$user = User::select(['id', 'name as nickname'])->first();
The query above will get the first user and the only column that will be retrieved is the "nickname".
If you are joining a table then make sure to use the "." dot syntax to specify which of the table column you are referring to.
Post::join('comments', 'posts.id', '=', 'comments.id') ->select('comments.title as subject') ->get();
Leave a reply