I am Using Observers in Laravel to add default values to attrbiutes.
public function creating($model)
{
if (!$model->company_id) $model->company_id = (Auth::check()) ? Auth::user()->company_id : null;
}
This works in every Controller. But if I create a custom Command in app\Console\Commands\
. I got an error:
Illuminate\Database\QueryException SQLSTATE[HY000]: General error: 1364 Field 'company_id' doesn't have a default value
How do I get Observers working from Command Line?
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2uyWvtJ
via IFTTT
Aucun commentaire:
Enregistrer un commentaire