image) { return; } return Storage::url($this->image); } /** * Get image url for the product image. */ public function getImageUrlAttribute() { return $this->image_url(); } /** * @return array */ public function toArray() { $array = parent::toArray(); $array['image_url'] = $this->image_url; return $array; } /** * Get the role that owns the admin. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function role() { return $this->belongsTo(RoleProxy::modelClass()); } /** * Checks if admin has permission to perform certain action. * * @param string $permission * @return bool */ public function hasPermission($permission) { if ( $this->role->permission_type == 'custom' && ! $this->role->permissions ) { return false; } return in_array($permission, $this->role->permissions); } /** * Send the password reset notification. * * @param string $token * @return void */ public function sendPasswordResetNotification($token) { $this->notify(new ResetPasswordNotification($token)); } /** * Create a new factory instance for the model. */ protected static function newFactory(): Factory { return AdminFactory::new(); } }