Answer the question
In order to leave comments, you need to log in
Why empty $this inside the model?
Hello. Faced with the fact that after transferring to another server, the application stopped working. Found out that none of the methods of getting dependencies works, because. $this contains an empty model.
For example, one of the methods of the User class
public function dialogs()
{
dd($this);
return $this->belongsToMany('App\Models\Dialog', 'dialog_user', 'userId', 'dialogId');
}
public function getDialogs()
{
$user = Auth::user();
$dialogs = $this->dialogService->getDialogs($user);
return response()->json($dialogs);
}
public function getDialogs(User $user)
{
$user->load(['dialogs' => function($query) {
$query->latest('updated_at');
}]);
if (!count($user->dialogs)) {
$responseHelper = new SendJsonResponse();
$responseHelper->sendWithError('no_dialogs');
}
return $user->dialogs;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question