Passed
Push — master ( be1785...591f13 )
by Ajit
07:10
created

User::roleUser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App;
4
5
use Auth;
6
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...
7
use Illuminate\Auth\Authenticatable;
8
use Illuminate\Database\Eloquent\Model;
9
use Zizaco\Entrust\Traits\EntrustUserTrait;
10
use Illuminate\Auth\Passwords\CanResetPassword;
11
use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
12
use Spatie\MediaLibrary\HasMedia\Interfaces\HasMediaConversions;
13
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
14
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
15
16
class User extends Model implements AuthenticatableContract, CanResetPasswordContract, HasMediaConversions
17
{
18
    use Authenticatable, CanResetPassword, EntrustUserTrait, HasMediaTrait;
0 ignored issues
show
Bug introduced by
The trait Illuminate\Auth\Passwords\CanResetPassword requires the property $email which is not provided by App\User.
Loading history...
introduced by
The trait Spatie\MediaLibrary\HasMedia\HasMediaTrait requires some properties which are not provided by App\User: $collection_name, $media
Loading history...
introduced by
The trait Zizaco\Entrust\Traits\EntrustUserTrait requires some properties which are not provided by App\User: $roles, $perms
Loading history...
Bug introduced by
The trait Illuminate\Auth\Authenticatable requires the property $password which is not provided by App\User.
Loading history...
19
20
    /**
21
     * The database table used by the model.
22
     *
23
     * @var string
24
     */
25
    protected $table = 'mst_users';
26
27
    /**
28
     * The attributes that are mass assignable.
29
     *
30
     * @var array
31
     */
32
    protected $fillable = ['name', 'email', 'password', 'status'];
33
34
    /**
35
     * The attributes excluded from the model's JSON form.
36
     *
37
     * @var array
38
     */
39
    protected $hidden = ['password', 'remember_token'];
40
41
    // Media i.e. Image size conversion
42
    public function registerMediaConversions()
43
    {
44
        $this->addMediaConversion('thumb')
45
             ->setManipulations(['w' => 50, 'h' => 50, 'q' => 100, 'fit' => 'crop'])
46
             ->performOnCollections('staff');
47
48
        $this->addMediaConversion('form')
49
             ->setManipulations(['w' => 70, 'h' => 70, 'q' => 100, 'fit' => 'crop'])
50
             ->performOnCollections('staff');
51
    }
52
53
    public function scopeExcludeArchive($query)
54
    {
55
        if (Auth::User()->id != 1) {
56
            return $query->where('status', '!=', \constStatus::Archive)->where('id', '!=', 1);
57
        }
58
59
        return $query->where('status', '!=', \constStatus::Archive);
60
    }
61
62
    public function roleUser()
63
    {
64
        return $this->hasOne('App\RoleUser');
65
    }
66
}
67