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

Creation   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 1
c 1
b 0
f 1
lcom 0
cbo 0
dl 0
loc 28
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A bootCreation() 0 19 1
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
}