The above code can be executed, but all the fields in the attribute of the associated model are still queried.
$ User = UserAttribute: where ('uid', $ uid)-> with (['attribute' => function ($ query) {$ query-> pluck ('title') ;},])-> get ();
The above code can be executed, but all the fields in the attribute of the associated model are still queried.
Reply content:
$ User = UserAttribute: where ('uid', $ uid)-> with (['attribute' => function ($ query) {$ query-> pluck ('title') ;},])-> get ();
The above code can be executed, but all the fields in the attribute of the associated model are still queried.
You can select in the Model, but the id cannot be small, otherwise there is no association condition.
Public function attribute () {return $ this-> hasvalues ('attribute', 'attribute _ id')-> select ('id', 'title ');}
Related Articles:
Question about the association query of multiple Laravel conditions?
Laravel association query
Laravel