“Hubungan di Laravel” Kode Jawaban

bagaimana menggunakan di mana hubungan laravel

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

Situs WHERAS: 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 bagaimana menanyakan hubungan milik

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

Hubungan di Laravel

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

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

hubungan yang fasih

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

hubungan yang mendefinisikan Laravel

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

Jawaban yang mirip dengan “Hubungan di Laravel”

Pertanyaan yang mirip dengan “Hubungan di Laravel”

Lebih banyak jawaban terkait untuk “Hubungan di Laravel” di PHP

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya