Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

eloquent with

use AppModelsUser;

$users = User::with(['posts' => function ($query) {
    $query->where('title', 'like', '%code%');
}])->get();

# Select columns

Post::query()
    ->with(['user' => function($query) {
        $query->select('id','username');
    }])
    ->get();
Source by laravel.com #
 
PREVIOUS NEXT
Tagged: #eloquent
ADD COMMENT
Topic
Name
9+7 =