web wehehas: https: / / laravel. com / docs/
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();
laravel výmluvný spolupracovník
$account = App\Account::find(10);
$user->account()->associate($account);
$user->save();
výmluvné vztahy
$roles = App\User::find(1)->roles()->orderBy('name')->get();
laravel aktualizovat všechny vztahy
$position->users()->update(['position_id' => 4]);
Laravel mass update vztah
$channel->videos()->update(['visibility' => true]);
laravel jak dotaz patřík vztahu
$movies = Movie::whereHas('director', function($q) {
$q->where('name', 'great');
})->get();