/** * Retrieve model name * * @return string */ public function model() { return UserManager::package()->config('models.permission'); }
/** * @param Request $request * @return \Illuminate\Http\JsonResponse */ public function authenticate(Request $request) { $credentials = $request->only('email', 'password'); try { if (!($token = app(JWTAuth::class)->attempt($credentials))) { return response()->json([UserManager::package()->trans('auth.incorrect_attempt')], 401); } } catch (JWTException $e) { return response()->json([UserManager::package()->trans('auth.error')], 500); } return response()->json(compact('token')); }
/** * User belongs to many permissions. * * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function userPermissions() { return $this->belongsToMany(UserManager::package()->config('models.permission'))->withTimestamps(); }
/** * Permission belongs to many roles. * * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function roles() { return $this->belongsToMany(UserManager::package()->config('models.role'))->withTimestamps(); }
/** * Allows to pretend or simulate package behavior. * * @param string $option * @return bool */ private function pretend($option) { return (bool) UserManager::package()->config('pretend.options.' . $option); }