@@ -6,15 +6,15 @@ |
||
6 | 6 | |
7 | 7 | class OauthClientsDatabaseSeeder extends Seeder |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the database seeds. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function run() |
|
15 | - { |
|
16 | - $this->call(ClearDataSeeder::class); |
|
17 | - $this->call(OauthClientsTableSeeder::class); |
|
18 | - $this->call(AssignRelationsSeeder::class); |
|
19 | - } |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + $this->call(ClearDataSeeder::class); |
|
17 | + $this->call(OauthClientsTableSeeder::class); |
|
18 | + $this->call(AssignRelationsSeeder::class); |
|
19 | + } |
|
20 | 20 | } |
@@ -6,15 +6,15 @@ |
||
6 | 6 | |
7 | 7 | class ClearDataSeeder extends Seeder |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the database seeds. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function run() |
|
15 | - { |
|
16 | - $permissions = \DB::table('permissions')->whereIn('model', ['oauthClient']); |
|
17 | - \DB::table('groups_permissions')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
|
18 | - $permissions->delete(); |
|
19 | - } |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + $permissions = \DB::table('permissions')->whereIn('model', ['oauthClient']); |
|
17 | + \DB::table('groups_permissions')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
|
18 | + $permissions->delete(); |
|
19 | + } |
|
20 | 20 | } |
@@ -7,28 +7,28 @@ |
||
7 | 7 | |
8 | 8 | class OauthClient extends JsonResource |
9 | 9 | { |
10 | - /** |
|
11 | - * Transform the resource into an array. |
|
12 | - * |
|
13 | - * @param Request $request |
|
14 | - * @return array |
|
15 | - */ |
|
16 | - public function toArray($request) |
|
17 | - { |
|
18 | - if (! $this->resource) { |
|
19 | - return []; |
|
20 | - } |
|
10 | + /** |
|
11 | + * Transform the resource into an array. |
|
12 | + * |
|
13 | + * @param Request $request |
|
14 | + * @return array |
|
15 | + */ |
|
16 | + public function toArray($request) |
|
17 | + { |
|
18 | + if (! $this->resource) { |
|
19 | + return []; |
|
20 | + } |
|
21 | 21 | |
22 | - return [ |
|
23 | - 'id' => $this->id, |
|
24 | - 'name' => $this->name, |
|
25 | - 'redirect' => $this->redirect, |
|
26 | - 'user' => new UserResource($this->whenLoaded('user')), |
|
27 | - 'personalAccessClient' => $this->personal_access_client, |
|
28 | - 'passwordClient' => $this->password_client, |
|
29 | - 'revoked' => $this->revoked, |
|
30 | - 'created_at' => $this->created_at, |
|
31 | - 'updated_at' => $this->updated_at, |
|
32 | - ]; |
|
33 | - } |
|
22 | + return [ |
|
23 | + 'id' => $this->id, |
|
24 | + 'name' => $this->name, |
|
25 | + 'redirect' => $this->redirect, |
|
26 | + 'user' => new UserResource($this->whenLoaded('user')), |
|
27 | + 'personalAccessClient' => $this->personal_access_client, |
|
28 | + 'passwordClient' => $this->password_client, |
|
29 | + 'revoked' => $this->revoked, |
|
30 | + 'created_at' => $this->created_at, |
|
31 | + 'updated_at' => $this->updated_at, |
|
32 | + ]; |
|
33 | + } |
|
34 | 34 | } |
@@ -11,59 +11,59 @@ |
||
11 | 11 | |
12 | 12 | class OauthClientController extends BaseApiController |
13 | 13 | { |
14 | - /** |
|
15 | - * Init new object. |
|
16 | - * |
|
17 | - * @param OauthClientRepository $repo |
|
18 | - * @param CoreConfig $config |
|
19 | - * @return void |
|
20 | - */ |
|
21 | - public function __construct(OauthClientRepository $repo, CoreConfig $config) |
|
22 | - { |
|
23 | - parent::__construct($repo, $config, 'App\Modules\OauthClients\Http\Resources\OauthClient'); |
|
24 | - } |
|
14 | + /** |
|
15 | + * Init new object. |
|
16 | + * |
|
17 | + * @param OauthClientRepository $repo |
|
18 | + * @param CoreConfig $config |
|
19 | + * @return void |
|
20 | + */ |
|
21 | + public function __construct(OauthClientRepository $repo, CoreConfig $config) |
|
22 | + { |
|
23 | + parent::__construct($repo, $config, 'App\Modules\OauthClients\Http\Resources\OauthClient'); |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * Insert the given model to storage. |
|
28 | - * |
|
29 | - * @param InsertOauthClient $request |
|
30 | - * @return \Illuminate\Http\Response |
|
31 | - */ |
|
32 | - public function insert(InsertOauthClient $request) |
|
33 | - { |
|
34 | - return new $this->modelResource($this->repo->save($request->all())); |
|
35 | - } |
|
26 | + /** |
|
27 | + * Insert the given model to storage. |
|
28 | + * |
|
29 | + * @param InsertOauthClient $request |
|
30 | + * @return \Illuminate\Http\Response |
|
31 | + */ |
|
32 | + public function insert(InsertOauthClient $request) |
|
33 | + { |
|
34 | + return new $this->modelResource($this->repo->save($request->all())); |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * Update the given model to storage. |
|
39 | - * |
|
40 | - * @param UpdateOauthClient $request |
|
41 | - * @return \Illuminate\Http\Response |
|
42 | - */ |
|
43 | - public function update(UpdateOauthClient $request) |
|
44 | - { |
|
45 | - return new $this->modelResource($this->repo->save($request->all())); |
|
46 | - } |
|
37 | + /** |
|
38 | + * Update the given model to storage. |
|
39 | + * |
|
40 | + * @param UpdateOauthClient $request |
|
41 | + * @return \Illuminate\Http\Response |
|
42 | + */ |
|
43 | + public function update(UpdateOauthClient $request) |
|
44 | + { |
|
45 | + return new $this->modelResource($this->repo->save($request->all())); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Revoke the given client. |
|
50 | - * |
|
51 | - * @param integer $clientId Id of the client |
|
52 | - * @return \Illuminate\Http\Response |
|
53 | - */ |
|
54 | - public function revoke($clientId) |
|
55 | - { |
|
56 | - return new GeneralResource($this->repo->revoke($clientId)); |
|
57 | - } |
|
48 | + /** |
|
49 | + * Revoke the given client. |
|
50 | + * |
|
51 | + * @param integer $clientId Id of the client |
|
52 | + * @return \Illuminate\Http\Response |
|
53 | + */ |
|
54 | + public function revoke($clientId) |
|
55 | + { |
|
56 | + return new GeneralResource($this->repo->revoke($clientId)); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Un revoke the given client. |
|
61 | - * |
|
62 | - * @param integer $clientId Id of the client |
|
63 | - * @return \Illuminate\Http\Response |
|
64 | - */ |
|
65 | - public function unRevoke($clientId) |
|
66 | - { |
|
67 | - return new GeneralResource($this->repo->unRevoke($clientId)); |
|
68 | - } |
|
59 | + /** |
|
60 | + * Un revoke the given client. |
|
61 | + * |
|
62 | + * @param integer $clientId Id of the client |
|
63 | + * @return \Illuminate\Http\Response |
|
64 | + */ |
|
65 | + public function unRevoke($clientId) |
|
66 | + { |
|
67 | + return new GeneralResource($this->repo->unRevoke($clientId)); |
|
68 | + } |
|
69 | 69 | } |
@@ -5,73 +5,73 @@ |
||
5 | 5 | |
6 | 6 | class NotificationRepository extends BaseRepository |
7 | 7 | { |
8 | - /** |
|
9 | - * Init new object. |
|
10 | - * |
|
11 | - * @param Notification $model |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function __construct(Notification $model) |
|
15 | - { |
|
16 | - parent::__construct($model); |
|
17 | - } |
|
8 | + /** |
|
9 | + * Init new object. |
|
10 | + * |
|
11 | + * @param Notification $model |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function __construct(Notification $model) |
|
15 | + { |
|
16 | + parent::__construct($model); |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * Retrieve all notifications of the logged in user. |
|
21 | - * |
|
22 | - * @param integer $perPage |
|
23 | - * @return Collection |
|
24 | - */ |
|
25 | - public function my($perPage) |
|
26 | - { |
|
27 | - return \Auth::user()->notifications()->paginate($perPage); |
|
28 | - } |
|
19 | + /** |
|
20 | + * Retrieve all notifications of the logged in user. |
|
21 | + * |
|
22 | + * @param integer $perPage |
|
23 | + * @return Collection |
|
24 | + */ |
|
25 | + public function my($perPage) |
|
26 | + { |
|
27 | + return \Auth::user()->notifications()->paginate($perPage); |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * Retrieve unread notifications of the logged in user. |
|
32 | - * |
|
33 | - * @param integer $perPage |
|
34 | - * @return Collection |
|
35 | - */ |
|
36 | - public function unread($perPage) |
|
37 | - { |
|
38 | - return \Auth::user()->unreadNotifications()->paginate($perPage); |
|
39 | - } |
|
30 | + /** |
|
31 | + * Retrieve unread notifications of the logged in user. |
|
32 | + * |
|
33 | + * @param integer $perPage |
|
34 | + * @return Collection |
|
35 | + */ |
|
36 | + public function unread($perPage) |
|
37 | + { |
|
38 | + return \Auth::user()->unreadNotifications()->paginate($perPage); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Mark the notification as read. |
|
43 | - * |
|
44 | - * @param integer $id |
|
45 | - * @return object |
|
46 | - */ |
|
47 | - public function markAsRead($id) |
|
48 | - { |
|
49 | - if ($notification = \Auth::user()->unreadNotifications()->where('id', $id)->first()) { |
|
50 | - $notification->markAsRead(); |
|
51 | - } |
|
52 | - } |
|
41 | + /** |
|
42 | + * Mark the notification as read. |
|
43 | + * |
|
44 | + * @param integer $id |
|
45 | + * @return object |
|
46 | + */ |
|
47 | + public function markAsRead($id) |
|
48 | + { |
|
49 | + if ($notification = \Auth::user()->unreadNotifications()->where('id', $id)->first()) { |
|
50 | + $notification->markAsRead(); |
|
51 | + } |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Mark all notifications as read. |
|
56 | - * |
|
57 | - * @return void |
|
58 | - */ |
|
59 | - public function markAllAsRead() |
|
60 | - { |
|
61 | - \Auth::user()->unreadNotifications()->update(['read_at' => now()]); |
|
62 | - } |
|
54 | + /** |
|
55 | + * Mark all notifications as read. |
|
56 | + * |
|
57 | + * @return void |
|
58 | + */ |
|
59 | + public function markAllAsRead() |
|
60 | + { |
|
61 | + \Auth::user()->unreadNotifications()->update(['read_at' => now()]); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Notify th given user with the given notification. |
|
66 | - * |
|
67 | - * @param collection $users |
|
68 | - * @param string $notification |
|
69 | - * @param object $notificationData |
|
70 | - * @return void |
|
71 | - */ |
|
72 | - public function notify($users, $notification, $notificationData = false) |
|
73 | - { |
|
74 | - $notification = 'App\Modules\Notifications\Notifications\\'.$notification; |
|
75 | - \Notification::send($users, new $notification($notificationData)); |
|
76 | - } |
|
64 | + /** |
|
65 | + * Notify th given user with the given notification. |
|
66 | + * |
|
67 | + * @param collection $users |
|
68 | + * @param string $notification |
|
69 | + * @param object $notificationData |
|
70 | + * @return void |
|
71 | + */ |
|
72 | + public function notify($users, $notification, $notificationData = false) |
|
73 | + { |
|
74 | + $notification = 'App\Modules\Notifications\Notifications\\'.$notification; |
|
75 | + \Notification::send($users, new $notification($notificationData)); |
|
76 | + } |
|
77 | 77 | } |
@@ -13,8 +13,8 @@ |
||
13 | 13 | |
14 | 14 | Route::group(['prefix' => 'notifications'], function () { |
15 | 15 | |
16 | - Route::get('/', 'NotificationController@index'); |
|
17 | - Route::get('unread', 'NotificationController@unread'); |
|
18 | - Route::get('read/{id}', 'NotificationController@markAsRead'); |
|
19 | - Route::get('read/all', 'NotificationController@markAllAsRead'); |
|
16 | + Route::get('/', 'NotificationController@index'); |
|
17 | + Route::get('unread', 'NotificationController@unread'); |
|
18 | + Route::get('read/{id}', 'NotificationController@markAsRead'); |
|
19 | + Route::get('read/all', 'NotificationController@markAllAsRead'); |
|
20 | 20 | }); |
@@ -6,27 +6,27 @@ |
||
6 | 6 | |
7 | 7 | class ModuleServiceProvider extends ServiceProvider |
8 | 8 | { |
9 | - /** |
|
10 | - * Bootstrap the module services. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function boot() |
|
15 | - { |
|
16 | - $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'notifications'); |
|
17 | - $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'notifications'); |
|
9 | + /** |
|
10 | + * Bootstrap the module services. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function boot() |
|
15 | + { |
|
16 | + $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'notifications'); |
|
17 | + $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'notifications'); |
|
18 | 18 | |
19 | - $this->loadMigrationsFrom(module_path('notifications', 'Database/Migrations', 'app')); |
|
20 | - $this->loadFactoriesFrom(module_path('notifications', 'Database/Factories', 'app')); |
|
21 | - } |
|
19 | + $this->loadMigrationsFrom(module_path('notifications', 'Database/Migrations', 'app')); |
|
20 | + $this->loadFactoriesFrom(module_path('notifications', 'Database/Factories', 'app')); |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * Register the module services. |
|
25 | - * |
|
26 | - * @return void |
|
27 | - */ |
|
28 | - public function register() |
|
29 | - { |
|
30 | - $this->app->register(RouteServiceProvider::class); |
|
31 | - } |
|
23 | + /** |
|
24 | + * Register the module services. |
|
25 | + * |
|
26 | + * @return void |
|
27 | + */ |
|
28 | + public function register() |
|
29 | + { |
|
30 | + $this->app->register(RouteServiceProvider::class); |
|
31 | + } |
|
32 | 32 | } |
@@ -6,25 +6,25 @@ |
||
6 | 6 | |
7 | 7 | class Notification extends JsonResource |
8 | 8 | { |
9 | - /** |
|
10 | - * Transform the resource into an array. |
|
11 | - * |
|
12 | - * @param Request $request |
|
13 | - * @return array |
|
14 | - */ |
|
15 | - public function toArray($request) |
|
16 | - { |
|
17 | - if (! $this->resource) { |
|
18 | - return []; |
|
19 | - } |
|
9 | + /** |
|
10 | + * Transform the resource into an array. |
|
11 | + * |
|
12 | + * @param Request $request |
|
13 | + * @return array |
|
14 | + */ |
|
15 | + public function toArray($request) |
|
16 | + { |
|
17 | + if (! $this->resource) { |
|
18 | + return []; |
|
19 | + } |
|
20 | 20 | |
21 | - return [ |
|
22 | - 'id' => $this->id, |
|
23 | - 'type' => $this->type, |
|
24 | - 'data' => $this->data, |
|
25 | - 'read_at' => $this->read_at, |
|
26 | - 'created_at' => $this->created_at, |
|
27 | - 'updated_at' => $this->updated_at, |
|
28 | - ]; |
|
29 | - } |
|
21 | + return [ |
|
22 | + 'id' => $this->id, |
|
23 | + 'type' => $this->type, |
|
24 | + 'data' => $this->data, |
|
25 | + 'read_at' => $this->read_at, |
|
26 | + 'created_at' => $this->created_at, |
|
27 | + 'updated_at' => $this->updated_at, |
|
28 | + ]; |
|
29 | + } |
|
30 | 30 | } |
@@ -10,65 +10,65 @@ |
||
10 | 10 | |
11 | 11 | class NotificationController extends BaseApiController |
12 | 12 | { |
13 | - /** |
|
14 | - * List of all route actions that the base api controller |
|
15 | - * will skip permissions check for them. |
|
16 | - * @var array |
|
17 | - */ |
|
18 | - protected $skipPermissionCheck = ['markAsRead', 'markAllAsRead', 'index', 'unread']; |
|
13 | + /** |
|
14 | + * List of all route actions that the base api controller |
|
15 | + * will skip permissions check for them. |
|
16 | + * @var array |
|
17 | + */ |
|
18 | + protected $skipPermissionCheck = ['markAsRead', 'markAllAsRead', 'index', 'unread']; |
|
19 | 19 | |
20 | - /** |
|
21 | - * Init new object. |
|
22 | - * |
|
23 | - * @param NotificationRepository $repo |
|
24 | - * @param CoreConfig $config |
|
25 | - * @return void |
|
26 | - */ |
|
27 | - public function __construct(NotificationRepository $repo, CoreConfig $config) |
|
28 | - { |
|
29 | - parent::__construct($repo, $config, 'App\Modules\Notifications\Http\Resources\Notification'); |
|
30 | - } |
|
20 | + /** |
|
21 | + * Init new object. |
|
22 | + * |
|
23 | + * @param NotificationRepository $repo |
|
24 | + * @param CoreConfig $config |
|
25 | + * @return void |
|
26 | + */ |
|
27 | + public function __construct(NotificationRepository $repo, CoreConfig $config) |
|
28 | + { |
|
29 | + parent::__construct($repo, $config, 'App\Modules\Notifications\Http\Resources\Notification'); |
|
30 | + } |
|
31 | 31 | |
32 | - /** |
|
33 | - * Retrieve all notifications of the logged in user. |
|
34 | - * |
|
35 | - * @param Request $request |
|
36 | - * @return \Illuminate\Http\Response |
|
37 | - */ |
|
38 | - public function index(Request $request) |
|
39 | - { |
|
40 | - return $this->modelResource::collection($this->repo->my($request->query('perPage'))); |
|
41 | - } |
|
32 | + /** |
|
33 | + * Retrieve all notifications of the logged in user. |
|
34 | + * |
|
35 | + * @param Request $request |
|
36 | + * @return \Illuminate\Http\Response |
|
37 | + */ |
|
38 | + public function index(Request $request) |
|
39 | + { |
|
40 | + return $this->modelResource::collection($this->repo->my($request->query('perPage'))); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * Retrieve unread notifications of the logged in user. |
|
45 | - * |
|
46 | - * @param Request $request |
|
47 | - * @return \Illuminate\Http\Response |
|
48 | - */ |
|
49 | - public function unread(Request $request) |
|
50 | - { |
|
51 | - return $this->modelResource::collection($this->repo->unread($request->query('perPage'))); |
|
52 | - } |
|
43 | + /** |
|
44 | + * Retrieve unread notifications of the logged in user. |
|
45 | + * |
|
46 | + * @param Request $request |
|
47 | + * @return \Illuminate\Http\Response |
|
48 | + */ |
|
49 | + public function unread(Request $request) |
|
50 | + { |
|
51 | + return $this->modelResource::collection($this->repo->unread($request->query('perPage'))); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Mark the notification as read. |
|
56 | - * |
|
57 | - * @param integer $id Id of the notification. |
|
58 | - * @return \Illuminate\Http\Response |
|
59 | - */ |
|
60 | - public function markAsRead($id) |
|
61 | - { |
|
62 | - return new GeneralResource($this->repo->markAsRead($id)); |
|
63 | - } |
|
54 | + /** |
|
55 | + * Mark the notification as read. |
|
56 | + * |
|
57 | + * @param integer $id Id of the notification. |
|
58 | + * @return \Illuminate\Http\Response |
|
59 | + */ |
|
60 | + public function markAsRead($id) |
|
61 | + { |
|
62 | + return new GeneralResource($this->repo->markAsRead($id)); |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * Mark all notifications as read. |
|
67 | - * |
|
68 | - * @return \Illuminate\Http\Response |
|
69 | - */ |
|
70 | - public function markAllAsRead() |
|
71 | - { |
|
72 | - return new GeneralResource($this->repo->markAllAsRead()); |
|
73 | - } |
|
65 | + /** |
|
66 | + * Mark all notifications as read. |
|
67 | + * |
|
68 | + * @return \Illuminate\Http\Response |
|
69 | + */ |
|
70 | + public function markAllAsRead() |
|
71 | + { |
|
72 | + return new GeneralResource($this->repo->markAllAsRead()); |
|
73 | + } |
|
74 | 74 | } |