Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel where has

use IlluminateDatabaseEloquentBuilder;

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

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