Попробуйте, это будет работать. Дополнительная информация: Документация
$this->crud->addColumns([
'name' => 'agent_team_name',
'label' => 'Agent Team',
'type' => 'closure',
'function' => function ($entry) {
$team_id = $entry->tenants->agent_team_id;
return isset($team_id) ? Team::findOrFail($team_id)->name : '-';
},
'orderable' => true,
'orderLogic' => function ($query, $column, $columnDirection) {
return $query->join('tenants', 'students.tenant_id', 'tenants.id')
->join('teams', 'tenants.agent_team_id', 'teams.id')
->orderBy('teams.name', $columnDirection);
},
]);
$this->crud->addColumns([
'name' => 'client_team_name',
'label' => 'Client Team',
'type' => 'closure',
'function' => function ($entry) {
$team_id = $entry->tenants->client_team_id;
return isset($team_id) ? Team::findOrFail($team_id)->name : '-';
},
'orderable' => true,
'orderLogic' => function ($query, $column, $columnDirection) {
return $query->join('tenants', 'students.tenant_id', 'tenants.id')
->join('teams', 'tenants.client_team_id', 'teams.id')
->orderBy('teams.name', $columnDirection);
},
]);