Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

whereHas site:https://laravel.com/docs/

use IlluminateDatabaseEloquentBuilder;

// Retrieve posts with at least one comment containing words like code%...
$posts = Post::whereHas('comments', function (Builder $query) {
    $query->where('content', 'like', 'code%');
})->get();

// Retrieve posts with at least ten comments containing words like code%...
$posts = Post::whereHas('comments', function (Builder $query) {
    $query->where('content', 'like', 'code%');
}, '>=', 10)->get();
Source by laravel.com #
 
PREVIOUS NEXT
Tagged: #whereHas
ADD COMMENT
Topic
Name
6+3 =