Browse Source

wip: fix Traits

3.x
wallo 2 years ago
parent
commit
e8896a6270
2 changed files with 4 additions and 3 deletions
  1. 3
    2
      app/Traits/Blamable.php
  2. 1
    1
      app/Traits/CompanyOwned.php

+ 3
- 2
app/Traits/Blamable.php View File

8
 {
8
 {
9
     public static function bootBlamable(): void
9
     public static function bootBlamable(): void
10
     {
10
     {
11
-        static::created(static function ($model) {
11
+        static::creating(static function ($model) {
12
             $model->created_by = Auth::check() ? Auth::id() : null;
12
             $model->created_by = Auth::check() ? Auth::id() : null;
13
             $model->updated_by = Auth::check() ? Auth::id() : null;
13
             $model->updated_by = Auth::check() ? Auth::id() : null;
14
         });
14
         });
15
 
15
 
16
-        static::updated(static function ($model) {
16
+        static::updating(static function ($model) {
17
             $model->updated_by = Auth::check() ? Auth::id() : null;
17
             $model->updated_by = Auth::check() ? Auth::id() : null;
18
+            $model->save();
18
         });
19
         });
19
     }
20
     }
20
 }
21
 }

+ 1
- 1
app/Traits/CompanyOwned.php View File

9
 {
9
 {
10
     public static function bootCompanyOwned(): void
10
     public static function bootCompanyOwned(): void
11
     {
11
     {
12
-        static::created(static function ($model) {
12
+        static::creating(static function ($model) {
13
             if (Auth::check() && Auth::user()->currentCompany) {
13
             if (Auth::check() && Auth::user()->currentCompany) {
14
                 $model->company_id = Auth::user()->currentCompany->id;
14
                 $model->company_id = Auth::user()->currentCompany->id;
15
             } else {
15
             } else {

Loading…
Cancel
Save