how to get data in inside the relationship into relationship with hasmany relationship in laravel code example
Example 1: whereHas site:https://laravel.com/docs/
use Illuminate\Database\Eloquent\Builder;
$posts = Post::whereHas('comments', function (Builder $query) {
$query->where('content', 'like', 'code%');
})->get();
$posts = Post::whereHas('comments', function (Builder $query) {
$query->where('content', 'like', 'code%');
}, '>=', 10)->get();
Example 2: laravel how to query belongsTo relationship
$movies = Movie::whereHas('director', function($q) {
$q->where('name', 'great');
})->get();