@@ -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', ['pushNotificationDevice']); |
|
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', ['pushNotificationDevice']); |
|
17 | + \DB::table('groups_permissions')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
|
18 | + $permissions->delete(); |
|
19 | + } |
|
20 | 20 | } |
@@ -7,25 +7,25 @@ |
||
7 | 7 | |
8 | 8 | class PushNotificationDevice 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 | - 'device_token' => $this->device_token, |
|
25 | - 'access_token' => $this->access_token, |
|
26 | - 'user' => new UserResource($this->whenLoaded('user')), |
|
27 | - 'created_at' => $this->created_at, |
|
28 | - 'updated_at' => $this->updated_at, |
|
29 | - ]; |
|
30 | - } |
|
22 | + return [ |
|
23 | + 'id' => $this->id, |
|
24 | + 'device_token' => $this->device_token, |
|
25 | + 'access_token' => $this->access_token, |
|
26 | + 'user' => new UserResource($this->whenLoaded('user')), |
|
27 | + 'created_at' => $this->created_at, |
|
28 | + 'updated_at' => $this->updated_at, |
|
29 | + ]; |
|
30 | + } |
|
31 | 31 | } |
@@ -11,55 +11,55 @@ |
||
11 | 11 | |
12 | 12 | class PushNotificationDeviceController extends BaseApiController |
13 | 13 | { |
14 | - /** |
|
15 | - * List of all route actions that the base api controller |
|
16 | - * will skip permissions check for them. |
|
17 | - * @var array |
|
18 | - */ |
|
19 | - protected $skipPermissionCheck = ['registerDevice']; |
|
14 | + /** |
|
15 | + * List of all route actions that the base api controller |
|
16 | + * will skip permissions check for them. |
|
17 | + * @var array |
|
18 | + */ |
|
19 | + protected $skipPermissionCheck = ['registerDevice']; |
|
20 | 20 | |
21 | - /** |
|
22 | - * Init new object. |
|
23 | - * |
|
24 | - * @param PushNotificationDeviceRepository $repo |
|
25 | - * @param CoreConfig $config |
|
26 | - * @return void |
|
27 | - */ |
|
28 | - public function __construct(PushNotificationDeviceRepository $repo, CoreConfig $config) |
|
29 | - { |
|
30 | - parent::__construct($repo, $config, 'App\Modules\PushNotificationDevices\Http\Resources\PushNotificationDevice'); |
|
31 | - } |
|
21 | + /** |
|
22 | + * Init new object. |
|
23 | + * |
|
24 | + * @param PushNotificationDeviceRepository $repo |
|
25 | + * @param CoreConfig $config |
|
26 | + * @return void |
|
27 | + */ |
|
28 | + public function __construct(PushNotificationDeviceRepository $repo, CoreConfig $config) |
|
29 | + { |
|
30 | + parent::__construct($repo, $config, 'App\Modules\PushNotificationDevices\Http\Resources\PushNotificationDevice'); |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * Insert the given model to storage. |
|
35 | - * |
|
36 | - * @param InsertPushNotificationDevice $request |
|
37 | - * @return \Illuminate\Http\Response |
|
38 | - */ |
|
39 | - public function insert(InsertPushNotificationDevice $request) |
|
40 | - { |
|
41 | - return new $this->modelResource($this->repo->save($request->all())); |
|
42 | - } |
|
33 | + /** |
|
34 | + * Insert the given model to storage. |
|
35 | + * |
|
36 | + * @param InsertPushNotificationDevice $request |
|
37 | + * @return \Illuminate\Http\Response |
|
38 | + */ |
|
39 | + public function insert(InsertPushNotificationDevice $request) |
|
40 | + { |
|
41 | + return new $this->modelResource($this->repo->save($request->all())); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * Update the given model to storage. |
|
46 | - * |
|
47 | - * @param UpdatePushNotificationDevice $request |
|
48 | - * @return \Illuminate\Http\Response |
|
49 | - */ |
|
50 | - public function update(UpdatePushNotificationDevice $request) |
|
51 | - { |
|
52 | - return new $this->modelResource($this->repo->save($request->all())); |
|
53 | - } |
|
44 | + /** |
|
45 | + * Update the given model to storage. |
|
46 | + * |
|
47 | + * @param UpdatePushNotificationDevice $request |
|
48 | + * @return \Illuminate\Http\Response |
|
49 | + */ |
|
50 | + public function update(UpdatePushNotificationDevice $request) |
|
51 | + { |
|
52 | + return new $this->modelResource($this->repo->save($request->all())); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Register the given device to the logged in user. |
|
57 | - * |
|
58 | - * @param RegisterDevice $request |
|
59 | - * @return \Illuminate\Http\Response |
|
60 | - */ |
|
61 | - public function registerDevice(RegisterDevice $request) |
|
62 | - { |
|
63 | - return new $this->modelResource($this->repo->registerDevice($request->all())); |
|
64 | - } |
|
55 | + /** |
|
56 | + * Register the given device to the logged in user. |
|
57 | + * |
|
58 | + * @param RegisterDevice $request |
|
59 | + * @return \Illuminate\Http\Response |
|
60 | + */ |
|
61 | + public function registerDevice(RegisterDevice $request) |
|
62 | + { |
|
63 | + return new $this->modelResource($this->repo->registerDevice($request->all())); |
|
64 | + } |
|
65 | 65 | } |
@@ -6,48 +6,48 @@ |
||
6 | 6 | class PushNotificationDevice extends Model |
7 | 7 | { |
8 | 8 | |
9 | - use SoftDeletes; |
|
10 | - protected $table = 'push_notifications_devices'; |
|
11 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
12 | - protected $hidden = ['deleted_at', 'access_token']; |
|
13 | - protected $guarded = ['id']; |
|
14 | - protected $fillable = ['device_token', 'user_id', 'access_token']; |
|
15 | - public $searchable = ['device_token']; |
|
16 | - |
|
17 | - public function getCreatedAtAttribute($value) |
|
18 | - { |
|
19 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
20 | - } |
|
21 | - |
|
22 | - public function getUpdatedAtAttribute($value) |
|
23 | - { |
|
24 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
25 | - } |
|
26 | - |
|
27 | - public function getDeletedAtAttribute($value) |
|
28 | - { |
|
29 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
30 | - } |
|
9 | + use SoftDeletes; |
|
10 | + protected $table = 'push_notifications_devices'; |
|
11 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
12 | + protected $hidden = ['deleted_at', 'access_token']; |
|
13 | + protected $guarded = ['id']; |
|
14 | + protected $fillable = ['device_token', 'user_id', 'access_token']; |
|
15 | + public $searchable = ['device_token']; |
|
16 | + |
|
17 | + public function getCreatedAtAttribute($value) |
|
18 | + { |
|
19 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
20 | + } |
|
21 | + |
|
22 | + public function getUpdatedAtAttribute($value) |
|
23 | + { |
|
24 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
25 | + } |
|
26 | + |
|
27 | + public function getDeletedAtAttribute($value) |
|
28 | + { |
|
29 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
30 | + } |
|
31 | 31 | |
32 | - public function user() |
|
33 | - { |
|
34 | - return $this->belongsTo('App\Modules\Users\AclUser'); |
|
35 | - } |
|
36 | - |
|
37 | - /** |
|
38 | - * Encrypt the access_token attribute before |
|
39 | - * saving it in the storage. |
|
40 | - * |
|
41 | - * @param string $value |
|
42 | - */ |
|
43 | - public function setLoginTokenAttribute($value) |
|
44 | - { |
|
45 | - $this->attributes['access_token'] = encrypt($value); |
|
46 | - } |
|
47 | - |
|
48 | - public static function boot() |
|
49 | - { |
|
50 | - parent::boot(); |
|
51 | - PushNotificationDevice::observe(\App::make('App\Modules\PushNotificationDevices\ModelObservers\PushNotificationDeviceObserver')); |
|
52 | - } |
|
32 | + public function user() |
|
33 | + { |
|
34 | + return $this->belongsTo('App\Modules\Users\AclUser'); |
|
35 | + } |
|
36 | + |
|
37 | + /** |
|
38 | + * Encrypt the access_token attribute before |
|
39 | + * saving it in the storage. |
|
40 | + * |
|
41 | + * @param string $value |
|
42 | + */ |
|
43 | + public function setLoginTokenAttribute($value) |
|
44 | + { |
|
45 | + $this->attributes['access_token'] = encrypt($value); |
|
46 | + } |
|
47 | + |
|
48 | + public static function boot() |
|
49 | + { |
|
50 | + parent::boot(); |
|
51 | + PushNotificationDevice::observe(\App::make('App\Modules\PushNotificationDevices\ModelObservers\PushNotificationDeviceObserver')); |
|
52 | + } |
|
53 | 53 | } |
@@ -6,37 +6,37 @@ |
||
6 | 6 | class AclPermission extends Model |
7 | 7 | { |
8 | 8 | |
9 | - use SoftDeletes; |
|
10 | - protected $table = 'permissions'; |
|
11 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
12 | - protected $hidden = ['deleted_at']; |
|
13 | - protected $guarded = ['id']; |
|
14 | - protected $fillable = ['name', 'model']; |
|
15 | - public $searchable = ['name', 'model']; |
|
9 | + use SoftDeletes; |
|
10 | + protected $table = 'permissions'; |
|
11 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
12 | + protected $hidden = ['deleted_at']; |
|
13 | + protected $guarded = ['id']; |
|
14 | + protected $fillable = ['name', 'model']; |
|
15 | + public $searchable = ['name', 'model']; |
|
16 | 16 | |
17 | - public function getCreatedAtAttribute($value) |
|
18 | - { |
|
19 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
20 | - } |
|
17 | + public function getCreatedAtAttribute($value) |
|
18 | + { |
|
19 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
20 | + } |
|
21 | 21 | |
22 | - public function getUpdatedAtAttribute($value) |
|
23 | - { |
|
24 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
25 | - } |
|
22 | + public function getUpdatedAtAttribute($value) |
|
23 | + { |
|
24 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
25 | + } |
|
26 | 26 | |
27 | - public function getDeletedAtAttribute($value) |
|
28 | - { |
|
29 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
30 | - } |
|
27 | + public function getDeletedAtAttribute($value) |
|
28 | + { |
|
29 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
30 | + } |
|
31 | 31 | |
32 | - public function groups() |
|
33 | - { |
|
34 | - return $this->belongsToMany('App\Modules\Groups\AclGroup', 'groups_permissions', 'permission_id', 'group_id')->whereNull('groups_permissions.deleted_at')->withTimestamps(); |
|
35 | - } |
|
32 | + public function groups() |
|
33 | + { |
|
34 | + return $this->belongsToMany('App\Modules\Groups\AclGroup', 'groups_permissions', 'permission_id', 'group_id')->whereNull('groups_permissions.deleted_at')->withTimestamps(); |
|
35 | + } |
|
36 | 36 | |
37 | - public static function boot() |
|
38 | - { |
|
39 | - parent::boot(); |
|
40 | - AclPermission::observe(\App::make('App\Modules\Permissions\ModelObservers\AclPermissionObserver')); |
|
41 | - } |
|
37 | + public static function boot() |
|
38 | + { |
|
39 | + parent::boot(); |
|
40 | + AclPermission::observe(\App::make('App\Modules\Permissions\ModelObservers\AclPermissionObserver')); |
|
41 | + } |
|
42 | 42 | } |
@@ -15,6 +15,6 @@ |
||
15 | 15 | |
16 | 16 | Route::group(['prefix' => 'permissions'], function () { |
17 | 17 | |
18 | - Route::get('/', 'PermissionController@index'); |
|
19 | - Route::get('/{id}', 'PermissionController@find'); |
|
18 | + Route::get('/', 'PermissionController@index'); |
|
19 | + Route::get('/{id}', 'PermissionController@find'); |
|
20 | 20 | }); |
21 | 21 | \ No newline at end of file |
@@ -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', 'permissions'); |
|
17 | - $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'permissions'); |
|
9 | + /** |
|
10 | + * Bootstrap the module services. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function boot() |
|
15 | + { |
|
16 | + $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'permissions'); |
|
17 | + $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'permissions'); |
|
18 | 18 | |
19 | - $this->loadMigrationsFrom(module_path('permissions', 'Database/Migrations', 'app')); |
|
20 | - $this->loadFactoriesFrom(module_path('permissions', 'Database/Factories', 'app')); |
|
21 | - } |
|
19 | + $this->loadMigrationsFrom(module_path('permissions', 'Database/Migrations', 'app')); |
|
20 | + $this->loadFactoriesFrom(module_path('permissions', '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 | } |
@@ -7,73 +7,73 @@ |
||
7 | 7 | |
8 | 8 | class RouteServiceProvider extends ServiceProvider |
9 | 9 | { |
10 | - /** |
|
11 | - * This namespace is applied to your controller routes. |
|
12 | - * |
|
13 | - * In addition, it is set as the URL generator's root namespace. |
|
14 | - * |
|
15 | - * @var string |
|
16 | - */ |
|
17 | - protected $namespace = 'App\Modules\Permissions\Http\Controllers'; |
|
10 | + /** |
|
11 | + * This namespace is applied to your controller routes. |
|
12 | + * |
|
13 | + * In addition, it is set as the URL generator's root namespace. |
|
14 | + * |
|
15 | + * @var string |
|
16 | + */ |
|
17 | + protected $namespace = 'App\Modules\Permissions\Http\Controllers'; |
|
18 | 18 | |
19 | - /** |
|
20 | - * Define your route model bindings, pattern filters, etc. |
|
21 | - * |
|
22 | - * @return void |
|
23 | - */ |
|
24 | - public function boot() |
|
25 | - { |
|
26 | - // |
|
19 | + /** |
|
20 | + * Define your route model bindings, pattern filters, etc. |
|
21 | + * |
|
22 | + * @return void |
|
23 | + */ |
|
24 | + public function boot() |
|
25 | + { |
|
26 | + // |
|
27 | 27 | |
28 | - parent::boot(); |
|
29 | - } |
|
28 | + parent::boot(); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * Define the routes for the module. |
|
33 | - * |
|
34 | - * @return void |
|
35 | - */ |
|
36 | - public function map() |
|
37 | - { |
|
38 | - $this->mapWebRoutes(); |
|
31 | + /** |
|
32 | + * Define the routes for the module. |
|
33 | + * |
|
34 | + * @return void |
|
35 | + */ |
|
36 | + public function map() |
|
37 | + { |
|
38 | + $this->mapWebRoutes(); |
|
39 | 39 | |
40 | - $this->mapApiRoutes(); |
|
40 | + $this->mapApiRoutes(); |
|
41 | 41 | |
42 | - // |
|
43 | - } |
|
42 | + // |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Define the "web" routes for the module. |
|
47 | - * |
|
48 | - * These routes all receive session state, CSRF protection, etc. |
|
49 | - * |
|
50 | - * @return void |
|
51 | - */ |
|
52 | - protected function mapWebRoutes() |
|
53 | - { |
|
54 | - Route::group([ |
|
55 | - 'middleware' => 'web', |
|
56 | - 'namespace' => $this->namespace, |
|
57 | - ], function ($router) { |
|
58 | - require module_path('permissions', 'Routes/web.php', 'app'); |
|
59 | - }); |
|
60 | - } |
|
45 | + /** |
|
46 | + * Define the "web" routes for the module. |
|
47 | + * |
|
48 | + * These routes all receive session state, CSRF protection, etc. |
|
49 | + * |
|
50 | + * @return void |
|
51 | + */ |
|
52 | + protected function mapWebRoutes() |
|
53 | + { |
|
54 | + Route::group([ |
|
55 | + 'middleware' => 'web', |
|
56 | + 'namespace' => $this->namespace, |
|
57 | + ], function ($router) { |
|
58 | + require module_path('permissions', 'Routes/web.php', 'app'); |
|
59 | + }); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * Define the "api" routes for the module. |
|
64 | - * |
|
65 | - * These routes are typically stateless. |
|
66 | - * |
|
67 | - * @return void |
|
68 | - */ |
|
69 | - protected function mapApiRoutes() |
|
70 | - { |
|
71 | - Route::group([ |
|
72 | - 'middleware' => 'api', |
|
73 | - 'namespace' => $this->namespace, |
|
74 | - 'prefix' => 'api', |
|
75 | - ], function ($router) { |
|
76 | - require module_path('permissions', 'Routes/api.php', 'app'); |
|
77 | - }); |
|
78 | - } |
|
62 | + /** |
|
63 | + * Define the "api" routes for the module. |
|
64 | + * |
|
65 | + * These routes are typically stateless. |
|
66 | + * |
|
67 | + * @return void |
|
68 | + */ |
|
69 | + protected function mapApiRoutes() |
|
70 | + { |
|
71 | + Route::group([ |
|
72 | + 'middleware' => 'api', |
|
73 | + 'namespace' => $this->namespace, |
|
74 | + 'prefix' => 'api', |
|
75 | + ], function ($router) { |
|
76 | + require module_path('permissions', 'Routes/api.php', 'app'); |
|
77 | + }); |
|
78 | + } |
|
79 | 79 | } |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $factory->define(App\Modules\Permissions\AclPermission::class, function (Faker\Generator $faker) { |
4 | - return [ |
|
5 | - 'name' => $faker->randomElement(['save', 'delete', 'find', 'paginate']), |
|
6 | - 'model' => $faker->randomElement(['users', 'groups', 'settings', 'notifications']), |
|
7 | - 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
|
8 | - 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
|
9 | - ]; |
|
4 | + return [ |
|
5 | + 'name' => $faker->randomElement(['save', 'delete', 'find', 'paginate']), |
|
6 | + 'model' => $faker->randomElement(['users', 'groups', 'settings', 'notifications']), |
|
7 | + 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
|
8 | + 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
|
9 | + ]; |
|
10 | 10 | }); |