User::scopeExcludeArchive()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
1
<?php
2
3
namespace App;
4
5
use Auth;
6
use Illuminate\Auth\Authenticatable;
7
use Illuminate\Database\Eloquent\Model;
8
use Illuminate\Auth\Passwords\CanResetPassword;
9
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
10
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
11
use Lubus\Constants\Status;
0 ignored issues
show
Bug introduced by
The type Lubus\Constants\Status was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Zizaco\Entrust\Traits\EntrustUserTrait;
13
use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
14
use Spatie\MediaLibrary\HasMedia\Interfaces\HasMediaConversions;
15
use Spatie\MediaLibrary\HasMedia\Interfaces\HasMedia;
16
17
class User extends Model implements AuthenticatableContract, CanResetPasswordContract, HasMediaConversions
18
{
19
    use Authenticatable, CanResetPassword, EntrustUserTrait, HasMediaTrait;
20
21
    /**
22
     * The database table used by the model.
23
     *
24
     * @var string
25
     */
26
    protected $table = 'mst_users';
27
28
    /**
29
     * The attributes that are mass assignable.
30
     *
31
     * @var array
32
     */
33
    protected $fillable = ['name', 'email', 'password','status'];
34
35
    /**
36
     * The attributes excluded from the model's JSON form.
37
     *
38
     * @var array
39
     */
40
    protected $hidden = ['password', 'remember_token'];
41
42
    // Media i.e. Image size conversion
43
    public function registerMediaConversions()
44
    {
45
        $this->addMediaConversion('thumb')
46
             ->setManipulations(['w' => 50, 'h' => 50, 'q' => 100, 'fit' => 'crop'])
47
             ->performOnCollections('staff');
48
49
        $this->addMediaConversion('form')
50
             ->setManipulations(['w' => 70, 'h' => 70, 'q' => 100, 'fit' => 'crop'])
51
             ->performOnCollections('staff');
52
    }
53
54
    public function scopeExcludeArchive($query)
55
    {
56
        if (Auth::User()->id != 1) 
57
        {
58
            return $query->where('status','!=', \constStatus::Archive)->where('id','!=',1);
59
        }
60
61
        return $query->where('status','!=', \constStatus::Archive);
62
    }
63
64
    public function Role_user()
65
    {
66
        return $this->hasOne('App\Role_user');
67
    }
68
}
69