Example #1
0
    $article3 = App\Article::create(array('title' => 'How to ride a bike', 'body' => '...'));
    return;
    // second way (never a mass-assignment alert if done this way)
    $article2 = new App\Article();
    $article2->title = 'How to be succesful!';
    $article2->body = 'This is some other body...';
    $article2->save();
    return 'Saved article. It has an id of ' . $article2->id;
    // first way
    $article = App\Article::create(array('title' => 'How to peel potatoes', 'body' => 'This is some body...'));
    return $article->id;
});
Route::get('article', function () {
    $article = new App\Article('How to peel a potato');
    $letter = 'o';
    if ($article->containsLetter($letter)) {
        return 'Contains: ' . $letter;
    }
    return 'Nope';
});
/************************************************************************************/
Route::get('conditional', function () {
    $list = array('Harry', 'Ron', 'Hermione');
    return View::make('hello')->withFriends($list);
});
/**********************************************************************************/
Route::get('home_test', function () {
    $name = DB::Connection()->getDatabaseName();
    return View::make('pages/home')->with('list', ['banana', 'pear', 'apple'])->with('flavors', ['banana', 'pear', 'apple'])->with('name', $name);
});
Route::get('about', function () {