Closed andrecuellar closed 2 years ago
Ok, I did this
public function columns()
{
$users = $this->builder()->get()->pluck('user');
return [
Column::callback(['user.username'], function ($username) use ($users) {
return view('admin::datatable.username-column', [
'user' => $users->filter(function ($user) use ($username){
return $user->username == $username;
})->first()
]);
})
........
The number of queries was down from 33 to 25
Hello, I have this column
So I want to avoid the query inside that callback
User::where('username', $username)->first();
How can I do? Is possible to get user like $query->user()?
User
is realted toMuse