Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Traits;
- use App\User;
- trait AddingCompany
- {
- public static function boot()
- {
- parent::boot();
- static::creating(function ($model){
- /** @var User $user */
- $user = auth()->user();
- $model->fill([
- 'company_id' => $user->fk_company_id,
- 'created_by' => $user->id
- ]);
- });
- static::updating(function ($model){
- $model->fill([
- 'updated_by' => auth()->id()
- ]);
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement