@@ -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 | }); |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $factory->define(App\Modules\Core\Setting::class, function (Faker\Generator $faker) { |
4 | - return [ |
|
5 | - 'name' => $faker->randomElement(['Company Name', 'Title', 'Header Image']), |
|
6 | - 'value' => $faker->word(), |
|
7 | - 'key' => $faker->word(), |
|
8 | - 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
|
9 | - 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
|
10 | - ]; |
|
4 | + return [ |
|
5 | + 'name' => $faker->randomElement(['Company Name', 'Title', 'Header Image']), |
|
6 | + 'value' => $faker->word(), |
|
7 | + 'key' => $faker->word(), |
|
8 | + 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
|
9 | + 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
|
10 | + ]; |
|
11 | 11 | }); |
@@ -9,43 +9,43 @@ |
||
9 | 9 | |
10 | 10 | class SetRelations |
11 | 11 | { |
12 | - protected $arr; |
|
13 | - protected $route; |
|
14 | - protected $config; |
|
12 | + protected $arr; |
|
13 | + protected $route; |
|
14 | + protected $config; |
|
15 | 15 | |
16 | - /** |
|
17 | - * Init new object. |
|
18 | - * |
|
19 | - * @param Route $route |
|
20 | - * @param Arr $arr |
|
21 | - * @param Config $config |
|
22 | - * |
|
23 | - * @return void |
|
24 | - */ |
|
25 | - public function __construct(Route $route, Arr $arr, Config $config) |
|
26 | - { |
|
27 | - $this->arr = $arr; |
|
28 | - $this->route = $route; |
|
29 | - $this->config = $config->getConfig(); |
|
30 | - } |
|
16 | + /** |
|
17 | + * Init new object. |
|
18 | + * |
|
19 | + * @param Route $route |
|
20 | + * @param Arr $arr |
|
21 | + * @param Config $config |
|
22 | + * |
|
23 | + * @return void |
|
24 | + */ |
|
25 | + public function __construct(Route $route, Arr $arr, Config $config) |
|
26 | + { |
|
27 | + $this->arr = $arr; |
|
28 | + $this->route = $route; |
|
29 | + $this->config = $config->getConfig(); |
|
30 | + } |
|
31 | 31 | |
32 | - /** |
|
33 | - * Handle an incoming request. |
|
34 | - * |
|
35 | - * @param \Illuminate\Http\Request $request |
|
36 | - * @param \Closure $next |
|
37 | - * @return mixed |
|
38 | - */ |
|
39 | - public function handle($request, Closure $next) |
|
40 | - { |
|
41 | - $routeActions = explode('@', $this->route->currentRouteAction()); |
|
42 | - $modelName = explode('\\', $routeActions[0]); |
|
43 | - $modelName = lcfirst(str_replace('Controller', '', end($modelName))); |
|
44 | - $route = explode('@', $this->route->currentRouteAction())[1]; |
|
45 | - $route = $route !== 'index' ? $route : 'list'; |
|
46 | - $relations = $this->arr->get($this->config['relations'], $modelName, false); |
|
47 | - $request->relations = $relations && isset($relations[$route]) ? $relations[$route] : []; |
|
32 | + /** |
|
33 | + * Handle an incoming request. |
|
34 | + * |
|
35 | + * @param \Illuminate\Http\Request $request |
|
36 | + * @param \Closure $next |
|
37 | + * @return mixed |
|
38 | + */ |
|
39 | + public function handle($request, Closure $next) |
|
40 | + { |
|
41 | + $routeActions = explode('@', $this->route->currentRouteAction()); |
|
42 | + $modelName = explode('\\', $routeActions[0]); |
|
43 | + $modelName = lcfirst(str_replace('Controller', '', end($modelName))); |
|
44 | + $route = explode('@', $this->route->currentRouteAction())[1]; |
|
45 | + $route = $route !== 'index' ? $route : 'list'; |
|
46 | + $relations = $this->arr->get($this->config['relations'], $modelName, false); |
|
47 | + $request->relations = $relations && isset($relations[$route]) ? $relations[$route] : []; |
|
48 | 48 | |
49 | - return $next($request); |
|
50 | - } |
|
49 | + return $next($request); |
|
50 | + } |
|
51 | 51 | } |
@@ -13,7 +13,7 @@ |
||
13 | 13 | |
14 | 14 | Route::group(['prefix' => 'reports'], function () { |
15 | 15 | |
16 | - Route::get('/', 'ReportController@index'); |
|
17 | - Route::get('/{id}', 'ReportController@find'); |
|
18 | - Route::post('get/{reportName}', 'ReportController@getReport'); |
|
16 | + Route::get('/', 'ReportController@index'); |
|
17 | + Route::get('/{id}', 'ReportController@find'); |
|
18 | + Route::post('get/{reportName}', 'ReportController@getReport'); |
|
19 | 19 | }); |
@@ -1,9 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $factory->define(App\Modules\Roles\Role::class, function (Faker\Generator $faker) { |
4 | - return [ |
|
5 | - 'name' => $faker->unique->word(), |
|
6 | - 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
|
7 | - 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
|
8 | - ]; |
|
4 | + return [ |
|
5 | + 'name' => $faker->unique->word(), |
|
6 | + 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
|
7 | + 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
|
8 | + ]; |
|
9 | 9 | }); |
@@ -6,26 +6,26 @@ |
||
6 | 6 | |
7 | 7 | class AssignPermissions extends FormRequest |
8 | 8 | { |
9 | - /** |
|
10 | - * Determine if the user is authorized to make this request. |
|
11 | - * |
|
12 | - * @return bool |
|
13 | - */ |
|
14 | - public function authorize() |
|
15 | - { |
|
16 | - return true; |
|
17 | - } |
|
9 | + /** |
|
10 | + * Determine if the user is authorized to make this request. |
|
11 | + * |
|
12 | + * @return bool |
|
13 | + */ |
|
14 | + public function authorize() |
|
15 | + { |
|
16 | + return true; |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * Get the validation rules that apply to the request. |
|
21 | - * |
|
22 | - * @return array |
|
23 | - */ |
|
24 | - public function rules() |
|
25 | - { |
|
26 | - return [ |
|
27 | - 'permission_ids' => 'required|exists:permissions,id', |
|
28 | - 'role_id' => 'required|array|exists:roles,id' |
|
29 | - ]; |
|
30 | - } |
|
19 | + /** |
|
20 | + * Get the validation rules that apply to the request. |
|
21 | + * |
|
22 | + * @return array |
|
23 | + */ |
|
24 | + public function rules() |
|
25 | + { |
|
26 | + return [ |
|
27 | + 'permission_ids' => 'required|exists:permissions,id', |
|
28 | + 'role_id' => 'required|array|exists:roles,id' |
|
29 | + ]; |
|
30 | + } |
|
31 | 31 | } |
@@ -6,26 +6,26 @@ |
||
6 | 6 | |
7 | 7 | class UpdateRole extends FormRequest |
8 | 8 | { |
9 | - /** |
|
10 | - * Determine if the user is authorized to make this request. |
|
11 | - * |
|
12 | - * @return bool |
|
13 | - */ |
|
14 | - public function authorize() |
|
15 | - { |
|
16 | - return true; |
|
17 | - } |
|
9 | + /** |
|
10 | + * Determine if the user is authorized to make this request. |
|
11 | + * |
|
12 | + * @return bool |
|
13 | + */ |
|
14 | + public function authorize() |
|
15 | + { |
|
16 | + return true; |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * Get the validation rules that apply to the request. |
|
21 | - * |
|
22 | - * @return array |
|
23 | - */ |
|
24 | - public function rules() |
|
25 | - { |
|
26 | - return [ |
|
27 | - 'id' => 'required|exists:roles,id', |
|
28 | - 'name' => 'required|string|max:100|unique:roles,name,'.$this->get('id') |
|
29 | - ]; |
|
30 | - } |
|
19 | + /** |
|
20 | + * Get the validation rules that apply to the request. |
|
21 | + * |
|
22 | + * @return array |
|
23 | + */ |
|
24 | + public function rules() |
|
25 | + { |
|
26 | + return [ |
|
27 | + 'id' => 'required|exists:roles,id', |
|
28 | + 'name' => 'required|string|max:100|unique:roles,name,'.$this->get('id') |
|
29 | + ]; |
|
30 | + } |
|
31 | 31 | } |
@@ -6,25 +6,25 @@ |
||
6 | 6 | |
7 | 7 | class InsertRole extends FormRequest |
8 | 8 | { |
9 | - /** |
|
10 | - * Determine if the user is authorized to make this request. |
|
11 | - * |
|
12 | - * @return bool |
|
13 | - */ |
|
14 | - public function authorize() |
|
15 | - { |
|
16 | - return true; |
|
17 | - } |
|
9 | + /** |
|
10 | + * Determine if the user is authorized to make this request. |
|
11 | + * |
|
12 | + * @return bool |
|
13 | + */ |
|
14 | + public function authorize() |
|
15 | + { |
|
16 | + return true; |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * Get the validation rules that apply to the request. |
|
21 | - * |
|
22 | - * @return array |
|
23 | - */ |
|
24 | - public function rules() |
|
25 | - { |
|
26 | - return [ |
|
27 | - 'name' => 'required|string|max:100|unique:roles,name,'.$this->get('id') |
|
28 | - ]; |
|
29 | - } |
|
19 | + /** |
|
20 | + * Get the validation rules that apply to the request. |
|
21 | + * |
|
22 | + * @return array |
|
23 | + */ |
|
24 | + public function rules() |
|
25 | + { |
|
26 | + return [ |
|
27 | + 'name' => 'required|string|max:100|unique:roles,name,'.$this->get('id') |
|
28 | + ]; |
|
29 | + } |
|
30 | 30 | } |
@@ -8,25 +8,25 @@ |
||
8 | 8 | |
9 | 9 | class Role extends JsonResource |
10 | 10 | { |
11 | - /** |
|
12 | - * Transform the resource into an array. |
|
13 | - * |
|
14 | - * @param Request $request |
|
15 | - * @return array |
|
16 | - */ |
|
17 | - public function toArray($request) |
|
18 | - { |
|
19 | - if (! $this->resource) { |
|
20 | - return []; |
|
21 | - } |
|
11 | + /** |
|
12 | + * Transform the resource into an array. |
|
13 | + * |
|
14 | + * @param Request $request |
|
15 | + * @return array |
|
16 | + */ |
|
17 | + public function toArray($request) |
|
18 | + { |
|
19 | + if (! $this->resource) { |
|
20 | + return []; |
|
21 | + } |
|
22 | 22 | |
23 | - return [ |
|
24 | - 'id' => $this->id, |
|
25 | - 'name' => $this->name, |
|
26 | - 'users' => UserResource::collection($this->whenLoaded('users')), |
|
27 | - 'permissions' => PermissionResource::collection($this->whenLoaded('permissions')), |
|
28 | - 'created_at' => $this->created_at, |
|
29 | - 'updated_at' => $this->updated_at, |
|
30 | - ]; |
|
31 | - } |
|
23 | + return [ |
|
24 | + 'id' => $this->id, |
|
25 | + 'name' => $this->name, |
|
26 | + 'users' => UserResource::collection($this->whenLoaded('users')), |
|
27 | + 'permissions' => PermissionResource::collection($this->whenLoaded('permissions')), |
|
28 | + 'created_at' => $this->created_at, |
|
29 | + 'updated_at' => $this->updated_at, |
|
30 | + ]; |
|
31 | + } |
|
32 | 32 | } |