Advertisement
Guest User

Untitled

a guest
May 19th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Traits;
  4.  
  5. use App\User;
  6.  
  7. trait AddingCompany
  8. {
  9. public static function boot()
  10. {
  11. parent::boot();
  12.  
  13. static::creating(function ($model){
  14. /** @var User $user */
  15. $user = auth()->user();
  16. $model->fill([
  17. 'company_id' => $user->fk_company_id,
  18. 'created_by' => $user->id
  19. ]);
  20. });
  21.  
  22. static::updating(function ($model){
  23. $model->fill([
  24. 'updated_by' => auth()->id()
  25. ]);
  26. });
  27. }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement