@@ -2,25 +2,25 @@ |
||
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | 4 | |
| 5 | - /** |
|
| 6 | - * List of error messages used in core module. |
|
| 7 | - */ |
|
| 8 | - 'unAuthorized' => 'Please login before any action', |
|
| 9 | - 'tokenExpired' => 'Login token expired', |
|
| 10 | - 'noPermissions' => 'No permissions', |
|
| 11 | - 'loginFailed' => 'Wrong mail or password', |
|
| 12 | - 'noSocialEmail' => 'Couldn\'t retrieve email', |
|
| 13 | - 'userAlreadyRegistered' => 'User already registered. Please login using email and password', |
|
| 14 | - 'connectionError' => 'Connection error', |
|
| 15 | - 'redisNotRunning' => 'Your redis notification server is\'t running', |
|
| 16 | - 'dbQueryError' => 'Please check the given inputes', |
|
| 17 | - 'cannotCreateSetting' => 'Can\'t create setting', |
|
| 18 | - 'cannotUpdateSettingKey' => 'Can\'t update setting key', |
|
| 19 | - 'userIsBlocked' => 'You have been blocked', |
|
| 20 | - 'invalidResetToken' => 'Reset password token is invalid', |
|
| 21 | - 'invalidResetPassword' => 'Reset password is invalid', |
|
| 22 | - 'invalidOldPassword' => 'Old password is invalid', |
|
| 23 | - 'notFound' => 'The requested :replace not found', |
|
| 24 | - 'generalError' => 'Something went wrong', |
|
| 5 | + /** |
|
| 6 | + * List of error messages used in core module. |
|
| 7 | + */ |
|
| 8 | + 'unAuthorized' => 'Please login before any action', |
|
| 9 | + 'tokenExpired' => 'Login token expired', |
|
| 10 | + 'noPermissions' => 'No permissions', |
|
| 11 | + 'loginFailed' => 'Wrong mail or password', |
|
| 12 | + 'noSocialEmail' => 'Couldn\'t retrieve email', |
|
| 13 | + 'userAlreadyRegistered' => 'User already registered. Please login using email and password', |
|
| 14 | + 'connectionError' => 'Connection error', |
|
| 15 | + 'redisNotRunning' => 'Your redis notification server is\'t running', |
|
| 16 | + 'dbQueryError' => 'Please check the given inputes', |
|
| 17 | + 'cannotCreateSetting' => 'Can\'t create setting', |
|
| 18 | + 'cannotUpdateSettingKey' => 'Can\'t update setting key', |
|
| 19 | + 'userIsBlocked' => 'You have been blocked', |
|
| 20 | + 'invalidResetToken' => 'Reset password token is invalid', |
|
| 21 | + 'invalidResetPassword' => 'Reset password is invalid', |
|
| 22 | + 'invalidOldPassword' => 'Old password is invalid', |
|
| 23 | + 'notFound' => 'The requested :replace not found', |
|
| 24 | + 'generalError' => 'Something went wrong', |
|
| 25 | 25 | |
| 26 | 26 | ]; |
| 27 | 27 | \ No newline at end of file |
@@ -13,16 +13,16 @@ |
||
| 13 | 13 | public function up() |
| 14 | 14 | { |
| 15 | 15 | Schema::create('users', function (Blueprint $table) { |
| 16 | - $table->increments('id'); |
|
| 17 | - $table->string('name', 100)->nullable(); |
|
| 18 | - $table->string('email')->unique(); |
|
| 19 | - $table->string('password', 60)->nullable(); |
|
| 20 | - $table->boolean('blocked')->default(0); |
|
| 16 | + $table->increments('id'); |
|
| 17 | + $table->string('name', 100)->nullable(); |
|
| 18 | + $table->string('email')->unique(); |
|
| 19 | + $table->string('password', 60)->nullable(); |
|
| 20 | + $table->boolean('blocked')->default(0); |
|
| 21 | 21 | $table->date('last_change_password')->nullable(); |
| 22 | - $table->softDeletes(); |
|
| 23 | - $table->rememberToken(); |
|
| 24 | - $table->timestamps(); |
|
| 25 | - }); |
|
| 22 | + $table->softDeletes(); |
|
| 23 | + $table->rememberToken(); |
|
| 24 | + $table->timestamps(); |
|
| 25 | + }); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | public function up() |
| 14 | 14 | { |
| 15 | - Schema::create('users', function (Blueprint $table) { |
|
| 15 | + Schema::create('users', function(Blueprint $table) { |
|
| 16 | 16 | $table->increments('id'); |
| 17 | 17 | $table->string('name', 100)->nullable(); |
| 18 | 18 | $table->string('email')->unique(); |
@@ -2,105 +2,105 @@ |
||
| 2 | 2 | |
| 3 | 3 | class ErrorHandler |
| 4 | 4 | { |
| 5 | - public function unAuthorized() |
|
| 6 | - { |
|
| 7 | - $error = ['status' => 401, 'message' => trans('errors.unAuthorized')]; |
|
| 8 | - abort($error['status'], $error['message']); |
|
| 9 | - } |
|
| 10 | - |
|
| 11 | - public function tokenExpired() |
|
| 12 | - { |
|
| 13 | - $error = ['status' => 403, 'message' => trans('errors.tokenExpired')]; |
|
| 14 | - abort($error['status'], $error['message']); |
|
| 15 | - } |
|
| 16 | - |
|
| 17 | - public function noPermissions() |
|
| 18 | - { |
|
| 19 | - $error = ['status' => 403, 'message' => trans('errors.noPermissions')]; |
|
| 20 | - abort($error['status'], $error['message']); |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - public function loginFailed() |
|
| 24 | - { |
|
| 25 | - $error = ['status' => 400, 'message' => trans('errors.loginFailed')]; |
|
| 26 | - abort($error['status'], $error['message']); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - public function noSocialEmail() |
|
| 30 | - { |
|
| 31 | - $error = ['status' => 400, 'message' => trans('errors.noSocialEmail')]; |
|
| 32 | - abort($error['status'], $error['message']); |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - public function userAlreadyRegistered() |
|
| 36 | - { |
|
| 37 | - $error = ['status' => 400, 'message' => trans('errors.userAlreadyRegistered')]; |
|
| 38 | - abort($error['status'], $error['message']); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - public function connectionError() |
|
| 42 | - { |
|
| 43 | - $error = ['status' => 400, 'message' => trans('errors.connectionError')]; |
|
| 44 | - abort($error['status'], $error['message']); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - public function redisNotRunning() |
|
| 48 | - { |
|
| 49 | - $error = ['status' => 400, 'message' => trans('errors.redisNotRunning')]; |
|
| 50 | - abort($error['status'], $error['message']); |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - public function dbQueryError() |
|
| 54 | - { |
|
| 55 | - $error = ['status' => 400, 'message' => trans('errors.dbQueryError')]; |
|
| 56 | - abort($error['status'], $error['message']); |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - public function cannotCreateSetting() |
|
| 60 | - { |
|
| 61 | - $error = ['status' => 400, 'message' => trans('errors.cannotCreateSetting')]; |
|
| 62 | - abort($error['status'], $error['message']); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - public function cannotUpdateSettingKey() |
|
| 66 | - { |
|
| 67 | - $error = ['status' => 400, 'message' => trans('errors.cannotUpdateSettingKey')]; |
|
| 68 | - abort($error['status'], $error['message']); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - public function userIsBlocked() |
|
| 72 | - { |
|
| 73 | - $error = ['status' => 403, 'message' => trans('errors.userIsBlocked')]; |
|
| 74 | - abort($error['status'], $error['message']); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - public function invalidResetToken() |
|
| 78 | - { |
|
| 79 | - $error = ['status' => 400, 'message' => trans('errors.invalidResetToken')]; |
|
| 80 | - abort($error['status'], $error['message']); |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - public function invalidResetPassword() |
|
| 84 | - { |
|
| 85 | - $error = ['status' => 400, 'message' => trans('errors.invalidResetPassword')]; |
|
| 86 | - abort($error['status'], $error['message']); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - public function invalidOldPassword() |
|
| 90 | - { |
|
| 91 | - $error = ['status' => 400, 'message' => trans('errors.invalidOldPassword')]; |
|
| 92 | - abort($error['status'], $error['message']); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - public function notFound($text) |
|
| 96 | - { |
|
| 97 | - $error = ['status' => 404, 'message' => trans('errors.notFound', ['replace' => $text])]; |
|
| 98 | - abort($error['status'], $error['message']); |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - public function generalError() |
|
| 102 | - { |
|
| 103 | - $error = ['status' => 404, 'message' => trans('errors.generalError')]; |
|
| 104 | - abort($error['status'], $error['message']); |
|
| 105 | - } |
|
| 5 | + public function unAuthorized() |
|
| 6 | + { |
|
| 7 | + $error = ['status' => 401, 'message' => trans('errors.unAuthorized')]; |
|
| 8 | + abort($error['status'], $error['message']); |
|
| 9 | + } |
|
| 10 | + |
|
| 11 | + public function tokenExpired() |
|
| 12 | + { |
|
| 13 | + $error = ['status' => 403, 'message' => trans('errors.tokenExpired')]; |
|
| 14 | + abort($error['status'], $error['message']); |
|
| 15 | + } |
|
| 16 | + |
|
| 17 | + public function noPermissions() |
|
| 18 | + { |
|
| 19 | + $error = ['status' => 403, 'message' => trans('errors.noPermissions')]; |
|
| 20 | + abort($error['status'], $error['message']); |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + public function loginFailed() |
|
| 24 | + { |
|
| 25 | + $error = ['status' => 400, 'message' => trans('errors.loginFailed')]; |
|
| 26 | + abort($error['status'], $error['message']); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + public function noSocialEmail() |
|
| 30 | + { |
|
| 31 | + $error = ['status' => 400, 'message' => trans('errors.noSocialEmail')]; |
|
| 32 | + abort($error['status'], $error['message']); |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + public function userAlreadyRegistered() |
|
| 36 | + { |
|
| 37 | + $error = ['status' => 400, 'message' => trans('errors.userAlreadyRegistered')]; |
|
| 38 | + abort($error['status'], $error['message']); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + public function connectionError() |
|
| 42 | + { |
|
| 43 | + $error = ['status' => 400, 'message' => trans('errors.connectionError')]; |
|
| 44 | + abort($error['status'], $error['message']); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + public function redisNotRunning() |
|
| 48 | + { |
|
| 49 | + $error = ['status' => 400, 'message' => trans('errors.redisNotRunning')]; |
|
| 50 | + abort($error['status'], $error['message']); |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + public function dbQueryError() |
|
| 54 | + { |
|
| 55 | + $error = ['status' => 400, 'message' => trans('errors.dbQueryError')]; |
|
| 56 | + abort($error['status'], $error['message']); |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + public function cannotCreateSetting() |
|
| 60 | + { |
|
| 61 | + $error = ['status' => 400, 'message' => trans('errors.cannotCreateSetting')]; |
|
| 62 | + abort($error['status'], $error['message']); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + public function cannotUpdateSettingKey() |
|
| 66 | + { |
|
| 67 | + $error = ['status' => 400, 'message' => trans('errors.cannotUpdateSettingKey')]; |
|
| 68 | + abort($error['status'], $error['message']); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + public function userIsBlocked() |
|
| 72 | + { |
|
| 73 | + $error = ['status' => 403, 'message' => trans('errors.userIsBlocked')]; |
|
| 74 | + abort($error['status'], $error['message']); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + public function invalidResetToken() |
|
| 78 | + { |
|
| 79 | + $error = ['status' => 400, 'message' => trans('errors.invalidResetToken')]; |
|
| 80 | + abort($error['status'], $error['message']); |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + public function invalidResetPassword() |
|
| 84 | + { |
|
| 85 | + $error = ['status' => 400, 'message' => trans('errors.invalidResetPassword')]; |
|
| 86 | + abort($error['status'], $error['message']); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + public function invalidOldPassword() |
|
| 90 | + { |
|
| 91 | + $error = ['status' => 400, 'message' => trans('errors.invalidOldPassword')]; |
|
| 92 | + abort($error['status'], $error['message']); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + public function notFound($text) |
|
| 96 | + { |
|
| 97 | + $error = ['status' => 404, 'message' => trans('errors.notFound', ['replace' => $text])]; |
|
| 98 | + abort($error['status'], $error['message']); |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + public function generalError() |
|
| 102 | + { |
|
| 103 | + $error = ['status' => 404, 'message' => trans('errors.generalError')]; |
|
| 104 | + abort($error['status'], $error['message']); |
|
| 105 | + } |
|
| 106 | 106 | } |
| 107 | 107 | \ No newline at end of file |
@@ -13,140 +13,140 @@ |
||
| 13 | 13 | public function up() |
| 14 | 14 | { |
| 15 | 15 | /** |
| 16 | - * Insert the permissions related to this module. |
|
| 17 | - */ |
|
| 18 | - DB::table('permissions')->insert( |
|
| 19 | - [ |
|
| 20 | - /** |
|
| 21 | - * notifications model permissions. |
|
| 22 | - */ |
|
| 23 | - [ |
|
| 24 | - 'name' => 'find', |
|
| 25 | - 'model' => 'notifications', |
|
| 26 | - 'created_at' => \DB::raw('NOW()'), |
|
| 27 | - 'updated_at' => \DB::raw('NOW()') |
|
| 28 | - ], |
|
| 29 | - [ |
|
| 30 | - 'name' => 'search', |
|
| 31 | - 'model' => 'notifications', |
|
| 32 | - 'created_at' => \DB::raw('NOW()'), |
|
| 33 | - 'updated_at' => \DB::raw('NOW()') |
|
| 34 | - ], |
|
| 35 | - [ |
|
| 36 | - 'name' => 'list', |
|
| 37 | - 'model' => 'notifications', |
|
| 38 | - 'created_at' => \DB::raw('NOW()'), |
|
| 39 | - 'updated_at' => \DB::raw('NOW()') |
|
| 40 | - ], |
|
| 41 | - [ |
|
| 42 | - 'name' => 'findby', |
|
| 43 | - 'model' => 'notifications', |
|
| 44 | - 'created_at' => \DB::raw('NOW()'), |
|
| 45 | - 'updated_at' => \DB::raw('NOW()') |
|
| 46 | - ], |
|
| 47 | - [ |
|
| 48 | - 'name' => 'first', |
|
| 49 | - 'model' => 'notifications', |
|
| 50 | - 'created_at' => \DB::raw('NOW()'), |
|
| 51 | - 'updated_at' => \DB::raw('NOW()') |
|
| 52 | - ], |
|
| 53 | - [ |
|
| 54 | - 'name' => 'paginate', |
|
| 55 | - 'model' => 'notifications', |
|
| 56 | - 'created_at' => \DB::raw('NOW()'), |
|
| 57 | - 'updated_at' => \DB::raw('NOW()') |
|
| 58 | - ], |
|
| 59 | - [ |
|
| 60 | - 'name' => 'paginateby', |
|
| 61 | - 'model' => 'notifications', |
|
| 62 | - 'created_at' => \DB::raw('NOW()'), |
|
| 63 | - 'updated_at' => \DB::raw('NOW()') |
|
| 64 | - ], |
|
| 65 | - [ |
|
| 66 | - 'name' => 'notified', |
|
| 67 | - 'model' => 'notifications', |
|
| 68 | - 'created_at' => \DB::raw('NOW()'), |
|
| 69 | - 'updated_at' => \DB::raw('NOW()') |
|
| 70 | - ], |
|
| 71 | - [ |
|
| 72 | - 'name' => 'notifyall', |
|
| 73 | - 'model' => 'notifications', |
|
| 74 | - 'created_at' => \DB::raw('NOW()'), |
|
| 75 | - 'updated_at' => \DB::raw('NOW()') |
|
| 76 | - ], |
|
| 77 | - /** |
|
| 78 | - * pushNotificationDevices model permissions. |
|
| 79 | - */ |
|
| 80 | - [ |
|
| 81 | - 'name' => 'find', |
|
| 82 | - 'model' => 'pushNotificationDevices', |
|
| 83 | - 'created_at' => \DB::raw('NOW()'), |
|
| 84 | - 'updated_at' => \DB::raw('NOW()') |
|
| 85 | - ], |
|
| 86 | - [ |
|
| 87 | - 'name' => 'search', |
|
| 88 | - 'model' => 'pushNotificationDevices', |
|
| 89 | - 'created_at' => \DB::raw('NOW()'), |
|
| 90 | - 'updated_at' => \DB::raw('NOW()') |
|
| 91 | - ], |
|
| 92 | - [ |
|
| 93 | - 'name' => 'list', |
|
| 94 | - 'model' => 'pushNotificationDevices', |
|
| 95 | - 'created_at' => \DB::raw('NOW()'), |
|
| 96 | - 'updated_at' => \DB::raw('NOW()') |
|
| 97 | - ], |
|
| 98 | - [ |
|
| 99 | - 'name' => 'findby', |
|
| 100 | - 'model' => 'pushNotificationDevices', |
|
| 101 | - 'created_at' => \DB::raw('NOW()'), |
|
| 102 | - 'updated_at' => \DB::raw('NOW()') |
|
| 103 | - ], |
|
| 104 | - [ |
|
| 105 | - 'name' => 'first', |
|
| 106 | - 'model' => 'pushNotificationDevices', |
|
| 107 | - 'created_at' => \DB::raw('NOW()'), |
|
| 108 | - 'updated_at' => \DB::raw('NOW()') |
|
| 109 | - ], |
|
| 110 | - [ |
|
| 111 | - 'name' => 'paginate', |
|
| 112 | - 'model' => 'pushNotificationDevices', |
|
| 113 | - 'created_at' => \DB::raw('NOW()'), |
|
| 114 | - 'updated_at' => \DB::raw('NOW()') |
|
| 115 | - ], |
|
| 116 | - [ |
|
| 117 | - 'name' => 'paginateby', |
|
| 118 | - 'model' => 'pushNotificationDevices', |
|
| 119 | - 'created_at' => \DB::raw('NOW()'), |
|
| 120 | - 'updated_at' => \DB::raw('NOW()') |
|
| 121 | - ], |
|
| 122 | - [ |
|
| 123 | - 'name' => 'save', |
|
| 124 | - 'model' => 'pushNotificationDevices', |
|
| 125 | - 'created_at' => \DB::raw('NOW()'), |
|
| 126 | - 'updated_at' => \DB::raw('NOW()') |
|
| 127 | - ], |
|
| 128 | - [ |
|
| 129 | - 'name' => 'delete', |
|
| 130 | - 'model' => 'pushNotificationDevices', |
|
| 131 | - 'created_at' => \DB::raw('NOW()'), |
|
| 132 | - 'updated_at' => \DB::raw('NOW()') |
|
| 133 | - ], |
|
| 134 | - [ |
|
| 135 | - 'name' => 'deleted', |
|
| 136 | - 'model' => 'pushNotificationDevices', |
|
| 137 | - 'created_at' => \DB::raw('NOW()'), |
|
| 138 | - 'updated_at' => \DB::raw('NOW()') |
|
| 139 | - ], |
|
| 140 | - [ |
|
| 141 | - 'name' => 'restore', |
|
| 142 | - 'model' => 'pushNotificationDevices', |
|
| 143 | - 'created_at' => \DB::raw('NOW()'), |
|
| 144 | - 'updated_at' => \DB::raw('NOW()') |
|
| 145 | - ], |
|
| 146 | - ] |
|
| 147 | - ); |
|
| 16 | + * Insert the permissions related to this module. |
|
| 17 | + */ |
|
| 18 | + DB::table('permissions')->insert( |
|
| 19 | + [ |
|
| 20 | + /** |
|
| 21 | + * notifications model permissions. |
|
| 22 | + */ |
|
| 23 | + [ |
|
| 24 | + 'name' => 'find', |
|
| 25 | + 'model' => 'notifications', |
|
| 26 | + 'created_at' => \DB::raw('NOW()'), |
|
| 27 | + 'updated_at' => \DB::raw('NOW()') |
|
| 28 | + ], |
|
| 29 | + [ |
|
| 30 | + 'name' => 'search', |
|
| 31 | + 'model' => 'notifications', |
|
| 32 | + 'created_at' => \DB::raw('NOW()'), |
|
| 33 | + 'updated_at' => \DB::raw('NOW()') |
|
| 34 | + ], |
|
| 35 | + [ |
|
| 36 | + 'name' => 'list', |
|
| 37 | + 'model' => 'notifications', |
|
| 38 | + 'created_at' => \DB::raw('NOW()'), |
|
| 39 | + 'updated_at' => \DB::raw('NOW()') |
|
| 40 | + ], |
|
| 41 | + [ |
|
| 42 | + 'name' => 'findby', |
|
| 43 | + 'model' => 'notifications', |
|
| 44 | + 'created_at' => \DB::raw('NOW()'), |
|
| 45 | + 'updated_at' => \DB::raw('NOW()') |
|
| 46 | + ], |
|
| 47 | + [ |
|
| 48 | + 'name' => 'first', |
|
| 49 | + 'model' => 'notifications', |
|
| 50 | + 'created_at' => \DB::raw('NOW()'), |
|
| 51 | + 'updated_at' => \DB::raw('NOW()') |
|
| 52 | + ], |
|
| 53 | + [ |
|
| 54 | + 'name' => 'paginate', |
|
| 55 | + 'model' => 'notifications', |
|
| 56 | + 'created_at' => \DB::raw('NOW()'), |
|
| 57 | + 'updated_at' => \DB::raw('NOW()') |
|
| 58 | + ], |
|
| 59 | + [ |
|
| 60 | + 'name' => 'paginateby', |
|
| 61 | + 'model' => 'notifications', |
|
| 62 | + 'created_at' => \DB::raw('NOW()'), |
|
| 63 | + 'updated_at' => \DB::raw('NOW()') |
|
| 64 | + ], |
|
| 65 | + [ |
|
| 66 | + 'name' => 'notified', |
|
| 67 | + 'model' => 'notifications', |
|
| 68 | + 'created_at' => \DB::raw('NOW()'), |
|
| 69 | + 'updated_at' => \DB::raw('NOW()') |
|
| 70 | + ], |
|
| 71 | + [ |
|
| 72 | + 'name' => 'notifyall', |
|
| 73 | + 'model' => 'notifications', |
|
| 74 | + 'created_at' => \DB::raw('NOW()'), |
|
| 75 | + 'updated_at' => \DB::raw('NOW()') |
|
| 76 | + ], |
|
| 77 | + /** |
|
| 78 | + * pushNotificationDevices model permissions. |
|
| 79 | + */ |
|
| 80 | + [ |
|
| 81 | + 'name' => 'find', |
|
| 82 | + 'model' => 'pushNotificationDevices', |
|
| 83 | + 'created_at' => \DB::raw('NOW()'), |
|
| 84 | + 'updated_at' => \DB::raw('NOW()') |
|
| 85 | + ], |
|
| 86 | + [ |
|
| 87 | + 'name' => 'search', |
|
| 88 | + 'model' => 'pushNotificationDevices', |
|
| 89 | + 'created_at' => \DB::raw('NOW()'), |
|
| 90 | + 'updated_at' => \DB::raw('NOW()') |
|
| 91 | + ], |
|
| 92 | + [ |
|
| 93 | + 'name' => 'list', |
|
| 94 | + 'model' => 'pushNotificationDevices', |
|
| 95 | + 'created_at' => \DB::raw('NOW()'), |
|
| 96 | + 'updated_at' => \DB::raw('NOW()') |
|
| 97 | + ], |
|
| 98 | + [ |
|
| 99 | + 'name' => 'findby', |
|
| 100 | + 'model' => 'pushNotificationDevices', |
|
| 101 | + 'created_at' => \DB::raw('NOW()'), |
|
| 102 | + 'updated_at' => \DB::raw('NOW()') |
|
| 103 | + ], |
|
| 104 | + [ |
|
| 105 | + 'name' => 'first', |
|
| 106 | + 'model' => 'pushNotificationDevices', |
|
| 107 | + 'created_at' => \DB::raw('NOW()'), |
|
| 108 | + 'updated_at' => \DB::raw('NOW()') |
|
| 109 | + ], |
|
| 110 | + [ |
|
| 111 | + 'name' => 'paginate', |
|
| 112 | + 'model' => 'pushNotificationDevices', |
|
| 113 | + 'created_at' => \DB::raw('NOW()'), |
|
| 114 | + 'updated_at' => \DB::raw('NOW()') |
|
| 115 | + ], |
|
| 116 | + [ |
|
| 117 | + 'name' => 'paginateby', |
|
| 118 | + 'model' => 'pushNotificationDevices', |
|
| 119 | + 'created_at' => \DB::raw('NOW()'), |
|
| 120 | + 'updated_at' => \DB::raw('NOW()') |
|
| 121 | + ], |
|
| 122 | + [ |
|
| 123 | + 'name' => 'save', |
|
| 124 | + 'model' => 'pushNotificationDevices', |
|
| 125 | + 'created_at' => \DB::raw('NOW()'), |
|
| 126 | + 'updated_at' => \DB::raw('NOW()') |
|
| 127 | + ], |
|
| 128 | + [ |
|
| 129 | + 'name' => 'delete', |
|
| 130 | + 'model' => 'pushNotificationDevices', |
|
| 131 | + 'created_at' => \DB::raw('NOW()'), |
|
| 132 | + 'updated_at' => \DB::raw('NOW()') |
|
| 133 | + ], |
|
| 134 | + [ |
|
| 135 | + 'name' => 'deleted', |
|
| 136 | + 'model' => 'pushNotificationDevices', |
|
| 137 | + 'created_at' => \DB::raw('NOW()'), |
|
| 138 | + 'updated_at' => \DB::raw('NOW()') |
|
| 139 | + ], |
|
| 140 | + [ |
|
| 141 | + 'name' => 'restore', |
|
| 142 | + 'model' => 'pushNotificationDevices', |
|
| 143 | + 'created_at' => \DB::raw('NOW()'), |
|
| 144 | + 'updated_at' => \DB::raw('NOW()') |
|
| 145 | + ], |
|
| 146 | + ] |
|
| 147 | + ); |
|
| 148 | 148 | |
| 149 | - /** |
|
| 149 | + /** |
|
| 150 | 150 | * Assign the permissions to the admin group. |
| 151 | 151 | */ |
| 152 | 152 | $permissionIds = DB::table('permissions')->whereIn('model', ['notifications', 'pushNotificationDevices'])->select('id')->pluck('id'); |
@@ -171,7 +171,7 @@ |
||
| 171 | 171 | */ |
| 172 | 172 | public function down() |
| 173 | 173 | { |
| 174 | - $permissions = DB::table('permissions')->whereIn('model', ['notifications', 'pushNotificationDevices']); |
|
| 174 | + $permissions = DB::table('permissions')->whereIn('model', ['notifications', 'pushNotificationDevices']); |
|
| 175 | 175 | DB::table('groups_permissions')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
| 176 | 176 | $permissions->delete(); |
| 177 | 177 | } |
@@ -1,7 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -use Illuminate\Http\Request; |
|
| 4 | - |
|
| 5 | 3 | /* |
| 6 | 4 | |-------------------------------------------------------------------------- |
| 7 | 5 | | API Routes |
@@ -5,44 +5,44 @@ |
||
| 5 | 5 | */ |
| 6 | 6 | class AclPermissionObserver { |
| 7 | 7 | |
| 8 | - public function saving($model) |
|
| 9 | - { |
|
| 10 | - // |
|
| 11 | - } |
|
| 12 | - |
|
| 13 | - public function saved($model) |
|
| 14 | - { |
|
| 15 | - // |
|
| 16 | - } |
|
| 17 | - |
|
| 18 | - public function creating($model) |
|
| 19 | - { |
|
| 20 | - // |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - public function created($model) |
|
| 24 | - { |
|
| 25 | - // |
|
| 26 | - } |
|
| 27 | - |
|
| 28 | - public function updating($model) |
|
| 29 | - { |
|
| 30 | - // |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - public function updated($model) |
|
| 34 | - { |
|
| 35 | - // |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - public function deleting($model) |
|
| 39 | - { |
|
| 40 | - // |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - public function deleted($model) |
|
| 44 | - { |
|
| 45 | - // |
|
| 46 | - } |
|
| 8 | + public function saving($model) |
|
| 9 | + { |
|
| 10 | + // |
|
| 11 | + } |
|
| 12 | + |
|
| 13 | + public function saved($model) |
|
| 14 | + { |
|
| 15 | + // |
|
| 16 | + } |
|
| 17 | + |
|
| 18 | + public function creating($model) |
|
| 19 | + { |
|
| 20 | + // |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + public function created($model) |
|
| 24 | + { |
|
| 25 | + // |
|
| 26 | + } |
|
| 27 | + |
|
| 28 | + public function updating($model) |
|
| 29 | + { |
|
| 30 | + // |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + public function updated($model) |
|
| 34 | + { |
|
| 35 | + // |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + public function deleting($model) |
|
| 39 | + { |
|
| 40 | + // |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + public function deleted($model) |
|
| 44 | + { |
|
| 45 | + // |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | 48 | } |
| 49 | 49 | \ No newline at end of file |
@@ -13,233 +13,233 @@ discard block |
||
| 13 | 13 | public function up() |
| 14 | 14 | { |
| 15 | 15 | /** |
| 16 | - * Insert the permissions related to this module. |
|
| 17 | - */ |
|
| 18 | - DB::table('permissions')->insert( |
|
| 19 | - [ |
|
| 20 | - /** |
|
| 21 | - * Users model permissions. |
|
| 22 | - */ |
|
| 23 | - [ |
|
| 24 | - 'name' => 'save', |
|
| 25 | - 'model' => 'users', |
|
| 26 | - 'created_at' => \DB::raw('NOW()'), |
|
| 27 | - 'updated_at' => \DB::raw('NOW()') |
|
| 28 | - ], |
|
| 29 | - [ |
|
| 30 | - 'name' => 'delete', |
|
| 31 | - 'model' => 'users', |
|
| 32 | - 'created_at' => \DB::raw('NOW()'), |
|
| 33 | - 'updated_at' => \DB::raw('NOW()') |
|
| 34 | - ], |
|
| 35 | - [ |
|
| 36 | - 'name' => 'find', |
|
| 37 | - 'model' => 'users', |
|
| 38 | - 'created_at' => \DB::raw('NOW()'), |
|
| 39 | - 'updated_at' => \DB::raw('NOW()') |
|
| 40 | - ], |
|
| 41 | - [ |
|
| 42 | - 'name' => 'list', |
|
| 43 | - 'model' => 'users', |
|
| 44 | - 'created_at' => \DB::raw('NOW()'), |
|
| 45 | - 'updated_at' => \DB::raw('NOW()') |
|
| 46 | - ], |
|
| 47 | - [ |
|
| 48 | - 'name' => 'search', |
|
| 49 | - 'model' => 'users', |
|
| 50 | - 'created_at' => \DB::raw('NOW()'), |
|
| 51 | - 'updated_at' => \DB::raw('NOW()') |
|
| 52 | - ], |
|
| 53 | - [ |
|
| 54 | - 'name' => 'findby', |
|
| 55 | - 'model' => 'users', |
|
| 56 | - 'created_at' => \DB::raw('NOW()'), |
|
| 57 | - 'updated_at' => \DB::raw('NOW()') |
|
| 58 | - ], |
|
| 59 | - [ |
|
| 60 | - 'name' => 'first', |
|
| 61 | - 'model' => 'users', |
|
| 62 | - 'created_at' => \DB::raw('NOW()'), |
|
| 63 | - 'updated_at' => \DB::raw('NOW()') |
|
| 64 | - ], |
|
| 65 | - [ |
|
| 66 | - 'name' => 'paginate', |
|
| 67 | - 'model' => 'users', |
|
| 68 | - 'created_at' => \DB::raw('NOW()'), |
|
| 69 | - 'updated_at' => \DB::raw('NOW()') |
|
| 70 | - ], |
|
| 71 | - [ |
|
| 72 | - 'name' => 'paginateby', |
|
| 73 | - 'model' => 'users', |
|
| 74 | - 'created_at' => \DB::raw('NOW()'), |
|
| 75 | - 'updated_at' => \DB::raw('NOW()') |
|
| 76 | - ], |
|
| 77 | - [ |
|
| 78 | - 'name' => 'assigngroups', |
|
| 79 | - 'model' => 'users', |
|
| 80 | - 'created_at' => \DB::raw('NOW()'), |
|
| 81 | - 'updated_at' => \DB::raw('NOW()') |
|
| 82 | - ], |
|
| 83 | - [ |
|
| 84 | - 'name' => 'block', |
|
| 85 | - 'model' => 'users', |
|
| 86 | - 'created_at' => \DB::raw('NOW()'), |
|
| 87 | - 'updated_at' => \DB::raw('NOW()') |
|
| 88 | - ], |
|
| 89 | - [ |
|
| 90 | - 'name' => 'unblock', |
|
| 91 | - 'model' => 'users', |
|
| 92 | - 'created_at' => \DB::raw('NOW()'), |
|
| 93 | - 'updated_at' => \DB::raw('NOW()') |
|
| 94 | - ], |
|
| 95 | - [ |
|
| 96 | - 'name' => 'group', |
|
| 97 | - 'model' => 'users', |
|
| 98 | - 'created_at' => \DB::raw('NOW()'), |
|
| 99 | - 'updated_at' => \DB::raw('NOW()') |
|
| 100 | - ], |
|
| 101 | - [ |
|
| 102 | - 'name' => 'deleted', |
|
| 103 | - 'model' => 'users', |
|
| 104 | - 'created_at' => \DB::raw('NOW()'), |
|
| 105 | - 'updated_at' => \DB::raw('NOW()') |
|
| 106 | - ], |
|
| 107 | - [ |
|
| 108 | - 'name' => 'restore', |
|
| 109 | - 'model' => 'users', |
|
| 110 | - 'created_at' => \DB::raw('NOW()'), |
|
| 111 | - 'updated_at' => \DB::raw('NOW()') |
|
| 112 | - ], |
|
| 16 | + * Insert the permissions related to this module. |
|
| 17 | + */ |
|
| 18 | + DB::table('permissions')->insert( |
|
| 19 | + [ |
|
| 20 | + /** |
|
| 21 | + * Users model permissions. |
|
| 22 | + */ |
|
| 23 | + [ |
|
| 24 | + 'name' => 'save', |
|
| 25 | + 'model' => 'users', |
|
| 26 | + 'created_at' => \DB::raw('NOW()'), |
|
| 27 | + 'updated_at' => \DB::raw('NOW()') |
|
| 28 | + ], |
|
| 29 | + [ |
|
| 30 | + 'name' => 'delete', |
|
| 31 | + 'model' => 'users', |
|
| 32 | + 'created_at' => \DB::raw('NOW()'), |
|
| 33 | + 'updated_at' => \DB::raw('NOW()') |
|
| 34 | + ], |
|
| 35 | + [ |
|
| 36 | + 'name' => 'find', |
|
| 37 | + 'model' => 'users', |
|
| 38 | + 'created_at' => \DB::raw('NOW()'), |
|
| 39 | + 'updated_at' => \DB::raw('NOW()') |
|
| 40 | + ], |
|
| 41 | + [ |
|
| 42 | + 'name' => 'list', |
|
| 43 | + 'model' => 'users', |
|
| 44 | + 'created_at' => \DB::raw('NOW()'), |
|
| 45 | + 'updated_at' => \DB::raw('NOW()') |
|
| 46 | + ], |
|
| 47 | + [ |
|
| 48 | + 'name' => 'search', |
|
| 49 | + 'model' => 'users', |
|
| 50 | + 'created_at' => \DB::raw('NOW()'), |
|
| 51 | + 'updated_at' => \DB::raw('NOW()') |
|
| 52 | + ], |
|
| 53 | + [ |
|
| 54 | + 'name' => 'findby', |
|
| 55 | + 'model' => 'users', |
|
| 56 | + 'created_at' => \DB::raw('NOW()'), |
|
| 57 | + 'updated_at' => \DB::raw('NOW()') |
|
| 58 | + ], |
|
| 59 | + [ |
|
| 60 | + 'name' => 'first', |
|
| 61 | + 'model' => 'users', |
|
| 62 | + 'created_at' => \DB::raw('NOW()'), |
|
| 63 | + 'updated_at' => \DB::raw('NOW()') |
|
| 64 | + ], |
|
| 65 | + [ |
|
| 66 | + 'name' => 'paginate', |
|
| 67 | + 'model' => 'users', |
|
| 68 | + 'created_at' => \DB::raw('NOW()'), |
|
| 69 | + 'updated_at' => \DB::raw('NOW()') |
|
| 70 | + ], |
|
| 71 | + [ |
|
| 72 | + 'name' => 'paginateby', |
|
| 73 | + 'model' => 'users', |
|
| 74 | + 'created_at' => \DB::raw('NOW()'), |
|
| 75 | + 'updated_at' => \DB::raw('NOW()') |
|
| 76 | + ], |
|
| 77 | + [ |
|
| 78 | + 'name' => 'assigngroups', |
|
| 79 | + 'model' => 'users', |
|
| 80 | + 'created_at' => \DB::raw('NOW()'), |
|
| 81 | + 'updated_at' => \DB::raw('NOW()') |
|
| 82 | + ], |
|
| 83 | + [ |
|
| 84 | + 'name' => 'block', |
|
| 85 | + 'model' => 'users', |
|
| 86 | + 'created_at' => \DB::raw('NOW()'), |
|
| 87 | + 'updated_at' => \DB::raw('NOW()') |
|
| 88 | + ], |
|
| 89 | + [ |
|
| 90 | + 'name' => 'unblock', |
|
| 91 | + 'model' => 'users', |
|
| 92 | + 'created_at' => \DB::raw('NOW()'), |
|
| 93 | + 'updated_at' => \DB::raw('NOW()') |
|
| 94 | + ], |
|
| 95 | + [ |
|
| 96 | + 'name' => 'group', |
|
| 97 | + 'model' => 'users', |
|
| 98 | + 'created_at' => \DB::raw('NOW()'), |
|
| 99 | + 'updated_at' => \DB::raw('NOW()') |
|
| 100 | + ], |
|
| 101 | + [ |
|
| 102 | + 'name' => 'deleted', |
|
| 103 | + 'model' => 'users', |
|
| 104 | + 'created_at' => \DB::raw('NOW()'), |
|
| 105 | + 'updated_at' => \DB::raw('NOW()') |
|
| 106 | + ], |
|
| 107 | + [ |
|
| 108 | + 'name' => 'restore', |
|
| 109 | + 'model' => 'users', |
|
| 110 | + 'created_at' => \DB::raw('NOW()'), |
|
| 111 | + 'updated_at' => \DB::raw('NOW()') |
|
| 112 | + ], |
|
| 113 | 113 | |
| 114 | - /** |
|
| 115 | - * Permissions model permissions. |
|
| 116 | - */ |
|
| 117 | - [ |
|
| 118 | - 'name' => 'find', |
|
| 119 | - 'model' => 'permissions', |
|
| 120 | - 'created_at' => \DB::raw('NOW()'), |
|
| 121 | - 'updated_at' => \DB::raw('NOW()') |
|
| 122 | - ], |
|
| 123 | - [ |
|
| 124 | - 'name' => 'search', |
|
| 125 | - 'model' => 'permissions', |
|
| 126 | - 'created_at' => \DB::raw('NOW()'), |
|
| 127 | - 'updated_at' => \DB::raw('NOW()') |
|
| 128 | - ], |
|
| 129 | - [ |
|
| 130 | - 'name' => 'list', |
|
| 131 | - 'model' => 'permissions', |
|
| 132 | - 'created_at' => \DB::raw('NOW()'), |
|
| 133 | - 'updated_at' => \DB::raw('NOW()') |
|
| 134 | - ], |
|
| 135 | - [ |
|
| 136 | - 'name' => 'findby', |
|
| 137 | - 'model' => 'permissions', |
|
| 138 | - 'created_at' => \DB::raw('NOW()'), |
|
| 139 | - 'updated_at' => \DB::raw('NOW()') |
|
| 140 | - ], |
|
| 141 | - [ |
|
| 142 | - 'name' => 'first', |
|
| 143 | - 'model' => 'permissions', |
|
| 144 | - 'created_at' => \DB::raw('NOW()'), |
|
| 145 | - 'updated_at' => \DB::raw('NOW()') |
|
| 146 | - ], |
|
| 147 | - [ |
|
| 148 | - 'name' => 'paginate', |
|
| 149 | - 'model' => 'permissions', |
|
| 150 | - 'created_at' => \DB::raw('NOW()'), |
|
| 151 | - 'updated_at' => \DB::raw('NOW()') |
|
| 152 | - ], |
|
| 153 | - [ |
|
| 154 | - 'name' => 'paginateby', |
|
| 155 | - 'model' => 'permissions', |
|
| 156 | - 'created_at' => \DB::raw('NOW()'), |
|
| 157 | - 'updated_at' => \DB::raw('NOW()') |
|
| 158 | - ], |
|
| 114 | + /** |
|
| 115 | + * Permissions model permissions. |
|
| 116 | + */ |
|
| 117 | + [ |
|
| 118 | + 'name' => 'find', |
|
| 119 | + 'model' => 'permissions', |
|
| 120 | + 'created_at' => \DB::raw('NOW()'), |
|
| 121 | + 'updated_at' => \DB::raw('NOW()') |
|
| 122 | + ], |
|
| 123 | + [ |
|
| 124 | + 'name' => 'search', |
|
| 125 | + 'model' => 'permissions', |
|
| 126 | + 'created_at' => \DB::raw('NOW()'), |
|
| 127 | + 'updated_at' => \DB::raw('NOW()') |
|
| 128 | + ], |
|
| 129 | + [ |
|
| 130 | + 'name' => 'list', |
|
| 131 | + 'model' => 'permissions', |
|
| 132 | + 'created_at' => \DB::raw('NOW()'), |
|
| 133 | + 'updated_at' => \DB::raw('NOW()') |
|
| 134 | + ], |
|
| 135 | + [ |
|
| 136 | + 'name' => 'findby', |
|
| 137 | + 'model' => 'permissions', |
|
| 138 | + 'created_at' => \DB::raw('NOW()'), |
|
| 139 | + 'updated_at' => \DB::raw('NOW()') |
|
| 140 | + ], |
|
| 141 | + [ |
|
| 142 | + 'name' => 'first', |
|
| 143 | + 'model' => 'permissions', |
|
| 144 | + 'created_at' => \DB::raw('NOW()'), |
|
| 145 | + 'updated_at' => \DB::raw('NOW()') |
|
| 146 | + ], |
|
| 147 | + [ |
|
| 148 | + 'name' => 'paginate', |
|
| 149 | + 'model' => 'permissions', |
|
| 150 | + 'created_at' => \DB::raw('NOW()'), |
|
| 151 | + 'updated_at' => \DB::raw('NOW()') |
|
| 152 | + ], |
|
| 153 | + [ |
|
| 154 | + 'name' => 'paginateby', |
|
| 155 | + 'model' => 'permissions', |
|
| 156 | + 'created_at' => \DB::raw('NOW()'), |
|
| 157 | + 'updated_at' => \DB::raw('NOW()') |
|
| 158 | + ], |
|
| 159 | 159 | |
| 160 | - /** |
|
| 161 | - * Groups model permissions. |
|
| 162 | - */ |
|
| 163 | - [ |
|
| 164 | - 'name' => 'save', |
|
| 165 | - 'model' => 'groups', |
|
| 166 | - 'created_at' => \DB::raw('NOW()'), |
|
| 167 | - 'updated_at' => \DB::raw('NOW()') |
|
| 168 | - ], |
|
| 169 | - [ |
|
| 170 | - 'name' => 'delete', |
|
| 171 | - 'model' => 'groups', |
|
| 172 | - 'created_at' => \DB::raw('NOW()'), |
|
| 173 | - 'updated_at' => \DB::raw('NOW()') |
|
| 174 | - ], |
|
| 175 | - [ |
|
| 176 | - 'name' => 'find', |
|
| 177 | - 'model' => 'groups', |
|
| 178 | - 'created_at' => \DB::raw('NOW()'), |
|
| 179 | - 'updated_at' => \DB::raw('NOW()') |
|
| 180 | - ], |
|
| 181 | - [ |
|
| 182 | - 'name' => 'search', |
|
| 183 | - 'model' => 'groups', |
|
| 184 | - 'created_at' => \DB::raw('NOW()'), |
|
| 185 | - 'updated_at' => \DB::raw('NOW()') |
|
| 186 | - ], |
|
| 187 | - [ |
|
| 188 | - 'name' => 'list', |
|
| 189 | - 'model' => 'groups', |
|
| 190 | - 'created_at' => \DB::raw('NOW()'), |
|
| 191 | - 'updated_at' => \DB::raw('NOW()') |
|
| 192 | - ], |
|
| 193 | - [ |
|
| 194 | - 'name' => 'findby', |
|
| 195 | - 'model' => 'groups', |
|
| 196 | - 'created_at' => \DB::raw('NOW()'), |
|
| 197 | - 'updated_at' => \DB::raw('NOW()') |
|
| 198 | - ], |
|
| 199 | - [ |
|
| 200 | - 'name' => 'first', |
|
| 201 | - 'model' => 'groups', |
|
| 202 | - 'created_at' => \DB::raw('NOW()'), |
|
| 203 | - 'updated_at' => \DB::raw('NOW()') |
|
| 204 | - ], |
|
| 205 | - [ |
|
| 206 | - 'name' => 'paginate', |
|
| 207 | - 'model' => 'groups', |
|
| 208 | - 'created_at' => \DB::raw('NOW()'), |
|
| 209 | - 'updated_at' => \DB::raw('NOW()') |
|
| 210 | - ], |
|
| 211 | - [ |
|
| 212 | - 'name' => 'paginateby', |
|
| 213 | - 'model' => 'groups', |
|
| 214 | - 'created_at' => \DB::raw('NOW()'), |
|
| 215 | - 'updated_at' => \DB::raw('NOW()') |
|
| 216 | - ], |
|
| 217 | - [ |
|
| 218 | - 'name' => 'assignpermissions', |
|
| 219 | - 'model' => 'groups', |
|
| 220 | - 'created_at' => \DB::raw('NOW()'), |
|
| 221 | - 'updated_at' => \DB::raw('NOW()') |
|
| 222 | - ], |
|
| 223 | - [ |
|
| 224 | - 'name' => 'users', |
|
| 225 | - 'model' => 'groups', |
|
| 226 | - 'created_at' => \DB::raw('NOW()'), |
|
| 227 | - 'updated_at' => \DB::raw('NOW()') |
|
| 228 | - ], |
|
| 229 | - [ |
|
| 230 | - 'name' => 'deleted', |
|
| 231 | - 'model' => 'groups', |
|
| 232 | - 'created_at' => \DB::raw('NOW()'), |
|
| 233 | - 'updated_at' => \DB::raw('NOW()') |
|
| 234 | - ], |
|
| 235 | - [ |
|
| 236 | - 'name' => 'restore', |
|
| 237 | - 'model' => 'groups', |
|
| 238 | - 'created_at' => \DB::raw('NOW()'), |
|
| 239 | - 'updated_at' => \DB::raw('NOW()') |
|
| 240 | - ], |
|
| 241 | - ] |
|
| 242 | - ); |
|
| 160 | + /** |
|
| 161 | + * Groups model permissions. |
|
| 162 | + */ |
|
| 163 | + [ |
|
| 164 | + 'name' => 'save', |
|
| 165 | + 'model' => 'groups', |
|
| 166 | + 'created_at' => \DB::raw('NOW()'), |
|
| 167 | + 'updated_at' => \DB::raw('NOW()') |
|
| 168 | + ], |
|
| 169 | + [ |
|
| 170 | + 'name' => 'delete', |
|
| 171 | + 'model' => 'groups', |
|
| 172 | + 'created_at' => \DB::raw('NOW()'), |
|
| 173 | + 'updated_at' => \DB::raw('NOW()') |
|
| 174 | + ], |
|
| 175 | + [ |
|
| 176 | + 'name' => 'find', |
|
| 177 | + 'model' => 'groups', |
|
| 178 | + 'created_at' => \DB::raw('NOW()'), |
|
| 179 | + 'updated_at' => \DB::raw('NOW()') |
|
| 180 | + ], |
|
| 181 | + [ |
|
| 182 | + 'name' => 'search', |
|
| 183 | + 'model' => 'groups', |
|
| 184 | + 'created_at' => \DB::raw('NOW()'), |
|
| 185 | + 'updated_at' => \DB::raw('NOW()') |
|
| 186 | + ], |
|
| 187 | + [ |
|
| 188 | + 'name' => 'list', |
|
| 189 | + 'model' => 'groups', |
|
| 190 | + 'created_at' => \DB::raw('NOW()'), |
|
| 191 | + 'updated_at' => \DB::raw('NOW()') |
|
| 192 | + ], |
|
| 193 | + [ |
|
| 194 | + 'name' => 'findby', |
|
| 195 | + 'model' => 'groups', |
|
| 196 | + 'created_at' => \DB::raw('NOW()'), |
|
| 197 | + 'updated_at' => \DB::raw('NOW()') |
|
| 198 | + ], |
|
| 199 | + [ |
|
| 200 | + 'name' => 'first', |
|
| 201 | + 'model' => 'groups', |
|
| 202 | + 'created_at' => \DB::raw('NOW()'), |
|
| 203 | + 'updated_at' => \DB::raw('NOW()') |
|
| 204 | + ], |
|
| 205 | + [ |
|
| 206 | + 'name' => 'paginate', |
|
| 207 | + 'model' => 'groups', |
|
| 208 | + 'created_at' => \DB::raw('NOW()'), |
|
| 209 | + 'updated_at' => \DB::raw('NOW()') |
|
| 210 | + ], |
|
| 211 | + [ |
|
| 212 | + 'name' => 'paginateby', |
|
| 213 | + 'model' => 'groups', |
|
| 214 | + 'created_at' => \DB::raw('NOW()'), |
|
| 215 | + 'updated_at' => \DB::raw('NOW()') |
|
| 216 | + ], |
|
| 217 | + [ |
|
| 218 | + 'name' => 'assignpermissions', |
|
| 219 | + 'model' => 'groups', |
|
| 220 | + 'created_at' => \DB::raw('NOW()'), |
|
| 221 | + 'updated_at' => \DB::raw('NOW()') |
|
| 222 | + ], |
|
| 223 | + [ |
|
| 224 | + 'name' => 'users', |
|
| 225 | + 'model' => 'groups', |
|
| 226 | + 'created_at' => \DB::raw('NOW()'), |
|
| 227 | + 'updated_at' => \DB::raw('NOW()') |
|
| 228 | + ], |
|
| 229 | + [ |
|
| 230 | + 'name' => 'deleted', |
|
| 231 | + 'model' => 'groups', |
|
| 232 | + 'created_at' => \DB::raw('NOW()'), |
|
| 233 | + 'updated_at' => \DB::raw('NOW()') |
|
| 234 | + ], |
|
| 235 | + [ |
|
| 236 | + 'name' => 'restore', |
|
| 237 | + 'model' => 'groups', |
|
| 238 | + 'created_at' => \DB::raw('NOW()'), |
|
| 239 | + 'updated_at' => \DB::raw('NOW()') |
|
| 240 | + ], |
|
| 241 | + ] |
|
| 242 | + ); |
|
| 243 | 243 | |
| 244 | 244 | /** |
| 245 | 245 | * Create Default groups. |
@@ -256,29 +256,29 @@ discard block |
||
| 256 | 256 | * Create Default users. |
| 257 | 257 | */ |
| 258 | 258 | $adminUserId = DB::table('users')->insertGetId( |
| 259 | - [ |
|
| 259 | + [ |
|
| 260 | 260 | 'email' => '[email protected]', |
| 261 | 261 | 'password' => bcrypt('123456'), |
| 262 | 262 | 'created_at' => \DB::raw('NOW()'), |
| 263 | 263 | 'updated_at' => \DB::raw('NOW()') |
| 264 | 264 | ] |
| 265 | - ); |
|
| 265 | + ); |
|
| 266 | 266 | |
| 267 | 267 | /** |
| 268 | 268 | * Assign users to groups. |
| 269 | 269 | */ |
| 270 | 270 | DB::table('users_groups')->insert( |
| 271 | - [ |
|
| 272 | - [ |
|
| 271 | + [ |
|
| 272 | + [ |
|
| 273 | 273 | 'user_id' => $adminUserId, |
| 274 | 274 | 'group_id' => $adminGroupId, |
| 275 | 275 | 'created_at' => \DB::raw('NOW()'), |
| 276 | 276 | 'updated_at' => \DB::raw('NOW()') |
| 277 | - ] |
|
| 278 | - ] |
|
| 279 | - ); |
|
| 277 | + ] |
|
| 278 | + ] |
|
| 279 | + ); |
|
| 280 | 280 | |
| 281 | - /** |
|
| 281 | + /** |
|
| 282 | 282 | * Assign the permissions to the admin group. |
| 283 | 283 | */ |
| 284 | 284 | $permissionIds = DB::table('permissions')->whereIn('model', ['users', 'permissions', 'groups'])->select('id')->pluck('id'); |
@@ -7,252 +7,252 @@ |
||
| 7 | 7 | |
| 8 | 8 | class UsersController extends BaseApiController |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * The name of the model that is used by the base api controller |
|
| 12 | - * to preform actions like (add, edit ... etc). |
|
| 13 | - * @var string |
|
| 14 | - */ |
|
| 15 | - protected $model = 'users'; |
|
| 10 | + /** |
|
| 11 | + * The name of the model that is used by the base api controller |
|
| 12 | + * to preform actions like (add, edit ... etc). |
|
| 13 | + * @var string |
|
| 14 | + */ |
|
| 15 | + protected $model = 'users'; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * List of all route actions that the base api controller |
|
| 19 | - * will skip permissions check for them. |
|
| 20 | - * @var array |
|
| 21 | - */ |
|
| 22 | - protected $skipPermissionCheck = ['account', 'logout', 'sendreset']; |
|
| 17 | + /** |
|
| 18 | + * List of all route actions that the base api controller |
|
| 19 | + * will skip permissions check for them. |
|
| 20 | + * @var array |
|
| 21 | + */ |
|
| 22 | + protected $skipPermissionCheck = ['account', 'logout', 'sendreset']; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * List of all route actions that the base api controller |
|
| 26 | - * will skip login check for them. |
|
| 27 | - * @var array |
|
| 28 | - */ |
|
| 29 | - protected $skipLoginCheck = ['login', 'loginSocial', 'register', 'sendreset', 'resetpassword', 'refreshtoken']; |
|
| 24 | + /** |
|
| 25 | + * List of all route actions that the base api controller |
|
| 26 | + * will skip login check for them. |
|
| 27 | + * @var array |
|
| 28 | + */ |
|
| 29 | + protected $skipLoginCheck = ['login', 'loginSocial', 'register', 'sendreset', 'resetpassword', 'refreshtoken']; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * The validations rules used by the base api controller |
|
| 33 | - * to check before add. |
|
| 34 | - * @var array |
|
| 35 | - */ |
|
| 36 | - protected $validationRules = [ |
|
| 37 | - 'user_name' => 'string|unique:users,user_name,{id}', |
|
| 38 | - 'email' => 'required|email|unique:users,email,{id}', |
|
| 39 | - 'password' => 'min:6' |
|
| 40 | - ]; |
|
| 31 | + /** |
|
| 32 | + * The validations rules used by the base api controller |
|
| 33 | + * to check before add. |
|
| 34 | + * @var array |
|
| 35 | + */ |
|
| 36 | + protected $validationRules = [ |
|
| 37 | + 'user_name' => 'string|unique:users,user_name,{id}', |
|
| 38 | + 'email' => 'required|email|unique:users,email,{id}', |
|
| 39 | + 'password' => 'min:6' |
|
| 40 | + ]; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Return the logged in user account. |
|
| 44 | - * |
|
| 45 | - * @return \Illuminate\Http\Response |
|
| 46 | - */ |
|
| 47 | - public function account() |
|
| 48 | - { |
|
| 49 | - $relations = $this->relations && $this->relations['account'] ? $this->relations['account'] : []; |
|
| 50 | - return \Response::json(\Core::users()->account($relations), 200); |
|
| 51 | - } |
|
| 42 | + /** |
|
| 43 | + * Return the logged in user account. |
|
| 44 | + * |
|
| 45 | + * @return \Illuminate\Http\Response |
|
| 46 | + */ |
|
| 47 | + public function account() |
|
| 48 | + { |
|
| 49 | + $relations = $this->relations && $this->relations['account'] ? $this->relations['account'] : []; |
|
| 50 | + return \Response::json(\Core::users()->account($relations), 200); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Block the user. |
|
| 55 | - * |
|
| 56 | - * @param integer $id |
|
| 57 | - * @return \Illuminate\Http\Response |
|
| 58 | - */ |
|
| 59 | - public function block($id) |
|
| 60 | - { |
|
| 61 | - return \Response::json(\Core::users()->block($id), 200); |
|
| 62 | - } |
|
| 53 | + /** |
|
| 54 | + * Block the user. |
|
| 55 | + * |
|
| 56 | + * @param integer $id |
|
| 57 | + * @return \Illuminate\Http\Response |
|
| 58 | + */ |
|
| 59 | + public function block($id) |
|
| 60 | + { |
|
| 61 | + return \Response::json(\Core::users()->block($id), 200); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Unblock the user. |
|
| 66 | - * |
|
| 67 | - * @param integer $id |
|
| 68 | - * @return \Illuminate\Http\Response |
|
| 69 | - */ |
|
| 70 | - public function unblock($id) |
|
| 71 | - { |
|
| 72 | - return \Response::json(\Core::users()->unblock($id), 200); |
|
| 73 | - } |
|
| 64 | + /** |
|
| 65 | + * Unblock the user. |
|
| 66 | + * |
|
| 67 | + * @param integer $id |
|
| 68 | + * @return \Illuminate\Http\Response |
|
| 69 | + */ |
|
| 70 | + public function unblock($id) |
|
| 71 | + { |
|
| 72 | + return \Response::json(\Core::users()->unblock($id), 200); |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * Logout the user. |
|
| 77 | - * |
|
| 78 | - * @return \Illuminate\Http\Response |
|
| 79 | - */ |
|
| 80 | - public function logout() |
|
| 81 | - { |
|
| 82 | - return \Response::json(\Core::users()->logout(), 200); |
|
| 83 | - } |
|
| 75 | + /** |
|
| 76 | + * Logout the user. |
|
| 77 | + * |
|
| 78 | + * @return \Illuminate\Http\Response |
|
| 79 | + */ |
|
| 80 | + public function logout() |
|
| 81 | + { |
|
| 82 | + return \Response::json(\Core::users()->logout(), 200); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * Handle a registration request. |
|
| 87 | - * |
|
| 88 | - * @param \Illuminate\Http\Request $request |
|
| 89 | - * @return \Illuminate\Http\Response |
|
| 90 | - */ |
|
| 91 | - public function register(Request $request) |
|
| 92 | - { |
|
| 93 | - $this->validate($request, [ |
|
| 94 | - 'user_name' => 'string|unique:users,user_name,{id}', |
|
| 95 | - 'email' => 'required|email|unique:users,email,{id}', |
|
| 96 | - 'password' => 'required|min:6' |
|
| 97 | - ]); |
|
| 85 | + /** |
|
| 86 | + * Handle a registration request. |
|
| 87 | + * |
|
| 88 | + * @param \Illuminate\Http\Request $request |
|
| 89 | + * @return \Illuminate\Http\Response |
|
| 90 | + */ |
|
| 91 | + public function register(Request $request) |
|
| 92 | + { |
|
| 93 | + $this->validate($request, [ |
|
| 94 | + 'user_name' => 'string|unique:users,user_name,{id}', |
|
| 95 | + 'email' => 'required|email|unique:users,email,{id}', |
|
| 96 | + 'password' => 'required|min:6' |
|
| 97 | + ]); |
|
| 98 | 98 | |
| 99 | - return \Response::json(\Core::users()->register($request->only('email', 'password')), 200); |
|
| 100 | - } |
|
| 99 | + return \Response::json(\Core::users()->register($request->only('email', 'password')), 200); |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - /** |
|
| 103 | - * Handle a login request of the none admin to the application. |
|
| 104 | - * |
|
| 105 | - * @param \Illuminate\Http\Request $request |
|
| 106 | - * @return \Illuminate\Http\Response |
|
| 107 | - */ |
|
| 108 | - public function login(Request $request) |
|
| 109 | - { |
|
| 110 | - $this->validate($request, [ |
|
| 111 | - 'email' => 'required|email', |
|
| 112 | - 'password' => 'required|min:6', |
|
| 113 | - 'admin' => 'boolean' |
|
| 114 | - ]); |
|
| 102 | + /** |
|
| 103 | + * Handle a login request of the none admin to the application. |
|
| 104 | + * |
|
| 105 | + * @param \Illuminate\Http\Request $request |
|
| 106 | + * @return \Illuminate\Http\Response |
|
| 107 | + */ |
|
| 108 | + public function login(Request $request) |
|
| 109 | + { |
|
| 110 | + $this->validate($request, [ |
|
| 111 | + 'email' => 'required|email', |
|
| 112 | + 'password' => 'required|min:6', |
|
| 113 | + 'admin' => 'boolean' |
|
| 114 | + ]); |
|
| 115 | 115 | |
| 116 | - return \Response::json(\Core::users()->login($request->only('email', 'password'), $request->get('admin')), 200); |
|
| 117 | - } |
|
| 116 | + return \Response::json(\Core::users()->login($request->only('email', 'password'), $request->get('admin')), 200); |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - /** |
|
| 120 | - * Handle a social login request of the none admin to the application. |
|
| 121 | - * |
|
| 122 | - * @param \Illuminate\Http\Request $request |
|
| 123 | - * @return \Illuminate\Http\Response |
|
| 124 | - */ |
|
| 125 | - public function loginSocial(Request $request) |
|
| 126 | - { |
|
| 127 | - $this->validate($request, [ |
|
| 128 | - 'auth_code' => 'required_without:access_token', |
|
| 129 | - 'access_token' => 'required_without:auth_code', |
|
| 130 | - 'type' => 'required|in:facebook,google' |
|
| 131 | - ]); |
|
| 119 | + /** |
|
| 120 | + * Handle a social login request of the none admin to the application. |
|
| 121 | + * |
|
| 122 | + * @param \Illuminate\Http\Request $request |
|
| 123 | + * @return \Illuminate\Http\Response |
|
| 124 | + */ |
|
| 125 | + public function loginSocial(Request $request) |
|
| 126 | + { |
|
| 127 | + $this->validate($request, [ |
|
| 128 | + 'auth_code' => 'required_without:access_token', |
|
| 129 | + 'access_token' => 'required_without:auth_code', |
|
| 130 | + 'type' => 'required|in:facebook,google' |
|
| 131 | + ]); |
|
| 132 | 132 | |
| 133 | - return \Response::json(\Core::users()->loginSocial($request->only('auth_code', 'access_token', 'type')), 200); |
|
| 134 | - } |
|
| 133 | + return \Response::json(\Core::users()->loginSocial($request->only('auth_code', 'access_token', 'type')), 200); |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | - /** |
|
| 137 | - * Handle an assign groups to user request. |
|
| 138 | - * |
|
| 139 | - * @param \Illuminate\Http\Request $request |
|
| 140 | - * @return \Illuminate\Http\Response |
|
| 141 | - */ |
|
| 142 | - public function assigngroups(Request $request) |
|
| 143 | - { |
|
| 144 | - $this->validate($request, [ |
|
| 145 | - 'group_ids' => 'required|exists:groups,id', |
|
| 146 | - 'user_id' => 'required|exists:users,id' |
|
| 147 | - ]); |
|
| 136 | + /** |
|
| 137 | + * Handle an assign groups to user request. |
|
| 138 | + * |
|
| 139 | + * @param \Illuminate\Http\Request $request |
|
| 140 | + * @return \Illuminate\Http\Response |
|
| 141 | + */ |
|
| 142 | + public function assigngroups(Request $request) |
|
| 143 | + { |
|
| 144 | + $this->validate($request, [ |
|
| 145 | + 'group_ids' => 'required|exists:groups,id', |
|
| 146 | + 'user_id' => 'required|exists:users,id' |
|
| 147 | + ]); |
|
| 148 | 148 | |
| 149 | - return \Response::json(\Core::users()->assignGroups($request->get('user_id'), $request->get('group_ids')), 200); |
|
| 150 | - } |
|
| 149 | + return \Response::json(\Core::users()->assignGroups($request->get('user_id'), $request->get('group_ids')), 200); |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - /** |
|
| 153 | - * Send a reset link to the given user. |
|
| 154 | - * |
|
| 155 | - * @param \Illuminate\Http\Request $request |
|
| 156 | - * @return \Illuminate\Http\Response |
|
| 157 | - */ |
|
| 158 | - public function sendreset(Request $request) |
|
| 159 | - { |
|
| 160 | - $this->validate($request, ['email' => 'required|email', 'url' => 'required|url']); |
|
| 152 | + /** |
|
| 153 | + * Send a reset link to the given user. |
|
| 154 | + * |
|
| 155 | + * @param \Illuminate\Http\Request $request |
|
| 156 | + * @return \Illuminate\Http\Response |
|
| 157 | + */ |
|
| 158 | + public function sendreset(Request $request) |
|
| 159 | + { |
|
| 160 | + $this->validate($request, ['email' => 'required|email', 'url' => 'required|url']); |
|
| 161 | 161 | |
| 162 | - return \Response::json(\Core::users()->sendReset($request->only('email'), $request->get('url')), 200); |
|
| 163 | - } |
|
| 162 | + return \Response::json(\Core::users()->sendReset($request->only('email'), $request->get('url')), 200); |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | - /** |
|
| 166 | - * Reset the given user's password. |
|
| 167 | - * |
|
| 168 | - * @param \Illuminate\Http\Request $request |
|
| 169 | - * @return \Illuminate\Http\Response |
|
| 170 | - */ |
|
| 171 | - public function resetpassword(Request $request) |
|
| 172 | - { |
|
| 173 | - $this->validate($request, [ |
|
| 174 | - 'token' => 'required', |
|
| 175 | - 'email' => 'required|email', |
|
| 176 | - 'password' => 'required|confirmed|min:6', |
|
| 177 | - 'password_confirmation' => 'required', |
|
| 178 | - ]); |
|
| 165 | + /** |
|
| 166 | + * Reset the given user's password. |
|
| 167 | + * |
|
| 168 | + * @param \Illuminate\Http\Request $request |
|
| 169 | + * @return \Illuminate\Http\Response |
|
| 170 | + */ |
|
| 171 | + public function resetpassword(Request $request) |
|
| 172 | + { |
|
| 173 | + $this->validate($request, [ |
|
| 174 | + 'token' => 'required', |
|
| 175 | + 'email' => 'required|email', |
|
| 176 | + 'password' => 'required|confirmed|min:6', |
|
| 177 | + 'password_confirmation' => 'required', |
|
| 178 | + ]); |
|
| 179 | 179 | |
| 180 | - return \Response::json(\Core::users()->resetPassword($request->only('email', 'password', 'password_confirmation', 'token')), 200); |
|
| 181 | - } |
|
| 180 | + return \Response::json(\Core::users()->resetPassword($request->only('email', 'password', 'password_confirmation', 'token')), 200); |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | - /** |
|
| 184 | - * Change the logged in user password. |
|
| 185 | - * |
|
| 186 | - * @param \Illuminate\Http\Request $request |
|
| 187 | - * @return \Illuminate\Http\Response |
|
| 188 | - */ |
|
| 189 | - public function changePassword(Request $request) |
|
| 190 | - { |
|
| 191 | - $this->validate($request, [ |
|
| 192 | - 'old_password' => 'required', |
|
| 193 | - 'password' => 'required|confirmed|min:6', |
|
| 194 | - 'password_confirmation' => 'required', |
|
| 195 | - ]); |
|
| 183 | + /** |
|
| 184 | + * Change the logged in user password. |
|
| 185 | + * |
|
| 186 | + * @param \Illuminate\Http\Request $request |
|
| 187 | + * @return \Illuminate\Http\Response |
|
| 188 | + */ |
|
| 189 | + public function changePassword(Request $request) |
|
| 190 | + { |
|
| 191 | + $this->validate($request, [ |
|
| 192 | + 'old_password' => 'required', |
|
| 193 | + 'password' => 'required|confirmed|min:6', |
|
| 194 | + 'password_confirmation' => 'required', |
|
| 195 | + ]); |
|
| 196 | 196 | |
| 197 | - return \Response::json(\Core::users()->changePassword($request->only('old_password', 'password', 'password_confirmation')), 200); |
|
| 198 | - } |
|
| 197 | + return \Response::json(\Core::users()->changePassword($request->only('old_password', 'password', 'password_confirmation')), 200); |
|
| 198 | + } |
|
| 199 | 199 | |
| 200 | - /** |
|
| 201 | - * Refresh the expired login token. |
|
| 202 | - * |
|
| 203 | - * @return \Illuminate\Http\Response |
|
| 204 | - */ |
|
| 205 | - public function refreshtoken() |
|
| 206 | - { |
|
| 207 | - return \Response::json(\Core::users()->refreshtoken(), 200); |
|
| 208 | - } |
|
| 200 | + /** |
|
| 201 | + * Refresh the expired login token. |
|
| 202 | + * |
|
| 203 | + * @return \Illuminate\Http\Response |
|
| 204 | + */ |
|
| 205 | + public function refreshtoken() |
|
| 206 | + { |
|
| 207 | + return \Response::json(\Core::users()->refreshtoken(), 200); |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | - /** |
|
| 211 | - * Paginate all users with inthe given group. |
|
| 212 | - * |
|
| 213 | - * @param \Illuminate\Http\Request $request |
|
| 214 | - * @param string $groupName |
|
| 215 | - * @param integer $perPage |
|
| 216 | - * @param string $sortBy |
|
| 217 | - * @param boolean $desc |
|
| 218 | - * @return \Illuminate\Http\Response |
|
| 219 | - */ |
|
| 220 | - public function group(Request $request, $groupName, $perPage = false, $sortBy = 'created_at', $desc = 1) |
|
| 221 | - { |
|
| 222 | - $relations = $this->relations && $this->relations['group'] ? $this->relations['group'] : []; |
|
| 223 | - return \Response::json(\Core::users()->group($request->all(), $groupName, $relations, $perPage, $sortBy, $desc), 200); |
|
| 224 | - } |
|
| 210 | + /** |
|
| 211 | + * Paginate all users with inthe given group. |
|
| 212 | + * |
|
| 213 | + * @param \Illuminate\Http\Request $request |
|
| 214 | + * @param string $groupName |
|
| 215 | + * @param integer $perPage |
|
| 216 | + * @param string $sortBy |
|
| 217 | + * @param boolean $desc |
|
| 218 | + * @return \Illuminate\Http\Response |
|
| 219 | + */ |
|
| 220 | + public function group(Request $request, $groupName, $perPage = false, $sortBy = 'created_at', $desc = 1) |
|
| 221 | + { |
|
| 222 | + $relations = $this->relations && $this->relations['group'] ? $this->relations['group'] : []; |
|
| 223 | + return \Response::json(\Core::users()->group($request->all(), $groupName, $relations, $perPage, $sortBy, $desc), 200); |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | - /** |
|
| 227 | - * Save the given data to the logged in user. |
|
| 228 | - * |
|
| 229 | - * @param \Illuminate\Http\Request $request |
|
| 230 | - * @return \Illuminate\Http\Response |
|
| 231 | - */ |
|
| 232 | - public function saveProfile(Request $request) |
|
| 233 | - { |
|
| 234 | - foreach ($this->validationRules as &$rule) |
|
| 235 | - { |
|
| 236 | - if (strpos($rule, 'exists') && ! strpos($rule, 'deleted_at,NULL')) |
|
| 237 | - { |
|
| 238 | - $rule .= ',deleted_at,NULL'; |
|
| 239 | - } |
|
| 226 | + /** |
|
| 227 | + * Save the given data to the logged in user. |
|
| 228 | + * |
|
| 229 | + * @param \Illuminate\Http\Request $request |
|
| 230 | + * @return \Illuminate\Http\Response |
|
| 231 | + */ |
|
| 232 | + public function saveProfile(Request $request) |
|
| 233 | + { |
|
| 234 | + foreach ($this->validationRules as &$rule) |
|
| 235 | + { |
|
| 236 | + if (strpos($rule, 'exists') && ! strpos($rule, 'deleted_at,NULL')) |
|
| 237 | + { |
|
| 238 | + $rule .= ',deleted_at,NULL'; |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | - if ($request->has('id')) |
|
| 242 | - { |
|
| 243 | - $rule = str_replace('{id}', $request->get('id'), $rule); |
|
| 244 | - } |
|
| 245 | - else |
|
| 246 | - { |
|
| 247 | - $rule = str_replace(',{id}', '', $rule); |
|
| 248 | - } |
|
| 249 | - } |
|
| 241 | + if ($request->has('id')) |
|
| 242 | + { |
|
| 243 | + $rule = str_replace('{id}', $request->get('id'), $rule); |
|
| 244 | + } |
|
| 245 | + else |
|
| 246 | + { |
|
| 247 | + $rule = str_replace(',{id}', '', $rule); |
|
| 248 | + } |
|
| 249 | + } |
|
| 250 | 250 | |
| 251 | - $this->validate($request, $this->validationRules); |
|
| 251 | + $this->validate($request, $this->validationRules); |
|
| 252 | 252 | |
| 253 | - if ($this->model) |
|
| 254 | - { |
|
| 255 | - return \Response::json(call_user_func_array("\Core::{$this->model}", [])->saveProfile($request->all()), 200); |
|
| 256 | - } |
|
| 257 | - } |
|
| 253 | + if ($this->model) |
|
| 254 | + { |
|
| 255 | + return \Response::json(call_user_func_array("\Core::{$this->model}", [])->saveProfile($request->all()), 200); |
|
| 256 | + } |
|
| 257 | + } |
|
| 258 | 258 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | * to preform actions like (add, edit ... etc). |
| 13 | 13 | * @var string |
| 14 | 14 | */ |
| 15 | - protected $model = 'users'; |
|
| 15 | + protected $model = 'users'; |
|
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * List of all route actions that the base api controller |
@@ -26,14 +26,14 @@ discard block |
||
| 26 | 26 | * will skip login check for them. |
| 27 | 27 | * @var array |
| 28 | 28 | */ |
| 29 | - protected $skipLoginCheck = ['login', 'loginSocial', 'register', 'sendreset', 'resetpassword', 'refreshtoken']; |
|
| 29 | + protected $skipLoginCheck = ['login', 'loginSocial', 'register', 'sendreset', 'resetpassword', 'refreshtoken']; |
|
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * The validations rules used by the base api controller |
| 33 | 33 | * to check before add. |
| 34 | 34 | * @var array |
| 35 | 35 | */ |
| 36 | - protected $validationRules = [ |
|
| 36 | + protected $validationRules = [ |
|
| 37 | 37 | 'user_name' => 'string|unique:users,user_name,{id}', |
| 38 | 38 | 'email' => 'required|email|unique:users,email,{id}', |
| 39 | 39 | 'password' => 'min:6' |
@@ -170,8 +170,7 @@ |
||
| 170 | 170 | if ($request->has('id')) |
| 171 | 171 | { |
| 172 | 172 | $rule = str_replace('{id}', $request->get('id'), $rule); |
| 173 | - } |
|
| 174 | - else |
|
| 173 | + } else |
|
| 175 | 174 | { |
| 176 | 175 | $rule = str_replace(',{id}', '', $rule); |
| 177 | 176 | } |
@@ -5,44 +5,44 @@ |
||
| 5 | 5 | */ |
| 6 | 6 | class ReprotObserver { |
| 7 | 7 | |
| 8 | - public function saving($model) |
|
| 9 | - { |
|
| 10 | - // |
|
| 11 | - } |
|
| 12 | - |
|
| 13 | - public function saved($model) |
|
| 14 | - { |
|
| 15 | - // |
|
| 16 | - } |
|
| 17 | - |
|
| 18 | - public function creating($model) |
|
| 19 | - { |
|
| 20 | - // |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - public function created($model) |
|
| 24 | - { |
|
| 25 | - // |
|
| 26 | - } |
|
| 27 | - |
|
| 28 | - public function updating($model) |
|
| 29 | - { |
|
| 30 | - // |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - public function updated($model) |
|
| 34 | - { |
|
| 35 | - // |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - public function deleting($model) |
|
| 39 | - { |
|
| 40 | - // |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - public function deleted($model) |
|
| 44 | - { |
|
| 45 | - // |
|
| 46 | - } |
|
| 8 | + public function saving($model) |
|
| 9 | + { |
|
| 10 | + // |
|
| 11 | + } |
|
| 12 | + |
|
| 13 | + public function saved($model) |
|
| 14 | + { |
|
| 15 | + // |
|
| 16 | + } |
|
| 17 | + |
|
| 18 | + public function creating($model) |
|
| 19 | + { |
|
| 20 | + // |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + public function created($model) |
|
| 24 | + { |
|
| 25 | + // |
|
| 26 | + } |
|
| 27 | + |
|
| 28 | + public function updating($model) |
|
| 29 | + { |
|
| 30 | + // |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + public function updated($model) |
|
| 34 | + { |
|
| 35 | + // |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + public function deleting($model) |
|
| 39 | + { |
|
| 40 | + // |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + public function deleted($model) |
|
| 44 | + { |
|
| 45 | + // |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | 48 | } |
| 49 | 49 | \ No newline at end of file |