Esempio n. 1
0
    $comments = App\Article::find(4)->comments;
    //->where('body', '>', 50)->get();
    foreach ($comments as $comment) {
        var_dump($comment->body);
    }
});
Route::get('article2', function () {
    /*
    	DELETING ARTICLES
    */
    // deleting multiple articles
    $victims = App\Article::where('id', '<', 3);
    $victims->delete();
    return 'Mass delete!';
    // deleting a single article
    App\Article::destroy(3);
    return 'Destroyed!';
    /*
    	UPDATING ARTICLES
    */
    // updating multiple articles
    $articles = App\Article::where('id', '<', 3);
    $articles->update(array('body' => 'test'));
    return 'Mass update!';
    // updating a single article
    $article = App\Article::find(3);
    $article->title = 'How to drive a car';
    $article->save();
    return 'Saved! New title is: ' . $article->title;
    /*
    	RETRIEVING ARTICLES