@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @param Response $response |
16 | 16 | * @param array $args |
17 | 17 | * |
18 | - * @return mixed |
|
18 | + * @return \Psr\Http\Message\ResponseInterface |
|
19 | 19 | */ |
20 | 20 | public function actionIndex(Request $request, Response $response, $args) |
21 | 21 | { |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @param Response $response |
88 | 88 | * @param array $args |
89 | 89 | * |
90 | - * @return mixed |
|
90 | + * @return \Psr\Http\Message\ResponseInterface |
|
91 | 91 | * @throws JsonException |
92 | 92 | */ |
93 | 93 | public function actionGet(Request $request, Response $response, $args) |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @param Response $response |
111 | 111 | * @param array $args |
112 | 112 | * |
113 | - * @return mixed |
|
113 | + * @return \Psr\Http\Message\ResponseInterface |
|
114 | 114 | * @throws JsonException |
115 | 115 | */ |
116 | 116 | public function actionCreate(Request $request, Response $response, $args) |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @param Response $response |
134 | 134 | * @param array $args |
135 | 135 | * |
136 | - * @return mixed |
|
136 | + * @return \Psr\Http\Message\ResponseInterface |
|
137 | 137 | * @throws JsonException |
138 | 138 | */ |
139 | 139 | public function actionUpdate(Request $request, Response $response, $args) |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * @param Response $response |
163 | 163 | * @param array $args |
164 | 164 | * |
165 | - * @return mixed |
|
165 | + * @return \Psr\Http\Message\ResponseInterface |
|
166 | 166 | * @throws JsonException |
167 | 167 | */ |
168 | 168 | public function actionDelete(Request $request, Response $response, $args) |
@@ -4,7 +4,6 @@ |
||
4 | 4 | use App\Common\Helper; |
5 | 5 | use App\Common\JsonException; |
6 | 6 | use App\Scopes\MaxPerPageScope; |
7 | - |
|
8 | 7 | use Slim\Http\Request; |
9 | 8 | use Slim\Http\Response; |
10 | 9 |
@@ -44,7 +44,7 @@ |
||
44 | 44 | $query = $query->whereNotIn($filter['attribute'], $filter['value']); |
45 | 45 | break; |
46 | 46 | case 'like': |
47 | - $query = $query->where($filter['attribute'], 'like', '%' . $filter['value'] . '%'); |
|
47 | + $query = $query->where($filter['attribute'], 'like', '%'.$filter['value'].'%'); |
|
48 | 48 | break; |
49 | 49 | case '=': |
50 | 50 | case '!=': |
@@ -34,7 +34,9 @@ |
||
34 | 34 | $filter['operator'] = trim(strtolower($filter['operator'])); |
35 | 35 | $filter['attribute'] = trim($filter['attribute']); |
36 | 36 | |
37 | - if (empty($filter['operator']) || empty($filter['attribute']) || empty($filter['value'])) continue; |
|
37 | + if (empty($filter['operator']) || empty($filter['attribute']) || empty($filter['value'])) { |
|
38 | + continue; |
|
39 | + } |
|
38 | 40 | |
39 | 41 | switch ($filter['operator']) { |
40 | 42 | case 'in': |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * @param Response $response |
20 | 20 | * @param array $args |
21 | 21 | * |
22 | - * @return mixed |
|
22 | + * @return \Psr\Http\Message\ResponseInterface |
|
23 | 23 | * @throws JsonException |
24 | 24 | */ |
25 | 25 | public function actionCreate(Request $request, Response $response, $args) |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @param Response $response |
49 | 49 | * @param array $args |
50 | 50 | * |
51 | - * @return mixed |
|
51 | + * @return \Psr\Http\Message\ResponseInterface |
|
52 | 52 | * @throws JsonException |
53 | 53 | */ |
54 | 54 | public function actionUpdate(Request $request, Response $response, $args) |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @param Response $response |
81 | 81 | * @param array $args |
82 | 82 | * |
83 | - * @return mixed |
|
83 | + * @return \Psr\Http\Message\ResponseInterface |
|
84 | 84 | * @throws JsonException |
85 | 85 | */ |
86 | 86 | public function actionRequestResetPassword(Request $request, Response $response, $args) |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @param Response $response |
127 | 127 | * @param array $args |
128 | 128 | * |
129 | - * @return mixed |
|
129 | + * @return \Psr\Http\Message\ResponseInterface |
|
130 | 130 | * @throws JsonException |
131 | 131 | */ |
132 | 132 | public function actionResetPassword(Request $request, Response $response, $args) |
@@ -3,12 +3,10 @@ |
||
3 | 3 | |
4 | 4 | use App\Model\User; |
5 | 5 | use App\Common\JsonException; |
6 | - |
|
7 | 6 | use App\Requests\RequestResetPasswordRequest; |
8 | 7 | use App\Requests\ResetPasswordRequest; |
9 | 8 | use App\Requests\UserCreateRequest; |
10 | 9 | use App\Requests\UserUpdateRequest; |
11 | - |
|
12 | 10 | use Slim\Http\Request; |
13 | 11 | use Slim\Http\Response; |
14 | 12 |
@@ -141,7 +141,7 @@ |
||
141 | 141 | $user->setPassword($params['data']['attributes']['password']); |
142 | 142 | $user->removePasswordResetToken(); |
143 | 143 | |
144 | - if($user->save()){ |
|
144 | + if ($user->save()) { |
|
145 | 145 | return $this->renderer->jsonApiRender($response, 204); |
146 | 146 | }; |
147 | 147 | } |
@@ -141,7 +141,7 @@ |
||
141 | 141 | $user->setPassword($params['data']['attributes']['password']); |
142 | 142 | $user->removePasswordResetToken(); |
143 | 143 | |
144 | - if($user->save()){ |
|
144 | + if($user->save()) { |
|
145 | 145 | return $this->renderer->jsonApiRender($response, 204); |
146 | 146 | }; |
147 | 147 | } |
@@ -5,7 +5,8 @@ |
||
5 | 5 | } |
6 | 6 | |
7 | 7 | // Super debug func |
8 | -function prr($value) { |
|
8 | +function prr($value) |
|
9 | +{ |
|
9 | 10 | if (defined('DEBUG_MODE') && DEBUG_MODE == 1) { |
10 | 11 | echo '<pre>'; |
11 | 12 | print_r($value); |
@@ -8,8 +8,7 @@ |
||
8 | 8 | */ |
9 | 9 | public function up() |
10 | 10 | { |
11 | - Capsule::schema()->create('roles', function($table) |
|
12 | - { |
|
11 | + Capsule::schema()->create('roles', function($table) { |
|
13 | 12 | $table->increments('id'); |
14 | 13 | $table->string('name')->unique(); |
15 | 14 | $table->string('description'); |
@@ -2,7 +2,8 @@ |
||
2 | 2 | use App\Model\Role; |
3 | 3 | use App\Model\User; |
4 | 4 | |
5 | -class CreateRolesRightsUsers { |
|
5 | +class CreateRolesRightsUsers |
|
6 | +{ |
|
6 | 7 | public function run() |
7 | 8 | { |
8 | 9 | Role::create([ |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | /** |
164 | 164 | * Register model observers |
165 | 165 | */ |
166 | - private function registerModelObservers(){ |
|
166 | + private function registerModelObservers() { |
|
167 | 167 | $observers = [ |
168 | 168 | Observers\CreatedByAndUpdatedByObserver::class => [ |
169 | 169 | Model\Right::class, |
@@ -178,9 +178,9 @@ discard block |
||
178 | 178 | ] |
179 | 179 | ]; |
180 | 180 | |
181 | - foreach($observers as $observer => $models){ |
|
182 | - foreach($models as $model){ |
|
183 | - call_user_func($model. '::observe', $observer); |
|
181 | + foreach ($observers as $observer => $models) { |
|
182 | + foreach ($models as $model) { |
|
183 | + call_user_func($model.'::observe', $observer); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | } |
@@ -163,7 +163,8 @@ discard block |
||
163 | 163 | /** |
164 | 164 | * Register model observers |
165 | 165 | */ |
166 | - private function registerModelObservers(){ |
|
166 | + private function registerModelObservers() |
|
167 | + { |
|
167 | 168 | $observers = [ |
168 | 169 | Observers\CreatedByAndUpdatedByObserver::class => [ |
169 | 170 | Model\Right::class, |
@@ -178,8 +179,8 @@ discard block |
||
178 | 179 | ] |
179 | 180 | ]; |
180 | 181 | |
181 | - foreach($observers as $observer => $models){ |
|
182 | - foreach($models as $model){ |
|
182 | + foreach($observers as $observer => $models) { |
|
183 | + foreach($models as $model) { |
|
183 | 184 | call_user_func($model. '::observe', $observer); |
184 | 185 | } |
185 | 186 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | */ |
50 | 50 | public static function getUserId() |
51 | 51 | { |
52 | - if(self::checkUser()){ |
|
52 | + if (self::checkUser()) { |
|
53 | 53 | return self::$user->id; |
54 | 54 | } else { |
55 | 55 | return null; |
@@ -8,12 +8,16 @@ discard block |
||
8 | 8 | /** |
9 | 9 | * Forbidden to create new instances |
10 | 10 | */ |
11 | - private function __construct() {} |
|
11 | + private function __construct() |
|
12 | + { |
|
13 | +} |
|
12 | 14 | |
13 | 15 | /** |
14 | 16 | * Forbidden to cloned instances |
15 | 17 | */ |
16 | - private function __clone() {} |
|
18 | + private function __clone() |
|
19 | + { |
|
20 | +} |
|
17 | 21 | |
18 | 22 | /** |
19 | 23 | * @var User |
@@ -49,7 +53,7 @@ discard block |
||
49 | 53 | */ |
50 | 54 | public static function getUserId() |
51 | 55 | { |
52 | - if(self::checkUser()){ |
|
56 | + if(self::checkUser()) { |
|
53 | 57 | return self::$user->id; |
54 | 58 | } else { |
55 | 59 | return null; |
@@ -50,10 +50,12 @@ |
||
50 | 50 | ob_start(); |
51 | 51 | $this->protectedIncludeScope($this->templatePath . $template, $data); |
52 | 52 | $output = ob_get_clean(); |
53 | - } catch(\Throwable $e) { // PHP 7+ |
|
53 | + } catch(\Throwable $e) { |
|
54 | +// PHP 7+ |
|
54 | 55 | ob_end_clean(); |
55 | 56 | throw $e; |
56 | - } catch(\Exception $e) { // PHP < 7 |
|
57 | + } catch(\Exception $e) { |
|
58 | +// PHP < 7 |
|
57 | 59 | ob_end_clean(); |
58 | 60 | throw $e; |
59 | 61 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function __construct($templatePath = '', $attributes = []) |
23 | 23 | { |
24 | - $this->templatePath = rtrim($templatePath, '/\\') . '/'; |
|
24 | + $this->templatePath = rtrim($templatePath, '/\\').'/'; |
|
25 | 25 | $this->attributes = $attributes; |
26 | 26 | } |
27 | 27 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | throw new \InvalidArgumentException('Duplicate template key found'); |
41 | 41 | } |
42 | 42 | |
43 | - if (!is_file($this->templatePath . $template)) { |
|
43 | + if (!is_file($this->templatePath.$template)) { |
|
44 | 44 | throw new \RuntimeException('View cannot render `$template` because the template does not exist'); |
45 | 45 | } |
46 | 46 | |
@@ -48,12 +48,12 @@ discard block |
||
48 | 48 | |
49 | 49 | try { |
50 | 50 | ob_start(); |
51 | - $this->protectedIncludeScope($this->templatePath . $template, $data); |
|
51 | + $this->protectedIncludeScope($this->templatePath.$template, $data); |
|
52 | 52 | $output = ob_get_clean(); |
53 | - } catch(\Throwable $e) { // PHP 7+ |
|
53 | + } catch (\Throwable $e) { // PHP 7+ |
|
54 | 54 | ob_end_clean(); |
55 | 55 | throw $e; |
56 | - } catch(\Exception $e) { // PHP < 7 |
|
56 | + } catch (\Exception $e) { // PHP < 7 |
|
57 | 57 | ob_end_clean(); |
58 | 58 | throw $e; |
59 | 59 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param string $template |
66 | 66 | * @param array $data |
67 | 67 | */ |
68 | - protected function protectedIncludeScope ($template, array $data) |
|
68 | + protected function protectedIncludeScope($template, array $data) |
|
69 | 69 | { |
70 | 70 | extract($data); |
71 | 71 | include $template; |
@@ -196,25 +196,25 @@ |
||
196 | 196 | */ |
197 | 197 | |
198 | 198 | /** |
199 | - * @api {delete} /role/:id Удаление роли |
|
200 | - * @apiName DeleteRole |
|
201 | - * @apiGroup Role |
|
202 | - * |
|
203 | - * @apiDescription Метод для удаления роли. |
|
204 | - * |
|
205 | - * @apiPermission admin |
|
206 | - * |
|
207 | - * @apiParam {Number} id Id роли |
|
208 | - * |
|
209 | - * @apiHeader {String} Authorization Токен. |
|
210 | - * |
|
211 | - * @apiSuccessExample {json} Успешно (204) |
|
212 | - * HTTP/1.1 204 OK |
|
213 | - * |
|
214 | - * @apiUse UnauthorizedError |
|
215 | - * @apiUse StandardErrors |
|
216 | - * @apiUse NotFoundError |
|
217 | - */ |
|
199 | + * @api {delete} /role/:id Удаление роли |
|
200 | + * @apiName DeleteRole |
|
201 | + * @apiGroup Role |
|
202 | + * |
|
203 | + * @apiDescription Метод для удаления роли. |
|
204 | + * |
|
205 | + * @apiPermission admin |
|
206 | + * |
|
207 | + * @apiParam {Number} id Id роли |
|
208 | + * |
|
209 | + * @apiHeader {String} Authorization Токен. |
|
210 | + * |
|
211 | + * @apiSuccessExample {json} Успешно (204) |
|
212 | + * HTTP/1.1 204 OK |
|
213 | + * |
|
214 | + * @apiUse UnauthorizedError |
|
215 | + * @apiUse StandardErrors |
|
216 | + * @apiUse NotFoundError |
|
217 | + */ |
|
218 | 218 | final class RoleSchema extends BaseSchema |
219 | 219 | { |
220 | 220 | protected $resourceType = 'role'; |