Completed
Push — master ( 9e3353...dc977e )
by Joao
02:24
created

Creation::bootCreation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 19
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
1
<?php namespace jlourenco\base\Traits;
2
3
trait Creation {
4
5
    /**
6
     * Boot the creation trait for a model.
7
     *
8
     * @return void
9
     */
10
    public static function bootCreation()
11
    {
12
13
        // create a event to happen on updating
14
        static::updating(function($table)  {
15
            $table->updated_by = Sentinel::getUser()->id;
16
        });
17
18
        // create a event to happen on deleting
19
        static::deleting(function($table)  {
20
            $table->deleted_by = Sentinel::getUser()->id;
21
        });
22
23
        // create a event to happen on saving
24
        static::saving(function($table)  {
25
            $table->created_by = Sentinel::getUser()->id;
26
        });
27
28
    }
29
30
}