Как получить авторизацию пользователя в методе загрузки внутри модели?Php

Кемеровские программисты php общаются здесь
Гость
Как получить авторизацию пользователя в методе загрузки внутри модели?

Сообщение Гость »


Когда я звоню

Код: Выделить всё

auth()->user()
in the model.
and the result is null.
is it possible to call

Код: Выделить всё

auth()->user()
in the model ??
and this is my code

Код: Выделить всё

 /**
* The "booting" method of the model.
*
* @return void
*/
protected static function boot() {
parent::boot();
static::creating(function ($model) {
$model->created_by = auth()->user()->id;
});

static::updating(function ($model) {
$model->updated_by = auth()->user()->id;
});
}


Источник: https://stackoverflow.com/questions/672 ... de-a-model

Вернуться в «Php»