| @@ -39,9 +39,8 @@ | ||
| 39 | 39 | ]; |
| 40 | 40 | |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | - * $searchable Columns in table to search | |
| 44 | 43 | * @var array |
| 45 | 44 | */ |
| 46 | 45 | protected $searchable = [ |
| 47 | 46 | 'first_name', |
| @@ -49,9 +48,8 @@ | ||
| 49 | 48 | 'email' |
| 50 | 49 | ]; |
| 51 | 50 | |
| 52 | 51 | /** |
| 53 | - * Local scope to filter subscribers by search/query string | |
| 54 | 52 | * @param ModelQueryBuilder $query |
| 55 | 53 | * @param string $search |
| 56 | 54 | * @return ModelQueryBuilder |
| 57 | 55 | */ |
| @@ -64,9 +62,9 @@ | ||
| 64 | 62 | $fields = $this->searchable; |
| 65 | 63 | $query->where(function ($query) use ($fields, $search) { |
| 66 | 64 | $query->where(array_shift($fields), 'LIKE', "%$search%"); |
| 67 | 65 | |
| 68 | - $nameArray = explode(' ', $search); | |
| 66 | + $nameArray = explode(' ', (string) $search); | |
| 69 | 67 | if (count($nameArray) >= 2) { |
| 70 | 68 | $query->orWhere(function ($q) use ($nameArray) { |
| 71 | 69 | $fname = array_shift($nameArray); |
| 72 | 70 | $lastName = implode(' ', $nameArray); |
| @@ -83,9 +81,8 @@ | ||
| 83 | 81 | return $query; |
| 84 | 82 | } |
| 85 | 83 | |
| 86 | 84 | /** |
| 87 | - * Local scope to filter subscribers by search/query string | |
| 88 | 85 | * @param ModelQueryBuilder $query |
| 89 | 86 | * @param array $statuses |
| 90 | 87 | * @return ModelQueryBuilder |
| 91 | 88 | */ |
| @@ -121,9 +118,9 @@ | ||
| 121 | 118 | if (isset($this->attributes['last_name'])) { |
| 122 | 119 | $fallBackName .= '+' . $this->attributes['last_name']; |
| 123 | 120 | } |
| 124 | 121 | |
| 125 | - $hash = md5(strtolower(trim($this->attributes['email']))); | |
| 122 | + $hash = md5(strtolower(trim($this->attributes['email'] ?? ''))); | |
| 126 | 123 | |
| 127 | 124 | $fallback = ''; |
| 128 | 125 | if ($fallBackName) { |
| 129 | 126 | $fallback = '&d=https%3A%2F%2Fui-avatars.com%2Fapi%2F' . urlencode($fallBackName) . '/128'; |
| @@ -208,9 +205,9 @@ | ||
| 208 | 205 | ->where('key', $metaKey) |
| 209 | 206 | ->first(); |
| 210 | 207 | if ($meta) { |
| 211 | 208 | $meta->value = maybe_serialize($metaValue); |
| 212 | - $meta->update(); | |
| 209 | + $meta->save(); | |
| 213 | 210 | } |
| 214 | 211 | |
| 215 | 212 | if (!$meta) { |
| 216 | 213 | Meta::create([ |
| @@ -230,13 +227,12 @@ | ||
| 230 | 227 | ->where('object_type', 'person_meta') |
| 231 | 228 | ->delete(); |
| 232 | 229 | } |
| 233 | 230 | |
| 234 | - public function restoreAvatar($person, $id) | |
| 231 | + public function restoreAvatar() | |
| 235 | 232 | { |
| 236 | - $person->where('id', $id)->update([ | |
| 237 | - 'avatar' => null | |
| 238 | - ]); | |
| 233 | + $this->avatar = null; | |
| 234 | + $this->save(); | |
| 239 | 235 | |
| 240 | - return $person; | |
| 236 | + return $this; | |
| 241 | 237 | } |
| 242 | 238 | } |