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
Pull Request — master (#395)
by
unknown
01:26
created

Admin::getRememberToken()   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 0
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 $path_or_pic_base64_encoded
92
     */
93
    public function updateAdminPicture($path_or_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' => $path_or_pic_base64_encoded]);
97
98
        # Save the changes
99
        $this->update();
100
    }
101
102
    /**
103
     * get admin picture from extradata column
104
     * @return mixed
105
     */
106
    public function getAdminPicture(){
107
        $extdata = $this->getExtraDataObj();
108
        return $extdata->picture;
109
    }
110
111
    /**
112
     * find admin by primary key id
113
     * @param $admin_id
114
     * @return mixed
115
     */
116
    public function findById($admin_id){
117
        // Retrieve a model by its primary key...
118
        $admin = Admin::find($admin_id);
119
        // Retrieve the first model matching the query constraints...
120
        //$admin = Admin::where('id', $admin_id)->first();
121
        return $admin;
122
    }
123
124
    /**
125
     * Scope a query to get admin by id.
126
     * @param $query
127
     * @param $admin_id
128
     * @return mixed
129
     */
130
    public function scopeFindById($query, $admin_id){
131
        return $query->where('id', $admin_id);
132
    }
133
134
    /**
135
     * Scope a query to get admin by a $key and $value in extradata.
136
     * @param $query
137
     * @param $key
138
     * @param $value
139
     * @return mixed
140
     */
141
    public function scopeGetExtraData($query, $key, $value){
142
        //JSON_CONTAINS() function accepts the JSON field being searched and another to compare against.
143
        // It returns 1 when a match is found, e.g.
144
        return $query->whereRaw('JSON_CONTAINS(extradata->"$.' + $key + '", \'["' + $value + '"]\')');
145
        //return $query->where('extradata->' + $key, $value);
146
    }
147
148
    /**
149
     * get extradata as json object
150
     * @return mixed
151
     */
152
    public function getExtraDataObj(){
153
        return json_decode($this->extradata);
154
    }
155
156
    /**
157
     * Scope a query to get admin by a $key and search in $value.
158
     * @param $query
159
     * @param $key
160
     * @param $query_value
161
     * @return mixed
162
     */
163
    public function scopeSearchInExtraData($query, $key, $query_value){
164
        //JSON_SEARCH() function returns the path to the given match or NULL when there’s no match.
165
        // 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.
166
        return $query->whereRaw('JSON_SEARCH(extradata->"$.' + $key + '", "one", "%'+ $query_value + '%") IS NOT NULL');
167
        //return $query->where('extradata->' + $key, 'like', '%'+ $query_value + '%');
168
    }
169
170
171
    protected $fillable = array('first_name', 'last_name', 'email', 'password', 'extradata');
172
	/**
173
	 * The attributes excluded from the model's JSON form.
174
	 *
175
	 * @var array
176
	 */
177
	protected $hidden = array('password', 'remember_token');
178
179
180
181
182
}