Imagine you have an "Article" model and to only retrieve the "id", "title", and "content" you can write it like the following.
<?php # App\Http\Controllers\ArticleController.php public function show(Article $article) { $a = $article->only(["id", "title", "content"]); dd($a); /* only contain "id", "title", "content" columns */ }
So now instead of getting all of the columns, you can explicitly specify to only retrieve the column you need it to.
Leave a reply