| @@ 10-48 (lines=39) @@ | ||
| 7 | use \App\Modules\Acl\Repositories\GroupRepository; |
|
| 8 | use App\Modules\Core\Utl\CoreConfig; |
|
| 9 | ||
| 10 | class GroupsController extends BaseApiController |
|
| 11 | { |
|
| 12 | /** |
|
| 13 | * The validations rules used by the base api controller |
|
| 14 | * to check before add. |
|
| 15 | * @var array |
|
| 16 | */ |
|
| 17 | protected $validationRules = [ |
|
| 18 | 'name' => 'required|string|max:100|unique:groups,name,{id}' |
|
| 19 | ]; |
|
| 20 | ||
| 21 | /** |
|
| 22 | * Init new object. |
|
| 23 | * |
|
| 24 | * @param GroupRepository $repo |
|
| 25 | * @param CoreConfig $config |
|
| 26 | * @return void |
|
| 27 | */ |
|
| 28 | public function __construct(GroupRepository $repo, CoreConfig $config) |
|
| 29 | { |
|
| 30 | parent::__construct($repo, $config, 'App\Modules\Acl\Http\Resources\AclGroup'); |
|
| 31 | } |
|
| 32 | ||
| 33 | /** |
|
| 34 | * Handle an assign permissions to group request. |
|
| 35 | * |
|
| 36 | * @param \Illuminate\Http\Request $request |
|
| 37 | * @return \Illuminate\Http\Response |
|
| 38 | */ |
|
| 39 | public function assignpermissions(Request $request) |
|
| 40 | { |
|
| 41 | $this->validate($request, [ |
|
| 42 | 'permission_ids' => 'required|exists:permissions,id', |
|
| 43 | 'group_id' => 'required|array|exists:groups,id' |
|
| 44 | ]); |
|
| 45 | ||
| 46 | return new $this->modelResource($this->repo->assignPermissions($request->get('group_id'), $request->get('permission_ids'))); |
|
| 47 | } |
|
| 48 | } |
|
| 49 | ||
| @@ 10-55 (lines=46) @@ | ||
| 7 | use \App\Modules\Notifications\Repositories\PushNotificationDeviceRepository; |
|
| 8 | use App\Modules\Core\Utl\CoreConfig; |
|
| 9 | ||
| 10 | class PushNotificationDevicesController extends BaseApiController |
|
| 11 | { |
|
| 12 | /** |
|
| 13 | * List of all route actions that the base api controller |
|
| 14 | * will skip permissions check for them. |
|
| 15 | * @var array |
|
| 16 | */ |
|
| 17 | protected $skipPermissionCheck = ['registerDevice']; |
|
| 18 | ||
| 19 | /** |
|
| 20 | * The validations rules used by the base api controller |
|
| 21 | * to check before add. |
|
| 22 | * @var array |
|
| 23 | */ |
|
| 24 | protected $validationRules = [ |
|
| 25 | 'device_token' => 'required|string|max:255', |
|
| 26 | 'user_id' => 'required|exists:users,id' |
|
| 27 | ]; |
|
| 28 | ||
| 29 | /** |
|
| 30 | * Init new object. |
|
| 31 | * |
|
| 32 | * @param PushNotificationDeviceRepository $repo |
|
| 33 | * @param CoreConfig $config |
|
| 34 | * @return void |
|
| 35 | */ |
|
| 36 | public function __construct(PushNotificationDeviceRepository $repo, CoreConfig $config) |
|
| 37 | { |
|
| 38 | parent::__construct($repo, $config, 'App\Modules\Notifications\Http\Resources\PushNotificationDevice'); |
|
| 39 | } |
|
| 40 | ||
| 41 | /** |
|
| 42 | * Register the given device to the logged in user. |
|
| 43 | * |
|
| 44 | * @param \Illuminate\Http\Request $request |
|
| 45 | * @return \Illuminate\Http\Response |
|
| 46 | */ |
|
| 47 | public function registerDevice(Request $request) |
|
| 48 | { |
|
| 49 | $this->validate($request, [ |
|
| 50 | 'device_token' => 'required|string|max:255' |
|
| 51 | ]); |
|
| 52 | ||
| 53 | return new $this->modelResource($this->repo->registerDevice($request->all())); |
|
| 54 | } |
|
| 55 | } |
|
| 56 | ||