@@ -7,133 +7,133 @@ |
||
7 | 7 | class AclUser extends User |
8 | 8 | { |
9 | 9 | |
10 | - use SoftDeletes, HasApiTokens; |
|
11 | - protected $table = 'users'; |
|
12 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
13 | - protected $hidden = ['password', 'remember_token', 'deleted_at']; |
|
14 | - protected $guarded = ['id']; |
|
15 | - protected $fillable = ['profile_picture', 'name', 'email', 'password', 'locale', 'timezone']; |
|
16 | - public $searchable = ['name', 'email']; |
|
10 | + use SoftDeletes, HasApiTokens; |
|
11 | + protected $table = 'users'; |
|
12 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
13 | + protected $hidden = ['password', 'remember_token', 'deleted_at']; |
|
14 | + protected $guarded = ['id']; |
|
15 | + protected $fillable = ['profile_picture', 'name', 'email', 'password', 'locale', 'timezone']; |
|
16 | + public $searchable = ['name', 'email']; |
|
17 | 17 | |
18 | - public function getCreatedAtAttribute($value) |
|
19 | - { |
|
20 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
21 | - } |
|
22 | - |
|
23 | - public function getUpdatedAtAttribute($value) |
|
24 | - { |
|
25 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
26 | - } |
|
27 | - |
|
28 | - public function getDeletedAtAttribute($value) |
|
29 | - { |
|
30 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
31 | - } |
|
32 | - |
|
33 | - /** |
|
34 | - * Get the profile picture url. |
|
35 | - * @return string |
|
36 | - */ |
|
37 | - public function getProfilePictureAttribute($value) |
|
38 | - { |
|
39 | - return url(\Storage::url($value)); |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * Encrypt the password attribute before |
|
44 | - * saving it in the storage. |
|
45 | - * |
|
46 | - * @param string $value |
|
47 | - */ |
|
48 | - public function setPasswordAttribute($value) |
|
49 | - { |
|
50 | - $this->attributes['password'] = bcrypt($value); |
|
51 | - } |
|
52 | - |
|
53 | - /** |
|
54 | - * Get the entity's notifications. |
|
55 | - */ |
|
56 | - public function notifications() |
|
57 | - { |
|
58 | - return $this->morphMany('App\Modules\Notifications\Notification', 'notifiable')->orderBy('created_at', 'desc'); |
|
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * Get the entity's read notifications. |
|
63 | - */ |
|
64 | - public function readNotifications() |
|
65 | - { |
|
66 | - return $this->notifications()->whereNotNull('read_at'); |
|
67 | - } |
|
68 | - |
|
69 | - /** |
|
70 | - * Get the entity's unread notifications. |
|
71 | - */ |
|
72 | - public function unreadNotifications() |
|
73 | - { |
|
74 | - return $this->notifications()->whereNull('read_at'); |
|
75 | - } |
|
76 | - |
|
77 | - public function groups() |
|
78 | - { |
|
79 | - return $this->belongsToMany('App\Modules\Groups\AclGroup', 'users_groups', 'user_id', 'group_id')->whereNull('users_groups.deleted_at')->withTimestamps(); |
|
80 | - } |
|
81 | - |
|
82 | - public function oauthClients() |
|
83 | - { |
|
84 | - return $this->hasMany('App\Modules\OauthClients\OauthClient', 'user_id'); |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * Return fcm device tokens that will be used in sending fcm notifications. |
|
89 | - * |
|
90 | - * @return array |
|
91 | - */ |
|
92 | - public function routeNotificationForFCM() |
|
93 | - { |
|
94 | - $devices = \Core::pushNotificationDevices()->findBy(['user_id' => $this->id]); |
|
95 | - $tokens = []; |
|
96 | - |
|
97 | - foreach ($devices as $device) { |
|
98 | - if (\Core::users()->accessTokenExpiredOrRevoked($device->access_token)) { |
|
99 | - $device->forceDelete(); |
|
100 | - continue; |
|
101 | - } |
|
102 | - |
|
103 | - $tokens[] = $device->device_token; |
|
104 | - } |
|
105 | - |
|
106 | - return $tokens; |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * The channels the user receives notification broadcasts on. |
|
111 | - * |
|
112 | - * @return string |
|
113 | - */ |
|
114 | - public function receivesBroadcastNotificationsOn() |
|
115 | - { |
|
116 | - return 'users.'.$this->id; |
|
117 | - } |
|
118 | - |
|
119 | - /** |
|
120 | - * Custom password validation. |
|
121 | - * |
|
122 | - * @param string $password |
|
123 | - * @return boolean |
|
124 | - */ |
|
125 | - public function validateForPassportPasswordGrant($password) |
|
126 | - { |
|
127 | - if ($password == config('skeleton.social_pass')) { |
|
128 | - return true; |
|
129 | - } |
|
130 | - |
|
131 | - return \Hash::check($password, $this->password); |
|
132 | - } |
|
18 | + public function getCreatedAtAttribute($value) |
|
19 | + { |
|
20 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
21 | + } |
|
22 | + |
|
23 | + public function getUpdatedAtAttribute($value) |
|
24 | + { |
|
25 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
26 | + } |
|
27 | + |
|
28 | + public function getDeletedAtAttribute($value) |
|
29 | + { |
|
30 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
31 | + } |
|
32 | + |
|
33 | + /** |
|
34 | + * Get the profile picture url. |
|
35 | + * @return string |
|
36 | + */ |
|
37 | + public function getProfilePictureAttribute($value) |
|
38 | + { |
|
39 | + return url(\Storage::url($value)); |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * Encrypt the password attribute before |
|
44 | + * saving it in the storage. |
|
45 | + * |
|
46 | + * @param string $value |
|
47 | + */ |
|
48 | + public function setPasswordAttribute($value) |
|
49 | + { |
|
50 | + $this->attributes['password'] = bcrypt($value); |
|
51 | + } |
|
52 | + |
|
53 | + /** |
|
54 | + * Get the entity's notifications. |
|
55 | + */ |
|
56 | + public function notifications() |
|
57 | + { |
|
58 | + return $this->morphMany('App\Modules\Notifications\Notification', 'notifiable')->orderBy('created_at', 'desc'); |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * Get the entity's read notifications. |
|
63 | + */ |
|
64 | + public function readNotifications() |
|
65 | + { |
|
66 | + return $this->notifications()->whereNotNull('read_at'); |
|
67 | + } |
|
68 | + |
|
69 | + /** |
|
70 | + * Get the entity's unread notifications. |
|
71 | + */ |
|
72 | + public function unreadNotifications() |
|
73 | + { |
|
74 | + return $this->notifications()->whereNull('read_at'); |
|
75 | + } |
|
76 | + |
|
77 | + public function groups() |
|
78 | + { |
|
79 | + return $this->belongsToMany('App\Modules\Groups\AclGroup', 'users_groups', 'user_id', 'group_id')->whereNull('users_groups.deleted_at')->withTimestamps(); |
|
80 | + } |
|
81 | + |
|
82 | + public function oauthClients() |
|
83 | + { |
|
84 | + return $this->hasMany('App\Modules\OauthClients\OauthClient', 'user_id'); |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * Return fcm device tokens that will be used in sending fcm notifications. |
|
89 | + * |
|
90 | + * @return array |
|
91 | + */ |
|
92 | + public function routeNotificationForFCM() |
|
93 | + { |
|
94 | + $devices = \Core::pushNotificationDevices()->findBy(['user_id' => $this->id]); |
|
95 | + $tokens = []; |
|
96 | + |
|
97 | + foreach ($devices as $device) { |
|
98 | + if (\Core::users()->accessTokenExpiredOrRevoked($device->access_token)) { |
|
99 | + $device->forceDelete(); |
|
100 | + continue; |
|
101 | + } |
|
102 | + |
|
103 | + $tokens[] = $device->device_token; |
|
104 | + } |
|
105 | + |
|
106 | + return $tokens; |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * The channels the user receives notification broadcasts on. |
|
111 | + * |
|
112 | + * @return string |
|
113 | + */ |
|
114 | + public function receivesBroadcastNotificationsOn() |
|
115 | + { |
|
116 | + return 'users.'.$this->id; |
|
117 | + } |
|
118 | + |
|
119 | + /** |
|
120 | + * Custom password validation. |
|
121 | + * |
|
122 | + * @param string $password |
|
123 | + * @return boolean |
|
124 | + */ |
|
125 | + public function validateForPassportPasswordGrant($password) |
|
126 | + { |
|
127 | + if ($password == config('skeleton.social_pass')) { |
|
128 | + return true; |
|
129 | + } |
|
130 | + |
|
131 | + return \Hash::check($password, $this->password); |
|
132 | + } |
|
133 | 133 | |
134 | - public static function boot() |
|
135 | - { |
|
136 | - parent::boot(); |
|
137 | - AclUser::observe(\App::make('App\Modules\Users\ModelObservers\AclUserObserver')); |
|
138 | - } |
|
134 | + public static function boot() |
|
135 | + { |
|
136 | + parent::boot(); |
|
137 | + AclUser::observe(\App::make('App\Modules\Users\ModelObservers\AclUserObserver')); |
|
138 | + } |
|
139 | 139 | } |
@@ -9,32 +9,32 @@ |
||
9 | 9 | |
10 | 10 | class AclUser extends JsonResource |
11 | 11 | { |
12 | - /** |
|
13 | - * Transform the resource into an array. |
|
14 | - * |
|
15 | - * @param Request $request |
|
16 | - * @return array |
|
17 | - */ |
|
18 | - public function toArray($request) |
|
19 | - { |
|
20 | - if (! $this->resource) { |
|
21 | - return []; |
|
22 | - } |
|
12 | + /** |
|
13 | + * Transform the resource into an array. |
|
14 | + * |
|
15 | + * @param Request $request |
|
16 | + * @return array |
|
17 | + */ |
|
18 | + public function toArray($request) |
|
19 | + { |
|
20 | + if (! $this->resource) { |
|
21 | + return []; |
|
22 | + } |
|
23 | 23 | |
24 | - return [ |
|
25 | - 'id' => $this->id, |
|
26 | - 'name' => $this->name, |
|
27 | - 'email' => $this->email, |
|
28 | - 'profilePicture' => $this->profile_picture, |
|
29 | - 'notifications' => NotificationResource::collection($this->whenLoaded('notifications')), |
|
30 | - 'readNotifications' => NotificationResource::collection($this->whenLoaded('readNotifications')), |
|
31 | - 'unreadNotifications' => NotificationResource::collection($this->whenLoaded('unreadNotifications')), |
|
32 | - 'groups' => AclGroupResource::collection($this->whenLoaded('groups')), |
|
33 | - 'oauthClients' => OauthClientResource::collection($this->whenLoaded('oauthClients')), |
|
34 | - 'locale' => $this->locale, |
|
35 | - 'timezone' => $this->timezone, |
|
36 | - 'created_at' => $this->created_at, |
|
37 | - 'updated_at' => $this->updated_at, |
|
38 | - ]; |
|
39 | - } |
|
24 | + return [ |
|
25 | + 'id' => $this->id, |
|
26 | + 'name' => $this->name, |
|
27 | + 'email' => $this->email, |
|
28 | + 'profilePicture' => $this->profile_picture, |
|
29 | + 'notifications' => NotificationResource::collection($this->whenLoaded('notifications')), |
|
30 | + 'readNotifications' => NotificationResource::collection($this->whenLoaded('readNotifications')), |
|
31 | + 'unreadNotifications' => NotificationResource::collection($this->whenLoaded('unreadNotifications')), |
|
32 | + 'groups' => AclGroupResource::collection($this->whenLoaded('groups')), |
|
33 | + 'oauthClients' => OauthClientResource::collection($this->whenLoaded('oauthClients')), |
|
34 | + 'locale' => $this->locale, |
|
35 | + 'timezone' => $this->timezone, |
|
36 | + 'created_at' => $this->created_at, |
|
37 | + 'updated_at' => $this->updated_at, |
|
38 | + ]; |
|
39 | + } |
|
40 | 40 | } |
@@ -17,7 +17,7 @@ |
||
17 | 17 | */ |
18 | 18 | public function toArray($request) |
19 | 19 | { |
20 | - if (! $this->resource) { |
|
20 | + if ( ! $this->resource) { |
|
21 | 21 | return []; |
22 | 22 | } |
23 | 23 |
@@ -25,239 +25,239 @@ |
||
25 | 25 | |
26 | 26 | class UserController extends BaseApiController |
27 | 27 | { |
28 | - /** |
|
29 | - * List of all route actions that the base api controller |
|
30 | - * will skip permissions check for them. |
|
31 | - * @var array |
|
32 | - */ |
|
33 | - protected $skipPermissionCheck = ['account', 'logout', 'changePassword', 'saveProfile', 'account']; |
|
28 | + /** |
|
29 | + * List of all route actions that the base api controller |
|
30 | + * will skip permissions check for them. |
|
31 | + * @var array |
|
32 | + */ |
|
33 | + protected $skipPermissionCheck = ['account', 'logout', 'changePassword', 'saveProfile', 'account']; |
|
34 | 34 | |
35 | - /** |
|
36 | - * List of all route actions that the base api controller |
|
37 | - * will skip login check for them. |
|
38 | - * @var array |
|
39 | - */ |
|
40 | - protected $skipLoginCheck = ['login', 'loginSocial', 'register', 'sendReset', 'resetPassword', 'refreshToken', 'confirmEmail', 'resendEmailConfirmation']; |
|
35 | + /** |
|
36 | + * List of all route actions that the base api controller |
|
37 | + * will skip login check for them. |
|
38 | + * @var array |
|
39 | + */ |
|
40 | + protected $skipLoginCheck = ['login', 'loginSocial', 'register', 'sendReset', 'resetPassword', 'refreshToken', 'confirmEmail', 'resendEmailConfirmation']; |
|
41 | 41 | |
42 | - /** |
|
43 | - * The loginProxy implementation. |
|
44 | - * |
|
45 | - * @var App\Modules\Users\Proxy\LoginProxy |
|
46 | - */ |
|
47 | - protected $loginProxy; |
|
42 | + /** |
|
43 | + * The loginProxy implementation. |
|
44 | + * |
|
45 | + * @var App\Modules\Users\Proxy\LoginProxy |
|
46 | + */ |
|
47 | + protected $loginProxy; |
|
48 | 48 | |
49 | - /** |
|
50 | - * Init new object. |
|
51 | - * |
|
52 | - * @param LoginProxy $loginProxy |
|
53 | - * @param UserRepository $repo |
|
54 | - * @param CoreConfig $config |
|
55 | - * @return void |
|
56 | - */ |
|
57 | - public function __construct(LoginProxy $loginProxy, UserRepository $repo, CoreConfig $config) |
|
58 | - { |
|
59 | - $this->loginProxy = $loginProxy; |
|
60 | - parent::__construct($repo, $config, 'App\Modules\Users\Http\Resources\AclUser'); |
|
61 | - } |
|
49 | + /** |
|
50 | + * Init new object. |
|
51 | + * |
|
52 | + * @param LoginProxy $loginProxy |
|
53 | + * @param UserRepository $repo |
|
54 | + * @param CoreConfig $config |
|
55 | + * @return void |
|
56 | + */ |
|
57 | + public function __construct(LoginProxy $loginProxy, UserRepository $repo, CoreConfig $config) |
|
58 | + { |
|
59 | + $this->loginProxy = $loginProxy; |
|
60 | + parent::__construct($repo, $config, 'App\Modules\Users\Http\Resources\AclUser'); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * Insert the given model to storage. |
|
65 | - * |
|
66 | - * @param InsertUser $request |
|
67 | - * @return \Illuminate\Http\Response |
|
68 | - */ |
|
69 | - public function insert(InsertUser $request) |
|
70 | - { |
|
71 | - return new $this->modelResource($this->repo->save($request->all())); |
|
72 | - } |
|
63 | + /** |
|
64 | + * Insert the given model to storage. |
|
65 | + * |
|
66 | + * @param InsertUser $request |
|
67 | + * @return \Illuminate\Http\Response |
|
68 | + */ |
|
69 | + public function insert(InsertUser $request) |
|
70 | + { |
|
71 | + return new $this->modelResource($this->repo->save($request->all())); |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * Update the given model to storage. |
|
76 | - * |
|
77 | - * @param UpdateUser $request |
|
78 | - * @return \Illuminate\Http\Response |
|
79 | - */ |
|
80 | - public function update(UpdateUser $request) |
|
81 | - { |
|
82 | - return new $this->modelResource($this->repo->save($request->all())); |
|
83 | - } |
|
74 | + /** |
|
75 | + * Update the given model to storage. |
|
76 | + * |
|
77 | + * @param UpdateUser $request |
|
78 | + * @return \Illuminate\Http\Response |
|
79 | + */ |
|
80 | + public function update(UpdateUser $request) |
|
81 | + { |
|
82 | + return new $this->modelResource($this->repo->save($request->all())); |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * Return the logged in user account. |
|
87 | - * |
|
88 | - * @return \Illuminate\Http\Response |
|
89 | - */ |
|
90 | - public function account() |
|
91 | - { |
|
92 | - return new $this->modelResource($this->repo->account($this->relations)); |
|
93 | - } |
|
85 | + /** |
|
86 | + * Return the logged in user account. |
|
87 | + * |
|
88 | + * @return \Illuminate\Http\Response |
|
89 | + */ |
|
90 | + public function account() |
|
91 | + { |
|
92 | + return new $this->modelResource($this->repo->account($this->relations)); |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * Block the user. |
|
97 | - * |
|
98 | - * @param integer $id Id of the user. |
|
99 | - * @return \Illuminate\Http\Response |
|
100 | - */ |
|
101 | - public function block($id) |
|
102 | - { |
|
103 | - return new $this->modelResource($this->repo->block($id)); |
|
104 | - } |
|
95 | + /** |
|
96 | + * Block the user. |
|
97 | + * |
|
98 | + * @param integer $id Id of the user. |
|
99 | + * @return \Illuminate\Http\Response |
|
100 | + */ |
|
101 | + public function block($id) |
|
102 | + { |
|
103 | + return new $this->modelResource($this->repo->block($id)); |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * Unblock the user. |
|
108 | - * |
|
109 | - * @param integer $id Id of the user. |
|
110 | - * @return \Illuminate\Http\Response |
|
111 | - */ |
|
112 | - public function unblock($id) |
|
113 | - { |
|
114 | - return new $this->modelResource($this->repo->unblock($id)); |
|
115 | - } |
|
106 | + /** |
|
107 | + * Unblock the user. |
|
108 | + * |
|
109 | + * @param integer $id Id of the user. |
|
110 | + * @return \Illuminate\Http\Response |
|
111 | + */ |
|
112 | + public function unblock($id) |
|
113 | + { |
|
114 | + return new $this->modelResource($this->repo->unblock($id)); |
|
115 | + } |
|
116 | 116 | |
117 | - /** |
|
118 | - * Logout the user. |
|
119 | - * |
|
120 | - * @return \Illuminate\Http\Response |
|
121 | - */ |
|
122 | - public function logout() |
|
123 | - { |
|
124 | - return new GeneralResource($this->loginProxy->logout()); |
|
125 | - } |
|
117 | + /** |
|
118 | + * Logout the user. |
|
119 | + * |
|
120 | + * @return \Illuminate\Http\Response |
|
121 | + */ |
|
122 | + public function logout() |
|
123 | + { |
|
124 | + return new GeneralResource($this->loginProxy->logout()); |
|
125 | + } |
|
126 | 126 | |
127 | - /** |
|
128 | - * Handle a registration request. |
|
129 | - * |
|
130 | - * @param Register $request |
|
131 | - * @return \Illuminate\Http\Response |
|
132 | - */ |
|
133 | - public function register(Register $request) |
|
134 | - { |
|
135 | - return new $this->modelResource($this->repo->register($request->only('name', 'email', 'password'))); |
|
136 | - } |
|
127 | + /** |
|
128 | + * Handle a registration request. |
|
129 | + * |
|
130 | + * @param Register $request |
|
131 | + * @return \Illuminate\Http\Response |
|
132 | + */ |
|
133 | + public function register(Register $request) |
|
134 | + { |
|
135 | + return new $this->modelResource($this->repo->register($request->only('name', 'email', 'password'))); |
|
136 | + } |
|
137 | 137 | |
138 | - /** |
|
139 | - * Handle a login request to the application. |
|
140 | - * |
|
141 | - * @param Login $request |
|
142 | - * @return \Illuminate\Http\Response |
|
143 | - */ |
|
144 | - public function login(Login $request) |
|
145 | - { |
|
146 | - $result = $this->loginProxy->login($request->only('email', 'password'), $request->get('admin')); |
|
138 | + /** |
|
139 | + * Handle a login request to the application. |
|
140 | + * |
|
141 | + * @param Login $request |
|
142 | + * @return \Illuminate\Http\Response |
|
143 | + */ |
|
144 | + public function login(Login $request) |
|
145 | + { |
|
146 | + $result = $this->loginProxy->login($request->only('email', 'password'), $request->get('admin')); |
|
147 | 147 | |
148 | - return (new $this->modelResource($result['user']))->additional(['meta' => $result['tokens']]); |
|
149 | - } |
|
148 | + return (new $this->modelResource($result['user']))->additional(['meta' => $result['tokens']]); |
|
149 | + } |
|
150 | 150 | |
151 | - /** |
|
152 | - * Handle a social login request of the none admin to the application. |
|
153 | - * |
|
154 | - * @param LoginSocial $request |
|
155 | - * @return \Illuminate\Http\Response |
|
156 | - */ |
|
157 | - public function loginSocial(LoginSocial $request) |
|
158 | - { |
|
159 | - $result = $this->repo->loginSocial($request->get('auth_code'), $request->get('access_token'), $request->get('type')); |
|
151 | + /** |
|
152 | + * Handle a social login request of the none admin to the application. |
|
153 | + * |
|
154 | + * @param LoginSocial $request |
|
155 | + * @return \Illuminate\Http\Response |
|
156 | + */ |
|
157 | + public function loginSocial(LoginSocial $request) |
|
158 | + { |
|
159 | + $result = $this->repo->loginSocial($request->get('auth_code'), $request->get('access_token'), $request->get('type')); |
|
160 | 160 | |
161 | - return (new $this->modelResource($result['user']))->additional(['meta' => $result['tokens']]); |
|
162 | - } |
|
161 | + return (new $this->modelResource($result['user']))->additional(['meta' => $result['tokens']]); |
|
162 | + } |
|
163 | 163 | |
164 | - /** |
|
165 | - * Assign the given groups to the given user. |
|
166 | - * |
|
167 | - * @param AssignGroups $request |
|
168 | - * @return \Illuminate\Http\Response |
|
169 | - */ |
|
170 | - public function assignGroups(AssignGroups $request) |
|
171 | - { |
|
172 | - return new $this->modelResource($this->repo->assignGroups($request->get('user_id'), $request->get('group_ids'))); |
|
173 | - } |
|
164 | + /** |
|
165 | + * Assign the given groups to the given user. |
|
166 | + * |
|
167 | + * @param AssignGroups $request |
|
168 | + * @return \Illuminate\Http\Response |
|
169 | + */ |
|
170 | + public function assignGroups(AssignGroups $request) |
|
171 | + { |
|
172 | + return new $this->modelResource($this->repo->assignGroups($request->get('user_id'), $request->get('group_ids'))); |
|
173 | + } |
|
174 | 174 | |
175 | - /** |
|
176 | - * Send a reset link to the given user. |
|
177 | - * |
|
178 | - * @param SendReset $request |
|
179 | - * @return \Illuminate\Http\Response |
|
180 | - */ |
|
181 | - public function sendReset(SendReset $request) |
|
182 | - { |
|
183 | - return new GeneralResource($this->repo->sendReset($request->get('email'))); |
|
184 | - } |
|
175 | + /** |
|
176 | + * Send a reset link to the given user. |
|
177 | + * |
|
178 | + * @param SendReset $request |
|
179 | + * @return \Illuminate\Http\Response |
|
180 | + */ |
|
181 | + public function sendReset(SendReset $request) |
|
182 | + { |
|
183 | + return new GeneralResource($this->repo->sendReset($request->get('email'))); |
|
184 | + } |
|
185 | 185 | |
186 | - /** |
|
187 | - * Reset the given user's password. |
|
188 | - * |
|
189 | - * @param ResetPassword $request |
|
190 | - * @return \Illuminate\Http\Response |
|
191 | - */ |
|
192 | - public function resetPassword(ResetPassword $request) |
|
193 | - { |
|
194 | - return new GeneralResource($this->repo->resetPassword($request->only('email', 'password', 'password_confirmation', 'token'))); |
|
195 | - } |
|
186 | + /** |
|
187 | + * Reset the given user's password. |
|
188 | + * |
|
189 | + * @param ResetPassword $request |
|
190 | + * @return \Illuminate\Http\Response |
|
191 | + */ |
|
192 | + public function resetPassword(ResetPassword $request) |
|
193 | + { |
|
194 | + return new GeneralResource($this->repo->resetPassword($request->only('email', 'password', 'password_confirmation', 'token'))); |
|
195 | + } |
|
196 | 196 | |
197 | - /** |
|
198 | - * Change the logged in user password. |
|
199 | - * |
|
200 | - * @param ChangePassword $request |
|
201 | - * @return \Illuminate\Http\Response |
|
202 | - */ |
|
203 | - public function changePassword(ChangePassword $request) |
|
204 | - { |
|
205 | - return new GeneralResource($this->repo->changePassword($request->only('old_password', 'password', 'password_confirmation'))); |
|
206 | - } |
|
197 | + /** |
|
198 | + * Change the logged in user password. |
|
199 | + * |
|
200 | + * @param ChangePassword $request |
|
201 | + * @return \Illuminate\Http\Response |
|
202 | + */ |
|
203 | + public function changePassword(ChangePassword $request) |
|
204 | + { |
|
205 | + return new GeneralResource($this->repo->changePassword($request->only('old_password', 'password', 'password_confirmation'))); |
|
206 | + } |
|
207 | 207 | |
208 | - /** |
|
209 | - * Confirm email using the confirmation code. |
|
210 | - * |
|
211 | - * @param ConfirmEmail $request |
|
212 | - * @return \Illuminate\Http\Response |
|
213 | - */ |
|
214 | - public function confirmEmail(ConfirmEmail $request) |
|
215 | - { |
|
216 | - return new GeneralResource($this->repo->confirmEmail($request->only('confirmation_code'))); |
|
217 | - } |
|
208 | + /** |
|
209 | + * Confirm email using the confirmation code. |
|
210 | + * |
|
211 | + * @param ConfirmEmail $request |
|
212 | + * @return \Illuminate\Http\Response |
|
213 | + */ |
|
214 | + public function confirmEmail(ConfirmEmail $request) |
|
215 | + { |
|
216 | + return new GeneralResource($this->repo->confirmEmail($request->only('confirmation_code'))); |
|
217 | + } |
|
218 | 218 | |
219 | - /** |
|
220 | - * Resend the email confirmation mail. |
|
221 | - * |
|
222 | - * @param ResendEmailConfirmation $request |
|
223 | - * @return \Illuminate\Http\Response |
|
224 | - */ |
|
225 | - public function resendEmailConfirmation(ResendEmailConfirmation $request) |
|
226 | - { |
|
227 | - return new GeneralResource($this->repo->sendConfirmationEmail($request->get('email'))); |
|
228 | - } |
|
219 | + /** |
|
220 | + * Resend the email confirmation mail. |
|
221 | + * |
|
222 | + * @param ResendEmailConfirmation $request |
|
223 | + * @return \Illuminate\Http\Response |
|
224 | + */ |
|
225 | + public function resendEmailConfirmation(ResendEmailConfirmation $request) |
|
226 | + { |
|
227 | + return new GeneralResource($this->repo->sendConfirmationEmail($request->get('email'))); |
|
228 | + } |
|
229 | 229 | |
230 | - /** |
|
231 | - * Refresh the expired login token. |
|
232 | - * |
|
233 | - * @param RefreshToken $request |
|
234 | - * @return \Illuminate\Http\Response |
|
235 | - */ |
|
236 | - public function refreshToken(RefreshToken $request) |
|
237 | - { |
|
238 | - return new GeneralResource($this->loginProxy->refreshToken($request->get('refresh_token'))); |
|
239 | - } |
|
230 | + /** |
|
231 | + * Refresh the expired login token. |
|
232 | + * |
|
233 | + * @param RefreshToken $request |
|
234 | + * @return \Illuminate\Http\Response |
|
235 | + */ |
|
236 | + public function refreshToken(RefreshToken $request) |
|
237 | + { |
|
238 | + return new GeneralResource($this->loginProxy->refreshToken($request->get('refresh_token'))); |
|
239 | + } |
|
240 | 240 | |
241 | - /** |
|
242 | - * Paginate all users with in the given group. |
|
243 | - * |
|
244 | - * @param Request $request |
|
245 | - * @param string $groupName The name of the requested group. |
|
246 | - * @return \Illuminate\Http\Response |
|
247 | - */ |
|
248 | - public function group(Request $request, $groupName) |
|
249 | - { |
|
250 | - return $this->modelResource::collection($this->repo->group($request->all(), $groupName, $this->relations, $request->query('perPage'), $request->query('sortBy'), $request->query('desc'))); |
|
251 | - } |
|
241 | + /** |
|
242 | + * Paginate all users with in the given group. |
|
243 | + * |
|
244 | + * @param Request $request |
|
245 | + * @param string $groupName The name of the requested group. |
|
246 | + * @return \Illuminate\Http\Response |
|
247 | + */ |
|
248 | + public function group(Request $request, $groupName) |
|
249 | + { |
|
250 | + return $this->modelResource::collection($this->repo->group($request->all(), $groupName, $this->relations, $request->query('perPage'), $request->query('sortBy'), $request->query('desc'))); |
|
251 | + } |
|
252 | 252 | |
253 | - /** |
|
254 | - * Save the given data to the logged in user. |
|
255 | - * |
|
256 | - * @param SaveProfile $request |
|
257 | - * @return \Illuminate\Http\Response |
|
258 | - */ |
|
259 | - public function saveProfile(SaveProfile $request) |
|
260 | - { |
|
261 | - return new $this->modelResource($this->repo->saveProfile($request->only('name', 'email', 'profile_picture'))); |
|
262 | - } |
|
253 | + /** |
|
254 | + * Save the given data to the logged in user. |
|
255 | + * |
|
256 | + * @param SaveProfile $request |
|
257 | + * @return \Illuminate\Http\Response |
|
258 | + */ |
|
259 | + public function saveProfile(SaveProfile $request) |
|
260 | + { |
|
261 | + return new $this->modelResource($this->repo->saveProfile($request->only('name', 'email', 'profile_picture'))); |
|
262 | + } |
|
263 | 263 | } |
@@ -6,27 +6,27 @@ |
||
6 | 6 | |
7 | 7 | class SaveProfile extends FormRequest |
8 | 8 | { |
9 | - /** |
|
10 | - * Determine if the user is authorized to make this request. |
|
11 | - * |
|
12 | - * @return bool |
|
13 | - */ |
|
14 | - public function authorize() |
|
15 | - { |
|
16 | - return true; |
|
17 | - } |
|
9 | + /** |
|
10 | + * Determine if the user is authorized to make this request. |
|
11 | + * |
|
12 | + * @return bool |
|
13 | + */ |
|
14 | + public function authorize() |
|
15 | + { |
|
16 | + return true; |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * Get the validation rules that apply to the request. |
|
21 | - * |
|
22 | - * @return array |
|
23 | - */ |
|
24 | - public function rules() |
|
25 | - { |
|
26 | - return [ |
|
27 | - 'profile_picture' => 'nullable|string', |
|
28 | - 'name' => 'nullable|string', |
|
29 | - 'email' => 'required|email|unique:users,email,'.\Auth::id() |
|
30 | - ]; |
|
31 | - } |
|
19 | + /** |
|
20 | + * Get the validation rules that apply to the request. |
|
21 | + * |
|
22 | + * @return array |
|
23 | + */ |
|
24 | + public function rules() |
|
25 | + { |
|
26 | + return [ |
|
27 | + 'profile_picture' => 'nullable|string', |
|
28 | + 'name' => 'nullable|string', |
|
29 | + 'email' => 'required|email|unique:users,email,'.\Auth::id() |
|
30 | + ]; |
|
31 | + } |
|
32 | 32 | } |
@@ -6,25 +6,25 @@ |
||
6 | 6 | |
7 | 7 | class SendReset extends FormRequest |
8 | 8 | { |
9 | - /** |
|
10 | - * Determine if the user is authorized to make this request. |
|
11 | - * |
|
12 | - * @return bool |
|
13 | - */ |
|
14 | - public function authorize() |
|
15 | - { |
|
16 | - return true; |
|
17 | - } |
|
9 | + /** |
|
10 | + * Determine if the user is authorized to make this request. |
|
11 | + * |
|
12 | + * @return bool |
|
13 | + */ |
|
14 | + public function authorize() |
|
15 | + { |
|
16 | + return true; |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * Get the validation rules that apply to the request. |
|
21 | - * |
|
22 | - * @return array |
|
23 | - */ |
|
24 | - public function rules() |
|
25 | - { |
|
26 | - return [ |
|
27 | - 'email' => 'required|email' |
|
28 | - ]; |
|
29 | - } |
|
19 | + /** |
|
20 | + * Get the validation rules that apply to the request. |
|
21 | + * |
|
22 | + * @return array |
|
23 | + */ |
|
24 | + public function rules() |
|
25 | + { |
|
26 | + return [ |
|
27 | + 'email' => 'required|email' |
|
28 | + ]; |
|
29 | + } |
|
30 | 30 | } |
@@ -6,25 +6,25 @@ |
||
6 | 6 | |
7 | 7 | class RefreshToken extends FormRequest |
8 | 8 | { |
9 | - /** |
|
10 | - * Determine if the user is authorized to make this request. |
|
11 | - * |
|
12 | - * @return bool |
|
13 | - */ |
|
14 | - public function authorize() |
|
15 | - { |
|
16 | - return true; |
|
17 | - } |
|
9 | + /** |
|
10 | + * Determine if the user is authorized to make this request. |
|
11 | + * |
|
12 | + * @return bool |
|
13 | + */ |
|
14 | + public function authorize() |
|
15 | + { |
|
16 | + return true; |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * Get the validation rules that apply to the request. |
|
21 | - * |
|
22 | - * @return array |
|
23 | - */ |
|
24 | - public function rules() |
|
25 | - { |
|
26 | - return [ |
|
27 | - 'refresh_token' => 'required', |
|
28 | - ]; |
|
29 | - } |
|
19 | + /** |
|
20 | + * Get the validation rules that apply to the request. |
|
21 | + * |
|
22 | + * @return array |
|
23 | + */ |
|
24 | + public function rules() |
|
25 | + { |
|
26 | + return [ |
|
27 | + 'refresh_token' => 'required', |
|
28 | + ]; |
|
29 | + } |
|
30 | 30 | } |
@@ -6,27 +6,27 @@ |
||
6 | 6 | |
7 | 7 | class ChangePassword extends FormRequest |
8 | 8 | { |
9 | - /** |
|
10 | - * Determine if the user is authorized to make this request. |
|
11 | - * |
|
12 | - * @return bool |
|
13 | - */ |
|
14 | - public function authorize() |
|
15 | - { |
|
16 | - return true; |
|
17 | - } |
|
9 | + /** |
|
10 | + * Determine if the user is authorized to make this request. |
|
11 | + * |
|
12 | + * @return bool |
|
13 | + */ |
|
14 | + public function authorize() |
|
15 | + { |
|
16 | + return true; |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * Get the validation rules that apply to the request. |
|
21 | - * |
|
22 | - * @return array |
|
23 | - */ |
|
24 | - public function rules() |
|
25 | - { |
|
26 | - return [ |
|
27 | - 'old_password' => 'required', |
|
28 | - 'password' => 'required|confirmed|min:6', |
|
29 | - 'password_confirmation' => 'required' |
|
30 | - ]; |
|
31 | - } |
|
19 | + /** |
|
20 | + * Get the validation rules that apply to the request. |
|
21 | + * |
|
22 | + * @return array |
|
23 | + */ |
|
24 | + public function rules() |
|
25 | + { |
|
26 | + return [ |
|
27 | + 'old_password' => 'required', |
|
28 | + 'password' => 'required|confirmed|min:6', |
|
29 | + 'password_confirmation' => 'required' |
|
30 | + ]; |
|
31 | + } |
|
32 | 32 | } |
@@ -6,27 +6,27 @@ |
||
6 | 6 | |
7 | 7 | class InsertUser extends FormRequest |
8 | 8 | { |
9 | - /** |
|
10 | - * Determine if the user is authorized to make this request. |
|
11 | - * |
|
12 | - * @return bool |
|
13 | - */ |
|
14 | - public function authorize() |
|
15 | - { |
|
16 | - return true; |
|
17 | - } |
|
9 | + /** |
|
10 | + * Determine if the user is authorized to make this request. |
|
11 | + * |
|
12 | + * @return bool |
|
13 | + */ |
|
14 | + public function authorize() |
|
15 | + { |
|
16 | + return true; |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * Get the validation rules that apply to the request. |
|
21 | - * |
|
22 | - * @return array |
|
23 | - */ |
|
24 | - public function rules() |
|
25 | - { |
|
26 | - return [ |
|
27 | - 'name' => 'nullable|string', |
|
28 | - 'email' => 'required|email|unique:users,email,'.$this->get('id'), |
|
29 | - 'password' => 'nullable|min:6' |
|
30 | - ]; |
|
31 | - } |
|
19 | + /** |
|
20 | + * Get the validation rules that apply to the request. |
|
21 | + * |
|
22 | + * @return array |
|
23 | + */ |
|
24 | + public function rules() |
|
25 | + { |
|
26 | + return [ |
|
27 | + 'name' => 'nullable|string', |
|
28 | + 'email' => 'required|email|unique:users,email,'.$this->get('id'), |
|
29 | + 'password' => 'nullable|min:6' |
|
30 | + ]; |
|
31 | + } |
|
32 | 32 | } |
@@ -6,25 +6,25 @@ |
||
6 | 6 | |
7 | 7 | class ResendEmailConfirmation extends FormRequest |
8 | 8 | { |
9 | - /** |
|
10 | - * Determine if the user is authorized to make this request. |
|
11 | - * |
|
12 | - * @return bool |
|
13 | - */ |
|
14 | - public function authorize() |
|
15 | - { |
|
16 | - return true; |
|
17 | - } |
|
9 | + /** |
|
10 | + * Determine if the user is authorized to make this request. |
|
11 | + * |
|
12 | + * @return bool |
|
13 | + */ |
|
14 | + public function authorize() |
|
15 | + { |
|
16 | + return true; |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * Get the validation rules that apply to the request. |
|
21 | - * |
|
22 | - * @return array |
|
23 | - */ |
|
24 | - public function rules() |
|
25 | - { |
|
26 | - return [ |
|
27 | - 'email' => 'required|exists:users,email' |
|
28 | - ]; |
|
29 | - } |
|
19 | + /** |
|
20 | + * Get the validation rules that apply to the request. |
|
21 | + * |
|
22 | + * @return array |
|
23 | + */ |
|
24 | + public function rules() |
|
25 | + { |
|
26 | + return [ |
|
27 | + 'email' => 'required|exists:users,email' |
|
28 | + ]; |
|
29 | + } |
|
30 | 30 | } |