Skip to content

Commit f1ff75c

Browse files
committed
add extra data to fillable and new function to get admin picture
1 parent 67fbe33 commit f1ff75c

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/models/Admin.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,15 @@ public function updateAdminPicture($pic_base64_encoded){
9999
$this->update();
100100
}
101101

102+
/**
103+
* get admin picture from extradata column
104+
* @return mixed
105+
*/
106+
public function getAdminPicture(){
107+
$extdata = $this->scopeGetExtraDataObj();
108+
return $extdata->picture;
109+
}
110+
102111
/**
103112
* find admin by primary key id
104113
* @param $admin_id
@@ -136,6 +145,15 @@ public function scopeGetExtraData($query, $key, $value){
136145
//return $query->where('extradata->' + $key, $value);
137146
}
138147

148+
/**
149+
* Scope a query to get extradata as json object
150+
* @param $query
151+
* @return mixed
152+
*/
153+
public function scopeGetExtraDataObj($query){
154+
return json_decode($query->extradata);
155+
}
156+
139157
/**
140158
* Scope a query to get admin by a $key and search in $value.
141159
* @param $query
@@ -151,7 +169,7 @@ public function scopeSearchInExtraData($query, $key, $query_value){
151169
}
152170

153171

154-
protected $fillable = array('first_name', 'last_name', 'email', 'password');
172+
protected $fillable = array('first_name', 'last_name', 'email', 'password', 'extradata');
155173
/**
156174
* The attributes excluded from the model's JSON form.
157175
*

0 commit comments

Comments
 (0)