Get custom relationship data with Eloquent query builder I have this query :
FHINotification::with(['log'])
->where('user', $user->getSAMAccountName())
->whereNull('read_at')
->get();
"Log" model has a function to get custom data (more human readable than data in db)
public function getData(): array
{
Game::setWithoutStandardEdition(true);
$ldapService = App::make('App\Services\LdapService');
$log['url'] = $this->getUrl($this->task->resourceable_type, $this->task->string_resourceable_id);
$log['action'] = $this->getActionName($this->action);
$log['resource_name'] = $this->getResourceName($this->task->resourceable);
$log['user'] = $ldapService->getUserByUsername($this->user)->getDisplayName();
return $log;
}
I can call this method from a Log instance, for example: $log->getData() but is it possible to call it from a query builder ?
If not, I have to loop on my query result to format each one of them.
Thank you :)
This is what I want, perfect, thank you =)
Please sign in or create an account to participate in this conversation.