One To Many Laravel

[Solved] One To Many Laravel | Php - Code Explorer | yomemimo.com
Question : laravel where has

Answered by : alberto-peripolli

use Illuminate\Database\Eloquent\Builder;
// Retrieve posts with at least one comment containing words like foo%...
$posts = App\Post::whereHas('comments', function (Builder $query) { $query->where('content', 'like', 'foo%');
})->get();
// Retrieve posts with at least ten comments containing words like foo%...
$posts = App\Post::whereHas('comments', function (Builder $query) { $query->where('content', 'like', 'foo%');
}, '>=', 10)->get();

Source : https://laravel.com/docs/7.x/eloquent-relationships | Last Update : Thu, 14 May 20

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

Answered by : tiago-frana

use Illuminate\Database\Eloquent\Builder;
// 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 : https://laravel.com/docs/8.x/eloquent-relationships#querying-relationship-existence | Last Update : Thu, 24 Dec 20

Question : Laravel many to many

Answered by : steveroland-nde-tsapi

users id - integer name - string
 
roles id - integer name - string
 
role_user user_id - integer role_id - integer

Source : https://laravel.com/docs/9.x/eloquent-relationships#many-to-many | Last Update : Fri, 22 Jul 22

Answers related to one to many laravel

Code Explorer Popular Question For Php