Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel eager-loading with selected columns

$results = User::with([
	'country' => function ($query) {
		$query->select('id','name');
	},'posts' => function ($query) {
		$query->select('id','user_id','title');
	},'posts.attachments' => function ($query) {
		$query->select('id','post_id','type');
	}])->get(['id','country_id','name']);
Source by laravel.io #
 
PREVIOUS NEXT
Tagged: #laravel #selected #columns
ADD COMMENT
Topic
Name
3+8 =