If you have a Trait that you want to add to a few Models to call their boot()
method automatically, you can call Trait's method as boot[TraitName]
1class Transaction extends Model2{3 use MultiTenantModelTrait;4}
1class Task extends Model2{3 use MultiTenantModelTrait;4}
1trait MultiTenantModelTrait 2{ 3 // This method's name is boot[TraitName] 4 // It will be auto-called as boot() of Transaction/Task 5 public static function bootMultiTenantModelTrait() 6 { 7 static::creating(function ($model) { 8 if (!$isAdmin) { 9 $isAdmin->created_by_id = auth()->id();10 }11 })12 }13}