@@ -6,15 +6,15 @@ |
||
| 6 | 6 | |
| 7 | 7 | class NotificationsDatabaseSeeder extends Seeder |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Run the database seeds. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function run() |
|
| 15 | - { |
|
| 16 | - $this->call(ClearDataSeeder::class); |
|
| 17 | - $this->call(NotificationsTableSeeder::class); |
|
| 18 | - $this->call(AssignRelationsSeeder::class); |
|
| 19 | - } |
|
| 9 | + /** |
|
| 10 | + * Run the database seeds. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function run() |
|
| 15 | + { |
|
| 16 | + $this->call(ClearDataSeeder::class); |
|
| 17 | + $this->call(NotificationsTableSeeder::class); |
|
| 18 | + $this->call(AssignRelationsSeeder::class); |
|
| 19 | + } |
|
| 20 | 20 | } |
@@ -6,15 +6,15 @@ |
||
| 6 | 6 | |
| 7 | 7 | class RolesDatabaseSeeder extends Seeder |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Run the database seeds. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function run() |
|
| 15 | - { |
|
| 16 | - $this->call(ClearDataSeeder::class); |
|
| 17 | - $this->call(RolesTableSeeder::class); |
|
| 18 | - $this->call(AssignRelationsSeeder::class); |
|
| 19 | - } |
|
| 9 | + /** |
|
| 10 | + * Run the database seeds. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function run() |
|
| 15 | + { |
|
| 16 | + $this->call(ClearDataSeeder::class); |
|
| 17 | + $this->call(RolesTableSeeder::class); |
|
| 18 | + $this->call(AssignRelationsSeeder::class); |
|
| 19 | + } |
|
| 20 | 20 | } |
@@ -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', 'roles'); |
|
| 17 | - $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'roles'); |
|
| 9 | + /** |
|
| 10 | + * Bootstrap the module services. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function boot() |
|
| 15 | + { |
|
| 16 | + $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'roles'); |
|
| 17 | + $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'roles'); |
|
| 18 | 18 | |
| 19 | - $this->loadMigrationsFrom(module_path('roles', 'Database/Migrations', 'app')); |
|
| 20 | - $this->loadFactoriesFrom(module_path('roles', 'Database/Factories', 'app')); |
|
| 21 | - } |
|
| 19 | + $this->loadMigrationsFrom(module_path('roles', 'Database/Migrations', 'app')); |
|
| 20 | + $this->loadFactoriesFrom(module_path('roles', '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\Roles\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\Roles\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('roles', '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('roles', '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('roles', '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('roles', 'Routes/api.php', 'app'); |
|
| 77 | + }); |
|
| 78 | + } |
|
| 79 | 79 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | Route::group([ |
| 55 | 55 | 'middleware' => 'web', |
| 56 | 56 | 'namespace' => $this->namespace, |
| 57 | - ], function ($router) { |
|
| 57 | + ], function($router) { |
|
| 58 | 58 | require module_path('roles', 'Routes/web.php', 'app'); |
| 59 | 59 | }); |
| 60 | 60 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | 'middleware' => 'api', |
| 73 | 73 | 'namespace' => $this->namespace, |
| 74 | 74 | 'prefix' => 'api', |
| 75 | - ], function ($router) { |
|
| 75 | + ], function($router) { |
|
| 76 | 76 | require module_path('roles', 'Routes/api.php', 'app'); |
| 77 | 77 | }); |
| 78 | 78 | } |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | public function toArray($request) |
| 19 | 19 | { |
| 20 | - if (! $this->resource) { |
|
| 20 | + if ( ! $this->resource) { |
|
| 21 | 21 | return []; |
| 22 | 22 | } |
| 23 | 23 | |
@@ -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 | } |
@@ -47,7 +47,7 @@ |
||
| 47 | 47 | |
| 48 | 48 | if ($timezone && $timezone !== $user->timezone) { |
| 49 | 49 | $user->timezone = $timezone; |
| 50 | - $update = true; |
|
| 50 | + $update = true; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | if ($update) { |
@@ -16,7 +16,6 @@ |
||
| 16 | 16 | * |
| 17 | 17 | * @param Session $session |
| 18 | 18 | * @param Auth $auth |
| 19 | - * @param Errors $errors |
|
| 20 | 19 | * |
| 21 | 20 | * @return void |
| 22 | 21 | */ |
@@ -8,53 +8,53 @@ |
||
| 8 | 8 | |
| 9 | 9 | class UpdateLocaleAndTimezone |
| 10 | 10 | { |
| 11 | - protected $session; |
|
| 12 | - protected $auth; |
|
| 11 | + protected $session; |
|
| 12 | + protected $auth; |
|
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Init new object. |
|
| 16 | - * |
|
| 17 | - * @param Session $session |
|
| 18 | - * @param Auth $auth |
|
| 19 | - * @param Errors $errors |
|
| 20 | - * |
|
| 21 | - * @return void |
|
| 22 | - */ |
|
| 23 | - public function __construct(Session $session, Auth $auth) |
|
| 24 | - { |
|
| 25 | - $this->session = $session; |
|
| 26 | - $this->auth = $auth; |
|
| 27 | - } |
|
| 14 | + /** |
|
| 15 | + * Init new object. |
|
| 16 | + * |
|
| 17 | + * @param Session $session |
|
| 18 | + * @param Auth $auth |
|
| 19 | + * @param Errors $errors |
|
| 20 | + * |
|
| 21 | + * @return void |
|
| 22 | + */ |
|
| 23 | + public function __construct(Session $session, Auth $auth) |
|
| 24 | + { |
|
| 25 | + $this->session = $session; |
|
| 26 | + $this->auth = $auth; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Handle an incoming request. |
|
| 31 | - * |
|
| 32 | - * @param \Illuminate\Http\Request $request |
|
| 33 | - * @param \Closure $next |
|
| 34 | - * @return mixed |
|
| 35 | - */ |
|
| 36 | - public function handle($request, Closure $next) |
|
| 37 | - { |
|
| 38 | - $update = false; |
|
| 39 | - $user = $this->auth->user(); |
|
| 40 | - if ($user) { |
|
| 41 | - $locale = $this->session->get('locale'); |
|
| 42 | - $timezone = $this->session->get('time-zone'); |
|
| 43 | - if ($locale && $locale !== 'all' && $locale !== $user->locale) { |
|
| 44 | - $user->locale = $locale; |
|
| 45 | - $update = true; |
|
| 46 | - } |
|
| 29 | + /** |
|
| 30 | + * Handle an incoming request. |
|
| 31 | + * |
|
| 32 | + * @param \Illuminate\Http\Request $request |
|
| 33 | + * @param \Closure $next |
|
| 34 | + * @return mixed |
|
| 35 | + */ |
|
| 36 | + public function handle($request, Closure $next) |
|
| 37 | + { |
|
| 38 | + $update = false; |
|
| 39 | + $user = $this->auth->user(); |
|
| 40 | + if ($user) { |
|
| 41 | + $locale = $this->session->get('locale'); |
|
| 42 | + $timezone = $this->session->get('time-zone'); |
|
| 43 | + if ($locale && $locale !== 'all' && $locale !== $user->locale) { |
|
| 44 | + $user->locale = $locale; |
|
| 45 | + $update = true; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - if ($timezone && $timezone !== $user->timezone) { |
|
| 49 | - $user->timezone = $timezone; |
|
| 50 | - $update = true; |
|
| 51 | - } |
|
| 48 | + if ($timezone && $timezone !== $user->timezone) { |
|
| 49 | + $user->timezone = $timezone; |
|
| 50 | + $update = true; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - if ($update) { |
|
| 54 | - $user->save(); |
|
| 55 | - } |
|
| 56 | - } |
|
| 53 | + if ($update) { |
|
| 54 | + $user->save(); |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - return $next($request); |
|
| 59 | - } |
|
| 58 | + return $next($request); |
|
| 59 | + } |
|
| 60 | 60 | } |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | /** |
| 208 | 208 | * Get the given method body code. |
| 209 | 209 | * |
| 210 | - * @param object $reflectionMethod |
|
| 210 | + * @param \ReflectionMethod $reflectionMethod |
|
| 211 | 211 | * @return string |
| 212 | 212 | */ |
| 213 | 213 | protected function getMethodBody($reflectionMethod) |
@@ -228,6 +228,7 @@ discard block |
||
| 228 | 228 | * |
| 229 | 229 | * @param string $modelName |
| 230 | 230 | * @param array $docData |
| 231 | + * @param \ReflectionClass $reflectionClass |
|
| 231 | 232 | * @return string |
| 232 | 233 | */ |
| 233 | 234 | protected function getModels($modelName, &$docData, $reflectionClass) |
@@ -8,275 +8,275 @@ |
||
| 8 | 8 | |
| 9 | 9 | class GenerateDoc extends Command |
| 10 | 10 | { |
| 11 | - /** |
|
| 12 | - * The name and signature of the console command. |
|
| 13 | - * |
|
| 14 | - * @var string |
|
| 15 | - */ |
|
| 16 | - protected $signature = 'doc:generate'; |
|
| 11 | + /** |
|
| 12 | + * The name and signature of the console command. |
|
| 13 | + * |
|
| 14 | + * @var string |
|
| 15 | + */ |
|
| 16 | + protected $signature = 'doc:generate'; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * The console command description. |
|
| 20 | - * |
|
| 21 | - * @var string |
|
| 22 | - */ |
|
| 23 | - protected $description = 'Generate api documentation'; |
|
| 18 | + /** |
|
| 19 | + * The console command description. |
|
| 20 | + * |
|
| 21 | + * @var string |
|
| 22 | + */ |
|
| 23 | + protected $description = 'Generate api documentation'; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @var ReprotService |
|
| 27 | - */ |
|
| 28 | - protected $reportService; |
|
| 25 | + /** |
|
| 26 | + * @var ReprotService |
|
| 27 | + */ |
|
| 28 | + protected $reportService; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Init new object. |
|
| 32 | - * |
|
| 33 | - * @return void |
|
| 34 | - */ |
|
| 35 | - public function __construct(ReportService $reportService) |
|
| 36 | - { |
|
| 37 | - $this->reportService = $reportService; |
|
| 38 | - parent::__construct(); |
|
| 39 | - } |
|
| 30 | + /** |
|
| 31 | + * Init new object. |
|
| 32 | + * |
|
| 33 | + * @return void |
|
| 34 | + */ |
|
| 35 | + public function __construct(ReportService $reportService) |
|
| 36 | + { |
|
| 37 | + $this->reportService = $reportService; |
|
| 38 | + parent::__construct(); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * Execute the console command. |
|
| 43 | - * |
|
| 44 | - * @return mixed |
|
| 45 | - */ |
|
| 46 | - public function handle() |
|
| 47 | - { |
|
| 48 | - $docData = []; |
|
| 49 | - $docData['models'] = []; |
|
| 50 | - $routes = $this->getRoutes(); |
|
| 51 | - foreach ($routes as $route) { |
|
| 52 | - if ($route) { |
|
| 53 | - $actoinArray = explode('@', $route['action']); |
|
| 54 | - if (Arr::get($actoinArray, 1, false)) { |
|
| 55 | - $controller = $actoinArray[0]; |
|
| 56 | - $method = $actoinArray[1]; |
|
| 57 | - $route['name'] = $method !== 'index' ? $method : 'list'; |
|
| 41 | + /** |
|
| 42 | + * Execute the console command. |
|
| 43 | + * |
|
| 44 | + * @return mixed |
|
| 45 | + */ |
|
| 46 | + public function handle() |
|
| 47 | + { |
|
| 48 | + $docData = []; |
|
| 49 | + $docData['models'] = []; |
|
| 50 | + $routes = $this->getRoutes(); |
|
| 51 | + foreach ($routes as $route) { |
|
| 52 | + if ($route) { |
|
| 53 | + $actoinArray = explode('@', $route['action']); |
|
| 54 | + if (Arr::get($actoinArray, 1, false)) { |
|
| 55 | + $controller = $actoinArray[0]; |
|
| 56 | + $method = $actoinArray[1]; |
|
| 57 | + $route['name'] = $method !== 'index' ? $method : 'list'; |
|
| 58 | 58 | |
| 59 | - $reflectionClass = new \ReflectionClass($controller); |
|
| 60 | - $reflectionMethod = $reflectionClass->getMethod($method); |
|
| 61 | - $classProperties = $reflectionClass->getDefaultProperties(); |
|
| 62 | - $skipLoginCheck = Arr::get($classProperties, 'skipLoginCheck', false); |
|
| 63 | - $modelName = explode('\\', $controller); |
|
| 64 | - $modelName = lcfirst(str_replace('Controller', '', end($modelName))); |
|
| 59 | + $reflectionClass = new \ReflectionClass($controller); |
|
| 60 | + $reflectionMethod = $reflectionClass->getMethod($method); |
|
| 61 | + $classProperties = $reflectionClass->getDefaultProperties(); |
|
| 62 | + $skipLoginCheck = Arr::get($classProperties, 'skipLoginCheck', false); |
|
| 63 | + $modelName = explode('\\', $controller); |
|
| 64 | + $modelName = lcfirst(str_replace('Controller', '', end($modelName))); |
|
| 65 | 65 | |
| 66 | - $this->processDocBlock($route, $reflectionMethod); |
|
| 67 | - $this->getHeaders($route, $method, $skipLoginCheck); |
|
| 68 | - $this->getPostData($route, $reflectionMethod); |
|
| 66 | + $this->processDocBlock($route, $reflectionMethod); |
|
| 67 | + $this->getHeaders($route, $method, $skipLoginCheck); |
|
| 68 | + $this->getPostData($route, $reflectionMethod); |
|
| 69 | 69 | |
| 70 | - $route['response'] = $this->getResponseObject($modelName, $route['name'], $route['returnDocBlock']); |
|
| 70 | + $route['response'] = $this->getResponseObject($modelName, $route['name'], $route['returnDocBlock']); |
|
| 71 | 71 | |
| 72 | - $module = $route['prefix']; |
|
| 73 | - $module = \Str::camel(str_replace('/', '_', str_replace('api', '', $module))); |
|
| 74 | - $docData['modules'][$module][] = $route; |
|
| 72 | + $module = $route['prefix']; |
|
| 73 | + $module = \Str::camel(str_replace('/', '_', str_replace('api', '', $module))); |
|
| 74 | + $docData['modules'][$module][] = $route; |
|
| 75 | 75 | |
| 76 | - $this->getModels($modelName, $docData, $reflectionClass); |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - } |
|
| 76 | + $this->getModels($modelName, $docData, $reflectionClass); |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - $docData['errors'] = $this->getErrors(); |
|
| 82 | - $docData['reports'] = $this->reportService->all(); |
|
| 83 | - \File::put(app_path('Modules/Core/Resources/api.json'), json_encode($docData)); |
|
| 84 | - } |
|
| 81 | + $docData['errors'] = $this->getErrors(); |
|
| 82 | + $docData['reports'] = $this->reportService->all(); |
|
| 83 | + \File::put(app_path('Modules/Core/Resources/api.json'), json_encode($docData)); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * Get list of all registered routes. |
|
| 88 | - * |
|
| 89 | - * @return collection |
|
| 90 | - */ |
|
| 91 | - protected function getRoutes() |
|
| 92 | - { |
|
| 93 | - return collect(\Route::getRoutes())->map(function ($route) { |
|
| 94 | - if (strpos($route->uri(), 'api/') !== false) { |
|
| 95 | - return [ |
|
| 96 | - 'method' => $route->methods()[0], |
|
| 97 | - 'uri' => $route->uri(), |
|
| 98 | - 'action' => $route->getActionName(), |
|
| 99 | - 'prefix' => $route->getPrefix() |
|
| 100 | - ]; |
|
| 101 | - } |
|
| 102 | - return false; |
|
| 103 | - })->all(); |
|
| 104 | - } |
|
| 86 | + /** |
|
| 87 | + * Get list of all registered routes. |
|
| 88 | + * |
|
| 89 | + * @return collection |
|
| 90 | + */ |
|
| 91 | + protected function getRoutes() |
|
| 92 | + { |
|
| 93 | + return collect(\Route::getRoutes())->map(function ($route) { |
|
| 94 | + if (strpos($route->uri(), 'api/') !== false) { |
|
| 95 | + return [ |
|
| 96 | + 'method' => $route->methods()[0], |
|
| 97 | + 'uri' => $route->uri(), |
|
| 98 | + 'action' => $route->getActionName(), |
|
| 99 | + 'prefix' => $route->getPrefix() |
|
| 100 | + ]; |
|
| 101 | + } |
|
| 102 | + return false; |
|
| 103 | + })->all(); |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * Generate headers for the given route. |
|
| 108 | - * |
|
| 109 | - * @param array &$route |
|
| 110 | - * @param string $method |
|
| 111 | - * @param array $skipLoginCheck |
|
| 112 | - * @return void |
|
| 113 | - */ |
|
| 114 | - protected function getHeaders(&$route, $method, $skipLoginCheck) |
|
| 115 | - { |
|
| 116 | - $route['headers'] = [ |
|
| 117 | - 'Accept' => 'application/json', |
|
| 118 | - 'Content-Type' => 'application/json', |
|
| 119 | - 'locale' => 'The language of the returned data: ar, en or all.', |
|
| 120 | - 'time-zone' => 'Your locale time zone', |
|
| 121 | - ]; |
|
| 106 | + /** |
|
| 107 | + * Generate headers for the given route. |
|
| 108 | + * |
|
| 109 | + * @param array &$route |
|
| 110 | + * @param string $method |
|
| 111 | + * @param array $skipLoginCheck |
|
| 112 | + * @return void |
|
| 113 | + */ |
|
| 114 | + protected function getHeaders(&$route, $method, $skipLoginCheck) |
|
| 115 | + { |
|
| 116 | + $route['headers'] = [ |
|
| 117 | + 'Accept' => 'application/json', |
|
| 118 | + 'Content-Type' => 'application/json', |
|
| 119 | + 'locale' => 'The language of the returned data: ar, en or all.', |
|
| 120 | + 'time-zone' => 'Your locale time zone', |
|
| 121 | + ]; |
|
| 122 | 122 | |
| 123 | 123 | |
| 124 | - if (! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) { |
|
| 125 | - $route['headers']['Authorization'] = 'Bearer {token}'; |
|
| 126 | - } |
|
| 127 | - } |
|
| 124 | + if (! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) { |
|
| 125 | + $route['headers']['Authorization'] = 'Bearer {token}'; |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | - /** |
|
| 130 | - * Generate description and params for the given route |
|
| 131 | - * based on the docblock. |
|
| 132 | - * |
|
| 133 | - * @param array &$route |
|
| 134 | - * @param \ReflectionMethod $reflectionMethod |
|
| 135 | - * @return void |
|
| 136 | - */ |
|
| 137 | - protected function processDocBlock(&$route, $reflectionMethod) |
|
| 138 | - { |
|
| 139 | - $factory = \phpDocumentor\Reflection\DocBlockFactory::createInstance(); |
|
| 140 | - $docblock = $factory->create($reflectionMethod->getDocComment()); |
|
| 141 | - $route['description'] = trim(preg_replace('/\s+/', ' ', $docblock->getSummary())); |
|
| 142 | - $params = $docblock->getTagsByName('param'); |
|
| 143 | - $route['returnDocBlock'] = $docblock->getTagsByName('return')[0]->getType()->getFqsen()->getName(); |
|
| 129 | + /** |
|
| 130 | + * Generate description and params for the given route |
|
| 131 | + * based on the docblock. |
|
| 132 | + * |
|
| 133 | + * @param array &$route |
|
| 134 | + * @param \ReflectionMethod $reflectionMethod |
|
| 135 | + * @return void |
|
| 136 | + */ |
|
| 137 | + protected function processDocBlock(&$route, $reflectionMethod) |
|
| 138 | + { |
|
| 139 | + $factory = \phpDocumentor\Reflection\DocBlockFactory::createInstance(); |
|
| 140 | + $docblock = $factory->create($reflectionMethod->getDocComment()); |
|
| 141 | + $route['description'] = trim(preg_replace('/\s+/', ' ', $docblock->getSummary())); |
|
| 142 | + $params = $docblock->getTagsByName('param'); |
|
| 143 | + $route['returnDocBlock'] = $docblock->getTagsByName('return')[0]->getType()->getFqsen()->getName(); |
|
| 144 | 144 | |
| 145 | - foreach ($params as $param) { |
|
| 146 | - $name = $param->getVariableName(); |
|
| 147 | - if ($name !== 'request') { |
|
| 148 | - $route['parametars'][$param->getVariableName()] = $param->getDescription()->render(); |
|
| 149 | - } |
|
| 150 | - } |
|
| 145 | + foreach ($params as $param) { |
|
| 146 | + $name = $param->getVariableName(); |
|
| 147 | + if ($name !== 'request') { |
|
| 148 | + $route['parametars'][$param->getVariableName()] = $param->getDescription()->render(); |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - if ($route['name'] === 'list') { |
|
| 153 | - $route['parametars']['perPage'] = 'perPage'; |
|
| 154 | - $route['parametars']['sortBy'] = 'sortBy'; |
|
| 155 | - $route['parametars']['desc'] = 'desc'; |
|
| 156 | - } |
|
| 157 | - } |
|
| 152 | + if ($route['name'] === 'list') { |
|
| 153 | + $route['parametars']['perPage'] = 'perPage'; |
|
| 154 | + $route['parametars']['sortBy'] = 'sortBy'; |
|
| 155 | + $route['parametars']['desc'] = 'desc'; |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - /** |
|
| 160 | - * Generate post body for the given route. |
|
| 161 | - * |
|
| 162 | - * @param array &$route |
|
| 163 | - * @param \ReflectionMethod $reflectionMethod |
|
| 164 | - * @return void |
|
| 165 | - */ |
|
| 166 | - protected function getPostData(&$route, $reflectionMethod) |
|
| 167 | - { |
|
| 168 | - $parameters = $reflectionMethod->getParameters(); |
|
| 169 | - if (count($parameters)) { |
|
| 170 | - $className = optional($reflectionMethod->getParameters()[0]->getType())->getName(); |
|
| 171 | - if ($className) { |
|
| 172 | - $reflectionClass = new \ReflectionClass($className); |
|
| 159 | + /** |
|
| 160 | + * Generate post body for the given route. |
|
| 161 | + * |
|
| 162 | + * @param array &$route |
|
| 163 | + * @param \ReflectionMethod $reflectionMethod |
|
| 164 | + * @return void |
|
| 165 | + */ |
|
| 166 | + protected function getPostData(&$route, $reflectionMethod) |
|
| 167 | + { |
|
| 168 | + $parameters = $reflectionMethod->getParameters(); |
|
| 169 | + if (count($parameters)) { |
|
| 170 | + $className = optional($reflectionMethod->getParameters()[0]->getType())->getName(); |
|
| 171 | + if ($className) { |
|
| 172 | + $reflectionClass = new \ReflectionClass($className); |
|
| 173 | 173 | |
| 174 | - if ($reflectionClass->hasMethod('rules')) { |
|
| 175 | - $reflectionMethod = $reflectionClass->getMethod('rules'); |
|
| 176 | - $route['body'] = $reflectionMethod->invoke(new $className); |
|
| 174 | + if ($reflectionClass->hasMethod('rules')) { |
|
| 175 | + $reflectionMethod = $reflectionClass->getMethod('rules'); |
|
| 176 | + $route['body'] = $reflectionMethod->invoke(new $className); |
|
| 177 | 177 | |
| 178 | - foreach ($route['body'] as &$rule) { |
|
| 179 | - if (strpos($rule, 'unique')) { |
|
| 180 | - $rule = substr($rule, 0, strpos($rule, 'unique') + 6); |
|
| 181 | - } elseif (strpos($rule, 'exists')) { |
|
| 182 | - $rule = substr($rule, 0, strpos($rule, 'exists') - 1); |
|
| 183 | - } |
|
| 184 | - } |
|
| 185 | - } |
|
| 186 | - } |
|
| 187 | - } |
|
| 188 | - } |
|
| 178 | + foreach ($route['body'] as &$rule) { |
|
| 179 | + if (strpos($rule, 'unique')) { |
|
| 180 | + $rule = substr($rule, 0, strpos($rule, 'unique') + 6); |
|
| 181 | + } elseif (strpos($rule, 'exists')) { |
|
| 182 | + $rule = substr($rule, 0, strpos($rule, 'exists') - 1); |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | + } |
|
| 186 | + } |
|
| 187 | + } |
|
| 188 | + } |
|
| 189 | 189 | |
| 190 | - /** |
|
| 191 | - * Generate application errors. |
|
| 192 | - * |
|
| 193 | - * @return array |
|
| 194 | - */ |
|
| 195 | - protected function getErrors() |
|
| 196 | - { |
|
| 197 | - $errors = []; |
|
| 198 | - foreach (\Module::all() as $module) { |
|
| 199 | - $nameSpace = 'App\\Modules\\' . $module['basename'] ; |
|
| 200 | - $class = $nameSpace . '\\Errors\\' . $module['basename'] . 'Errors'; |
|
| 201 | - $reflectionClass = new \ReflectionClass($class); |
|
| 202 | - foreach ($reflectionClass->getMethods() as $method) { |
|
| 203 | - $methodName = $method->name; |
|
| 204 | - $reflectionMethod = $reflectionClass->getMethod($methodName); |
|
| 205 | - $body = $this->getMethodBody($reflectionMethod); |
|
| 190 | + /** |
|
| 191 | + * Generate application errors. |
|
| 192 | + * |
|
| 193 | + * @return array |
|
| 194 | + */ |
|
| 195 | + protected function getErrors() |
|
| 196 | + { |
|
| 197 | + $errors = []; |
|
| 198 | + foreach (\Module::all() as $module) { |
|
| 199 | + $nameSpace = 'App\\Modules\\' . $module['basename'] ; |
|
| 200 | + $class = $nameSpace . '\\Errors\\' . $module['basename'] . 'Errors'; |
|
| 201 | + $reflectionClass = new \ReflectionClass($class); |
|
| 202 | + foreach ($reflectionClass->getMethods() as $method) { |
|
| 203 | + $methodName = $method->name; |
|
| 204 | + $reflectionMethod = $reflectionClass->getMethod($methodName); |
|
| 205 | + $body = $this->getMethodBody($reflectionMethod); |
|
| 206 | 206 | |
| 207 | - preg_match('/\$error=\[\'status\'=>([^#]+)\,/iU', $body, $match); |
|
| 207 | + preg_match('/\$error=\[\'status\'=>([^#]+)\,/iU', $body, $match); |
|
| 208 | 208 | |
| 209 | - if (count($match)) { |
|
| 210 | - $errors[$match[1]][] = $methodName; |
|
| 211 | - } |
|
| 212 | - } |
|
| 213 | - } |
|
| 209 | + if (count($match)) { |
|
| 210 | + $errors[$match[1]][] = $methodName; |
|
| 211 | + } |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | - return $errors; |
|
| 216 | - } |
|
| 215 | + return $errors; |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | - /** |
|
| 219 | - * Get the given method body code. |
|
| 220 | - * |
|
| 221 | - * @param object $reflectionMethod |
|
| 222 | - * @return string |
|
| 223 | - */ |
|
| 224 | - protected function getMethodBody($reflectionMethod) |
|
| 225 | - { |
|
| 226 | - $filename = $reflectionMethod->getFileName(); |
|
| 227 | - $start_line = $reflectionMethod->getStartLine() - 1; |
|
| 228 | - $end_line = $reflectionMethod->getEndLine(); |
|
| 229 | - $length = $end_line - $start_line; |
|
| 230 | - $source = file($filename); |
|
| 231 | - $body = implode("", array_slice($source, $start_line, $length)); |
|
| 232 | - $body = trim(preg_replace('/\s+/', '', $body)); |
|
| 218 | + /** |
|
| 219 | + * Get the given method body code. |
|
| 220 | + * |
|
| 221 | + * @param object $reflectionMethod |
|
| 222 | + * @return string |
|
| 223 | + */ |
|
| 224 | + protected function getMethodBody($reflectionMethod) |
|
| 225 | + { |
|
| 226 | + $filename = $reflectionMethod->getFileName(); |
|
| 227 | + $start_line = $reflectionMethod->getStartLine() - 1; |
|
| 228 | + $end_line = $reflectionMethod->getEndLine(); |
|
| 229 | + $length = $end_line - $start_line; |
|
| 230 | + $source = file($filename); |
|
| 231 | + $body = implode("", array_slice($source, $start_line, $length)); |
|
| 232 | + $body = trim(preg_replace('/\s+/', '', $body)); |
|
| 233 | 233 | |
| 234 | - return $body; |
|
| 235 | - } |
|
| 234 | + return $body; |
|
| 235 | + } |
|
| 236 | 236 | |
| 237 | - /** |
|
| 238 | - * Get example object of all availble models. |
|
| 239 | - * |
|
| 240 | - * @param string $modelName |
|
| 241 | - * @param array $docData |
|
| 242 | - * @return string |
|
| 243 | - */ |
|
| 244 | - protected function getModels($modelName, &$docData, $reflectionClass) |
|
| 245 | - { |
|
| 246 | - if ($modelName && ! Arr::has($docData['models'], $modelName)) { |
|
| 247 | - $modelClass = get_class(call_user_func_array("\Core::{$modelName}", [])->model); |
|
| 248 | - $model = factory($modelClass)->make(); |
|
| 237 | + /** |
|
| 238 | + * Get example object of all availble models. |
|
| 239 | + * |
|
| 240 | + * @param string $modelName |
|
| 241 | + * @param array $docData |
|
| 242 | + * @return string |
|
| 243 | + */ |
|
| 244 | + protected function getModels($modelName, &$docData, $reflectionClass) |
|
| 245 | + { |
|
| 246 | + if ($modelName && ! Arr::has($docData['models'], $modelName)) { |
|
| 247 | + $modelClass = get_class(call_user_func_array("\Core::{$modelName}", [])->model); |
|
| 248 | + $model = factory($modelClass)->make(); |
|
| 249 | 249 | |
| 250 | - $property = $reflectionClass->getProperty('modelResource'); |
|
| 251 | - $property->setAccessible(true); |
|
| 252 | - $modelResource = $property->getValue(\App::make($reflectionClass->getName())); |
|
| 253 | - $modelResource = new $modelResource($model); |
|
| 254 | - $modelArr = $modelResource->toArray([]); |
|
| 250 | + $property = $reflectionClass->getProperty('modelResource'); |
|
| 251 | + $property->setAccessible(true); |
|
| 252 | + $modelResource = $property->getValue(\App::make($reflectionClass->getName())); |
|
| 253 | + $modelResource = new $modelResource($model); |
|
| 254 | + $modelArr = $modelResource->toArray([]); |
|
| 255 | 255 | |
| 256 | - foreach ($modelArr as $key => $attr) { |
|
| 257 | - if (is_object($attr) && $attr->resource instanceof \Illuminate\Http\Resources\MissingValue) { |
|
| 258 | - unset($modelArr[$key]); |
|
| 259 | - } |
|
| 260 | - } |
|
| 256 | + foreach ($modelArr as $key => $attr) { |
|
| 257 | + if (is_object($attr) && $attr->resource instanceof \Illuminate\Http\Resources\MissingValue) { |
|
| 258 | + unset($modelArr[$key]); |
|
| 259 | + } |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | - $docData['models'][$modelName] = json_encode($modelArr, JSON_PRETTY_PRINT); |
|
| 263 | - } |
|
| 264 | - } |
|
| 262 | + $docData['models'][$modelName] = json_encode($modelArr, JSON_PRETTY_PRINT); |
|
| 263 | + } |
|
| 264 | + } |
|
| 265 | 265 | |
| 266 | - /** |
|
| 267 | - * Get the route response object type. |
|
| 268 | - * |
|
| 269 | - * @param string $modelName |
|
| 270 | - * @param string $method |
|
| 271 | - * @param string $returnDocBlock |
|
| 272 | - * @return array |
|
| 273 | - */ |
|
| 274 | - protected function getResponseObject($modelName, $method, $returnDocBlock) |
|
| 275 | - { |
|
| 276 | - $config = \CoreConfig::getConfig(); |
|
| 277 | - $relations = Arr::has($config['relations'], $modelName) ? Arr::has($config['relations'][$modelName], $method) ? $config['relations'][$modelName] : false : false; |
|
| 278 | - $modelName = call_user_func_array("\Core::{$returnDocBlock}", []) ? $returnDocBlock : $modelName; |
|
| 266 | + /** |
|
| 267 | + * Get the route response object type. |
|
| 268 | + * |
|
| 269 | + * @param string $modelName |
|
| 270 | + * @param string $method |
|
| 271 | + * @param string $returnDocBlock |
|
| 272 | + * @return array |
|
| 273 | + */ |
|
| 274 | + protected function getResponseObject($modelName, $method, $returnDocBlock) |
|
| 275 | + { |
|
| 276 | + $config = \CoreConfig::getConfig(); |
|
| 277 | + $relations = Arr::has($config['relations'], $modelName) ? Arr::has($config['relations'][$modelName], $method) ? $config['relations'][$modelName] : false : false; |
|
| 278 | + $modelName = call_user_func_array("\Core::{$returnDocBlock}", []) ? $returnDocBlock : $modelName; |
|
| 279 | 279 | |
| 280 | - return $relations ? [$modelName => $relations && $relations[$method] ? $relations[$method] : []] : false; |
|
| 281 | - } |
|
| 280 | + return $relations ? [$modelName => $relations && $relations[$method] ? $relations[$method] : []] : false; |
|
| 281 | + } |
|
| 282 | 282 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | protected function getRoutes() |
| 92 | 92 | { |
| 93 | - return collect(\Route::getRoutes())->map(function ($route) { |
|
| 93 | + return collect(\Route::getRoutes())->map(function($route) { |
|
| 94 | 94 | if (strpos($route->uri(), 'api/') !== false) { |
| 95 | 95 | return [ |
| 96 | 96 | 'method' => $route->methods()[0], |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | ]; |
| 122 | 122 | |
| 123 | 123 | |
| 124 | - if (! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) { |
|
| 124 | + if ( ! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) { |
|
| 125 | 125 | $route['headers']['Authorization'] = 'Bearer {token}'; |
| 126 | 126 | } |
| 127 | 127 | } |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | if (count($parameters)) { |
| 170 | 170 | $className = optional($reflectionMethod->getParameters()[0]->getType())->getName(); |
| 171 | 171 | if ($className) { |
| 172 | - $reflectionClass = new \ReflectionClass($className); |
|
| 172 | + $reflectionClass = new \ReflectionClass($className); |
|
| 173 | 173 | |
| 174 | 174 | if ($reflectionClass->hasMethod('rules')) { |
| 175 | 175 | $reflectionMethod = $reflectionClass->getMethod('rules'); |
@@ -196,8 +196,8 @@ discard block |
||
| 196 | 196 | { |
| 197 | 197 | $errors = []; |
| 198 | 198 | foreach (\Module::all() as $module) { |
| 199 | - $nameSpace = 'App\\Modules\\' . $module['basename'] ; |
|
| 200 | - $class = $nameSpace . '\\Errors\\' . $module['basename'] . 'Errors'; |
|
| 199 | + $nameSpace = 'App\\Modules\\'.$module['basename']; |
|
| 200 | + $class = $nameSpace.'\\Errors\\'.$module['basename'].'Errors'; |
|
| 201 | 201 | $reflectionClass = new \ReflectionClass($class); |
| 202 | 202 | foreach ($reflectionClass->getMethods() as $method) { |
| 203 | 203 | $methodName = $method->name; |
@@ -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 | }); |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -$factory->define(App\Modules\Core\Setting::class, function (Faker\Generator $faker) { |
|
| 3 | +$factory->define(App\Modules\Core\Setting::class, function(Faker\Generator $faker) { |
|
| 4 | 4 | return [ |
| 5 | 5 | 'name' => $faker->randomElement(['Company Name', 'Title', 'Header Image']), |
| 6 | 6 | 'value' => $faker->word(), |
@@ -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 | } |