How can I chain 2 or more select tags within an eager load? I am using select because I only want to load these 2 columns, nothing else. Tried many things.
$teams = Team::with(['captain' => function($q) {
$q->select('id', 'name')->where('show_name', true);
$q->select('id', 'username')->where('show_username', true);
}])
Obviously this first implementation will not work, but it shows what I am trying to achieve
$q->select('id', 'name', 'username')
->where('show_name', true)
->orWhere('show_username', true);
}])
This second implementation returns both 'name' and 'username' if either show_name or show_username is true. I wan't something like
$q->select('id', 'name')
->where('show_name', true)
->orWhere() // ??
->select('id', 'username')
->where('show_username', true);
}])
Thanks
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire