@@ -14,10 +14,11 @@ discard block |
||
14 | 14 | |
15 | 15 | // create a event to happen on deleting |
16 | 16 | static::deleting(function($table) { |
17 | - if (class_exists('Cartalyst\Sentinel\Laravel\Facades\Sentinel')) |
|
18 | - $table->deleted_by = Sentinel::getUser()->id; |
|
19 | - else |
|
20 | - $table->deleted_by = Auth::user()->id; |
|
17 | + if (class_exists('Cartalyst\Sentinel\Laravel\Facades\Sentinel')) { |
|
18 | + $table->deleted_by = Sentinel::getUser()->id; |
|
19 | + } else { |
|
20 | + $table->deleted_by = Auth::user()->id; |
|
21 | + } |
|
21 | 22 | }); |
22 | 23 | |
23 | 24 | // create a event to happen on saving |
@@ -25,19 +26,22 @@ discard block |
||
25 | 26 | |
26 | 27 | if (class_exists('Cartalyst\Sentinel\Laravel\Facades\Sentinel')) |
27 | 28 | { |
28 | - if (Sentinel::check()) |
|
29 | - $table->modified_by = Sentinel::getUser()->id; |
|
30 | - |
|
31 | - if (Sentinel::check() && ($table->created_by == null || !($table->created_by > 0))) |
|
32 | - $table->created_by = Sentinel::getUser()->id; |
|
33 | - } |
|
34 | - else |
|
29 | + if (Sentinel::check()) { |
|
30 | + $table->modified_by = Sentinel::getUser()->id; |
|
31 | + } |
|
32 | + |
|
33 | + if (Sentinel::check() && ($table->created_by == null || !($table->created_by > 0))) { |
|
34 | + $table->created_by = Sentinel::getUser()->id; |
|
35 | + } |
|
36 | + } else |
|
35 | 37 | { |
36 | - if (!Auth::guest()) |
|
37 | - $table->modified_by = Auth::user()->id; |
|
38 | + if (!Auth::guest()) { |
|
39 | + $table->modified_by = Auth::user()->id; |
|
40 | + } |
|
38 | 41 | |
39 | - if (!Auth::guest() && ($table->created_by == null || !($table->created_by > 0))) |
|
40 | - $table->created_by = Auth::user()->id; |
|
42 | + if (!Auth::guest() && ($table->created_by == null || !($table->created_by > 0))) { |
|
43 | + $table->created_by = Auth::user()->id; |
|
44 | + } |
|
41 | 45 | } |
42 | 46 | |
43 | 47 | }); |