Completed
Push — master ( 098c56...133368 )
by Arjay
15:29
created

src/AuditableTraitObserver.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Yajra\Auditable;
4
5
/**
6
 * Class AuditableObserver
7
 *
8
 * @package Yajra\Auditable
9
 */
10
class AuditableTraitObserver
11
{
12
    /**
13
     * Model's creating event hook.
14
     *
15
     * @param \Yajra\Auditable\AuditableTrait $model
16
     */
17
    public function creating($model)
18
    {
19
        if (! $model->created_by) {
20
            $model->created_by = auth($model->getAuthGuard())->check() ? auth($model->getAuthGuard())->id() : 0;
21
        }
22
23 View Code Duplication
        if (! $model->updated_by) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
24
            $model->updated_by = auth($model->getAuthGuard())->check() ? auth($model->getAuthGuard())->id() : 0;
25
        }
26
    }
27
28
    /**
29
     * Model's updating event hook.
30
     *
31
     * @param \Yajra\Auditable\AuditableTrait $model
32
     */
33
    public function updating($model)
34
    {
35 View Code Duplication
        if (! $model->updated_by) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
36
            $model->updated_by = auth($model->getAuthGuard())->check() ? auth($model->getAuthGuard())->id() : 0;
37
        }
38
    }
39
}
40