GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 3569fe...568257 )
by Alireza
12s
created

Admin::scopeFindById()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
namespace Serverfireteam\Panel;
3
4
use Illuminate\Auth\Authenticatable;
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
7
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
8
use Illuminate\Support\Facades\Input;
9
use Illuminate\Notifications\Notifiable;
10
11
class Admin extends Model implements AuthenticatableContract, CanResetPasswordContract {
0 ignored issues
show
Bug introduced by
There is one abstract method getAuthIdentifierName in this class; you could implement it, or declare this class as abstract.
Loading history...
12
13
    use Authenticatable, AdminCanResetPassword;
14
    use HasRoles;
15
    use Notifiable;
16
	/**
17
	 * The database table used by the model.
18
	 *
19
	 * @var string
20
	 */
21
	protected $table = 'admins';
22
    protected $remember_token_name      = 'remember_token';
23
24
25
    public function getAuthIdentifier()
26
    {
27
        return $this->getKey();
28
    }
29
30
    /**
31
     * Get the password for the user.
32
     *
33
     * @return string
34
     */
35
    public function getAuthPassword()
36
    {
37
        return $this->password;
38
    }
39
    
40
    public function getRememberToken(){
41
        return $this->remember_token;
42
    }
43
    
44
    public function  setRememberToken($value){
45
        $this->remember_token =  $value;
46
    }
47
48
    public function getReminderEmail(){
49
        $email = Input::only('email');
50
        return $email['email'];
51
    }
52
53
54
    public function getRememberTokenName(){
55
        return $this->remember_token_name;
56
    }
57
58
59
    /**
60
     * To get all Admins that has $key and $value on extradata field
61
     * @param $key
62
     * @param $value
63
     * @return mixed
64
     */
65
    public function getAllExtraData($key, $value){
66
        //defined by local scope
67
        return Admin::getExtraData($key, $value)->get();
68
        //return Admin::where('extradata->' + $key, $value)->get();
69
        //JSON_CONTAINS() function accepts the JSON field being searched and another to compare against.
70
        // It returns 1 when a match is found, e.g.
71
        //return Admin::whereRaw('JSON_CONTAINS(extradata->"$.' + $key + '", \'["' + $value + '"]\')')->get();
72
    }
73
74
    /**
75
     * Get all the Admins who has $query in $key on extradata field
76
     * @param $key
77
     * @param $query
78
     * @return mixed
79
     */
80
    public function getSearchInExtraData($key, $query){
81
        //defined by local scope
82
        return Admin::searchInExtraData($key, $query)->get();
83
        //return Admin::where('extradata->' + $key, 'like', '%'+ $query + '%')->get();
84
        //JSON_SEARCH() function returns the path to the given match or NULL when there’s no match.
85
        // It is passed the JSON document being searched, 'one' to find the first match or 'all' to find all matches, and a search string, e.g.
86
        //return Admin::whereRaw('JSON_SEARCH(extradata->"$.' + $key + '", "one", "%'+ $query + '%") IS NOT NULL')->get();
87
    }
88
89
    /**
90
     * add or update admin's picture.
91
     * @param $pic_base64_encoded
92
     */
93
    public function updateAdminPicture($pic_base64_encoded){
94
        //use forceFill() which will bypass the mass assignment check to perform update on any JSON path,
95
        // if path is not there, it will be created and if it’s present it will be updated accordingly.
96
        $this->forceFill(['extradata->picture' => $pic_base64_encoded]);
97
98
        # Save the changes
99
        $this->update();
100
    }
101
102
    /**
103
     * find admin by primary key id
104
     * @param $admin_id
105
     * @return mixed
106
     */
107
    public function findById($admin_id){
108
        // Retrieve a model by its primary key...
109
        $admin = Admin::find($admin_id);
110
        // Retrieve the first model matching the query constraints...
111
        //$admin = Admin::where('id', $admin_id)->first();
112
        return $admin;
113
    }
114
115
    /**
116
     * Scope a query to get admin by id.
117
     * @param $query
118
     * @param $admin_id
119
     * @return mixed
120
     */
121
    public function scopeFindById($query, $admin_id){
122
        return $query->where('id', $admin_id);
123
    }
124
125
    /**
126
     * Scope a query to get admin by a $key and $value in extradata.
127
     * @param $query
128
     * @param $key
129
     * @param $value
130
     * @return mixed
131
     */
132
    public function scopeGetExtraData($query, $key, $value){
133
        //JSON_CONTAINS() function accepts the JSON field being searched and another to compare against.
134
        // It returns 1 when a match is found, e.g.
135
        return $query->whereRaw('JSON_CONTAINS(extradata->"$.' + $key + '", \'["' + $value + '"]\')');
136
        //return $query->where('extradata->' + $key, $value);
137
    }
138
139
    /**
140
     * Scope a query to get admin by a $key and search in $value.
141
     * @param $query
142
     * @param $key
143
     * @param $query_value
144
     * @return mixed
145
     */
146
    public function scopeSearchInExtraData($query, $key, $query_value){
147
        //JSON_SEARCH() function returns the path to the given match or NULL when there’s no match.
148
        // It is passed the JSON document being searched, 'one' to find the first match or 'all' to find all matches, and a search string, e.g.
149
        return $query->whereRaw('JSON_SEARCH(extradata->"$.' + $key + '", "one", "%'+ $query_value + '%") IS NOT NULL');
150
        //return $query->where('extradata->' + $key, 'like', '%'+ $query_value + '%');
151
    }
152
153
154
    protected $fillable = array('first_name', 'last_name', 'email', 'password');
155
	/**
156
	 * The attributes excluded from the model's JSON form.
157
	 *
158
	 * @var array
159
	 */
160
	protected $hidden = array('password', 'remember_token');
161
162
163
164
165
}