Answer the question
In order to leave comments, you need to log in
eloquent events not working in laravel 4.2. What am I doing wrong?
I understand this framework.
I took a solution from a bunch of manuals and inserted the following lines into the model under a blueprint to process model events:
public static function boot() {
parent::boot();
static::creating(function($model) {
$model->firm_hash = md5(str_random(25));
return true;
});
static::updating(function($model){
$model->firm_colors = 'ddddddddd';
});
}
Route::get('/test/update-firm-colors/{firm_id}', function($firm_id){
$firm = BusinessFirm::find($firm_id);
$firm->firm_colors = str_random(6); // Для теста
$firm->save();
return Response::json($firm);
});
Answer the question
In order to leave comments, you need to log in
I specially downloaded L4.2 to check - everything works as it should.
So the error is somewhere else. You need to go all the way step by step and see why it does not work. (Although 80% that everything works as it should, but you are looking in the wrong direction).
PS
Why use 4.2? It has not been relevant for a long time.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question