I added a method to one of my models:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Test extends Model
{
public static function boot()
{
parent::boot();
static::created(function ($model) {
//log $model or maybe do something more complex here
});
}
}
And i wish to extend the same behaviour to many other models. Copy pasting this doesent seem like a good idea because if something changes i dont want to change it in different places. What is the best solution to write this only once and get the same behaviour to multiple models?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire