“związek w Laravel” Kod odpowiedzi

Jak używać, gdzie relacja Laravel

Event::with(["owner", "participants" => function($q) use($someId){
    $q->where('participants.IdUser', '=', 1);
    //$q->where('some other field', $someId);
}])
Alive Angelfish

gdzie strona: 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();
Tiago F2

Laravel, jak zapytać o związek przynależności

$movies = Movie::whereHas('director', function($q) {
    $q->where('name', 'great');
})->get();
Fragile Flatworm

związek w Laravel

N + 1
return new SongsCollection(Song::with('album')->get());

'songs' => SongResource::collection($this->whenLoaded($this->songs))
Elegant Echidna

wymowne relacje

$roles = App\User::find(1)->roles()->orderBy('name')->get();
Energetic Emu

Laravel definiujący związek

$user->posts()->where('active', 1)->get();
Cooperative Crab

Odpowiedzi podobne do “związek w Laravel”

Pytania podobne do “związek w Laravel”

Więcej pokrewnych odpowiedzi na “związek w Laravel” w PHP

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu