Completed
Push — master ( cf2713...aee5ae )
by Sherif
02:07
created
src/Modules/Notifications/Database/Seeds/NotificationsDatabaseSeeder.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -6,15 +6,15 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Modules/Roles/Database/Seeds/RolesDatabaseSeeder.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -6,15 +6,15 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Modules/Roles/Providers/ModuleServiceProvider.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -6,27 +6,27 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Modules/Roles/Providers/RouteServiceProvider.php 2 patches
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -7,73 +7,73 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/Modules/Roles/Http/Resources/Role.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -8,25 +8,25 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Modules/Core/Http/Middleware/UpdateLocaleAndTimezone.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,6 @@
 block discarded – undo
16 16
      *
17 17
      * @param   Session      $session
18 18
      * @param   Auth         $auth
19
-     * @param   ErrorHandler $errorHandler
20 19
      *
21 20
      * @return  void
22 21
      */
Please login to merge, or discard this patch.
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -8,53 +8,53 @@
 block discarded – undo
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   ErrorHandler $errorHandler
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   ErrorHandler $errorHandler
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
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
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) {
Please login to merge, or discard this patch.
src/Modules/Core/Http/Middleware/SetSessions.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -8,56 +8,56 @@
 block discarded – undo
8 8
 
9 9
 class SetSessions
10 10
 {
11
-    protected $app;
12
-    protected $session;
11
+	protected $app;
12
+	protected $session;
13 13
     
14
-    /**
15
-     * Init new object.
16
-     *
17
-     * @param   App      $app
18
-     * @param   Session  $session
19
-     *
20
-     * @return  void
21
-     */
22
-    public function __construct(App $app, Session $session)
23
-    {
24
-        $this->app = $app;
25
-        $this->session = $session;
26
-    }
27
-
28
-    /**
29
-     * Handle an incoming request.
30
-     *
31
-     * @param  \Illuminate\Http\Request  $request
32
-     * @param  \Closure  $next
33
-     * @return mixed
34
-     */
35
-    public function handle($request, Closure $next)
36
-    {
37
-        $this->session->put('time-zone', $request->header('time-zone') ?: 0);
38
-
39
-        $locale = $request->header('locale');
40
-        switch ($locale) {
41
-            case 'en':
42
-                $this->app->setLocale('en');
43
-                $this->session->put('locale', 'en');
44
-                break;
45
-
46
-            case 'ar':
47
-                $this->app->setLocale('ar');
48
-                $this->session->put('locale', 'ar');
49
-                break;
50
-
51
-            case 'all':
52
-                $this->app->setLocale('en');
53
-                $this->session->put('locale', 'all');
54
-                break;
55
-
56
-            default:
57
-                $this->app->setLocale('en');
58
-                $this->session->put('locale', 'en');
59
-                break;
60
-        }
61
-        return $next($request);
62
-    }
14
+	/**
15
+	 * Init new object.
16
+	 *
17
+	 * @param   App      $app
18
+	 * @param   Session  $session
19
+	 *
20
+	 * @return  void
21
+	 */
22
+	public function __construct(App $app, Session $session)
23
+	{
24
+		$this->app = $app;
25
+		$this->session = $session;
26
+	}
27
+
28
+	/**
29
+	 * Handle an incoming request.
30
+	 *
31
+	 * @param  \Illuminate\Http\Request  $request
32
+	 * @param  \Closure  $next
33
+	 * @return mixed
34
+	 */
35
+	public function handle($request, Closure $next)
36
+	{
37
+		$this->session->put('time-zone', $request->header('time-zone') ?: 0);
38
+
39
+		$locale = $request->header('locale');
40
+		switch ($locale) {
41
+			case 'en':
42
+				$this->app->setLocale('en');
43
+				$this->session->put('locale', 'en');
44
+				break;
45
+
46
+			case 'ar':
47
+				$this->app->setLocale('ar');
48
+				$this->session->put('locale', 'ar');
49
+				break;
50
+
51
+			case 'all':
52
+				$this->app->setLocale('en');
53
+				$this->session->put('locale', 'all');
54
+				break;
55
+
56
+			default:
57
+				$this->app->setLocale('en');
58
+				$this->session->put('locale', 'en');
59
+				break;
60
+		}
61
+		return $next($request);
62
+	}
63 63
 }
Please login to merge, or discard this patch.
src/ApiSkeletonServiceProvider.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -6,42 +6,42 @@
 block discarded – undo
6 6
 
7 7
 class ApiSkeletonServiceProvider extends ServiceProvider
8 8
 {
9
-    /**
10
-     * Perform post-registration booting of services.
11
-     *
12
-     * @return void
13
-     */
14
-    public function boot()
15
-    {
16
-        $this->publishes([
17
-            __DIR__.'/Modules'                               => app_path('Modules'),
18
-            __DIR__.'/Modules/Core/Resources/Assets'         => base_path('public/doc/assets'),
19
-            __DIR__.'/../lang'                               => base_path('resources/lang'),
20
-            __DIR__.'/../files/Handler.php'                  => app_path('Exceptions/Handler.php'),
21
-            __DIR__.'/../files/AuthServiceProvider.php'      => app_path('Providers/AuthServiceProvider.php'),
22
-            __DIR__.'/../files/BroadcastServiceProvider.php' => app_path('Providers/BroadcastServiceProvider.php'),
23
-            __DIR__.'/../files/Kernel.php'                   => app_path('Console/Kernel.php'),
24
-            __DIR__.'/../files/HttpKernel.php'               => app_path('Http/Kernel.php'),
25
-            __DIR__.'/../files/channels.php'                 => base_path('routes/channels.php'),
26
-            __DIR__.'/../phpcs.xml'                          => base_path('/phpcs.xml'),
27
-        ]);
9
+	/**
10
+	 * Perform post-registration booting of services.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function boot()
15
+	{
16
+		$this->publishes([
17
+			__DIR__.'/Modules'                               => app_path('Modules'),
18
+			__DIR__.'/Modules/Core/Resources/Assets'         => base_path('public/doc/assets'),
19
+			__DIR__.'/../lang'                               => base_path('resources/lang'),
20
+			__DIR__.'/../files/Handler.php'                  => app_path('Exceptions/Handler.php'),
21
+			__DIR__.'/../files/AuthServiceProvider.php'      => app_path('Providers/AuthServiceProvider.php'),
22
+			__DIR__.'/../files/BroadcastServiceProvider.php' => app_path('Providers/BroadcastServiceProvider.php'),
23
+			__DIR__.'/../files/Kernel.php'                   => app_path('Console/Kernel.php'),
24
+			__DIR__.'/../files/HttpKernel.php'               => app_path('Http/Kernel.php'),
25
+			__DIR__.'/../files/channels.php'                 => base_path('routes/channels.php'),
26
+			__DIR__.'/../phpcs.xml'                          => base_path('/phpcs.xml'),
27
+		]);
28 28
 
29
-        $this->publishes([
30
-            __DIR__.'/../config/skeleton.php' => config_path('skeleton.php'),
31
-            __DIR__.'/../files/auth.php'      => config_path('auth.php'),
32
-        ], 'config');
33
-    }
29
+		$this->publishes([
30
+			__DIR__.'/../config/skeleton.php' => config_path('skeleton.php'),
31
+			__DIR__.'/../files/auth.php'      => config_path('auth.php'),
32
+		], 'config');
33
+	}
34 34
 
35
-    /**
36
-     * Register any package services.
37
-     *
38
-     * @return void
39
-     */
40
-    public function register()
41
-    {
42
-        $this->mergeConfigFrom(
43
-            __DIR__.'/../config/skeleton.php',
44
-            'skeleton'
45
-        );
46
-    }
35
+	/**
36
+	 * Register any package services.
37
+	 *
38
+	 * @return void
39
+	 */
40
+	public function register()
41
+	{
42
+		$this->mergeConfigFrom(
43
+			__DIR__.'/../config/skeleton.php',
44
+			'skeleton'
45
+		);
46
+	}
47 47
 }
Please login to merge, or discard this patch.
src/Modules/Core/Console/Commands/GenerateDoc.php 3 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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)
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      */
84 84
     protected function getRoutes()
85 85
     {
86
-        return collect(\Route::getRoutes())->map(function ($route) {
86
+        return collect(\Route::getRoutes())->map(function($route) {
87 87
             if (strpos($route->uri(), 'api/') !== false) {
88 88
                 return [
89 89
                     'method' => $route->methods()[0],
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
         ];
115 115
 
116 116
 
117
-        if (! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) {
117
+        if ( ! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) {
118 118
             $route['headers']['Authorization'] = 'Bearer {token}';
119 119
         }
120 120
     }
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
         if (count($parameters)) {
163 163
             $className = optional($reflectionMethod->getParameters()[0]->getType())->getName();
164 164
             if ($className) {
165
-                $reflectionClass  = new \ReflectionClass($className);
165
+                $reflectionClass = new \ReflectionClass($className);
166 166
     
167 167
                 if ($reflectionClass->hasMethod('rules')) {
168 168
                     $reflectionMethod = $reflectionClass->getMethod('rules');
Please login to merge, or discard this patch.
Indentation   +235 added lines, -235 removed lines patch added patch discarded remove patch
@@ -8,271 +8,271 @@
 block discarded – undo
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
-        $reflectionClass = new \ReflectionClass('App\Modules\Core\Utl\ErrorHandler');
199
-        foreach ($reflectionClass->getMethods() as $method) {
200
-            $methodName       = $method->name;
201
-            $reflectionMethod = $reflectionClass->getMethod($methodName);
202
-            $body             = $this->getMethodBody($reflectionMethod);
190
+	/**
191
+	 * Generate application errors.
192
+	 *
193
+	 * @return array
194
+	 */
195
+	protected function getErrors()
196
+	{
197
+		$errors          = [];
198
+		$reflectionClass = new \ReflectionClass('App\Modules\Core\Utl\ErrorHandler');
199
+		foreach ($reflectionClass->getMethods() as $method) {
200
+			$methodName       = $method->name;
201
+			$reflectionMethod = $reflectionClass->getMethod($methodName);
202
+			$body             = $this->getMethodBody($reflectionMethod);
203 203
 
204
-            preg_match('/\$error=\[\'status\'=>([^#]+)\,/iU', $body, $match);
204
+			preg_match('/\$error=\[\'status\'=>([^#]+)\,/iU', $body, $match);
205 205
 
206
-            if (count($match)) {
207
-                $errors[$match[1]][] = $methodName;
208
-            }
209
-        }
206
+			if (count($match)) {
207
+				$errors[$match[1]][] = $methodName;
208
+			}
209
+		}
210 210
 
211
-        return $errors;
212
-    }
211
+		return $errors;
212
+	}
213 213
 
214
-    /**
215
-     * Get the given method body code.
216
-     *
217
-     * @param  object $reflectionMethod
218
-     * @return string
219
-     */
220
-    protected function getMethodBody($reflectionMethod)
221
-    {
222
-        $filename   = $reflectionMethod->getFileName();
223
-        $start_line = $reflectionMethod->getStartLine() - 1;
224
-        $end_line   = $reflectionMethod->getEndLine();
225
-        $length     = $end_line - $start_line;
226
-        $source     = file($filename);
227
-        $body       = implode("", array_slice($source, $start_line, $length));
228
-        $body       = trim(preg_replace('/\s+/', '', $body));
214
+	/**
215
+	 * Get the given method body code.
216
+	 *
217
+	 * @param  object $reflectionMethod
218
+	 * @return string
219
+	 */
220
+	protected function getMethodBody($reflectionMethod)
221
+	{
222
+		$filename   = $reflectionMethod->getFileName();
223
+		$start_line = $reflectionMethod->getStartLine() - 1;
224
+		$end_line   = $reflectionMethod->getEndLine();
225
+		$length     = $end_line - $start_line;
226
+		$source     = file($filename);
227
+		$body       = implode("", array_slice($source, $start_line, $length));
228
+		$body       = trim(preg_replace('/\s+/', '', $body));
229 229
 
230
-        return $body;
231
-    }
230
+		return $body;
231
+	}
232 232
 
233
-    /**
234
-     * Get example object of all availble models.
235
-     *
236
-     * @param  string $modelName
237
-     * @param  array  $docData
238
-     * @return string
239
-     */
240
-    protected function getModels($modelName, &$docData, $reflectionClass)
241
-    {
242
-        if ($modelName && ! Arr::has($docData['models'], $modelName)) {
243
-            $modelClass = get_class(call_user_func_array("\Core::{$modelName}", [])->model);
244
-            $model      = factory($modelClass)->make();
233
+	/**
234
+	 * Get example object of all availble models.
235
+	 *
236
+	 * @param  string $modelName
237
+	 * @param  array  $docData
238
+	 * @return string
239
+	 */
240
+	protected function getModels($modelName, &$docData, $reflectionClass)
241
+	{
242
+		if ($modelName && ! Arr::has($docData['models'], $modelName)) {
243
+			$modelClass = get_class(call_user_func_array("\Core::{$modelName}", [])->model);
244
+			$model      = factory($modelClass)->make();
245 245
 
246
-            $property = $reflectionClass->getProperty('modelResource');
247
-            $property->setAccessible(true);
248
-            $modelResource = $property->getValue(\App::make($reflectionClass->getName()));
249
-            $modelResource = new $modelResource($model);
250
-            $modelArr      = $modelResource->toArray([]);
246
+			$property = $reflectionClass->getProperty('modelResource');
247
+			$property->setAccessible(true);
248
+			$modelResource = $property->getValue(\App::make($reflectionClass->getName()));
249
+			$modelResource = new $modelResource($model);
250
+			$modelArr      = $modelResource->toArray([]);
251 251
 
252
-            foreach ($modelArr as $key => $attr) {
253
-                if (is_object($attr) && $attr->resource instanceof \Illuminate\Http\Resources\MissingValue) {
254
-                    unset($modelArr[$key]);
255
-                }
256
-            }
252
+			foreach ($modelArr as $key => $attr) {
253
+				if (is_object($attr) && $attr->resource instanceof \Illuminate\Http\Resources\MissingValue) {
254
+					unset($modelArr[$key]);
255
+				}
256
+			}
257 257
 
258
-            $docData['models'][$modelName] = json_encode($modelArr, JSON_PRETTY_PRINT);
259
-        }
260
-    }
258
+			$docData['models'][$modelName] = json_encode($modelArr, JSON_PRETTY_PRINT);
259
+		}
260
+	}
261 261
 
262
-    /**
263
-     * Get the route response object type.
264
-     *
265
-     * @param  string $modelName
266
-     * @param  string $method
267
-     * @param  string $returnDocBlock
268
-     * @return array
269
-     */
270
-    protected function getResponseObject($modelName, $method, $returnDocBlock)
271
-    {
272
-        $config    = \CoreConfig::getConfig();
273
-        $relations = Arr::has($config['relations'], $modelName) ? Arr::has($config['relations'][$modelName], $method) ? $config['relations'][$modelName] : false : false;
274
-        $modelName = call_user_func_array("\Core::{$returnDocBlock}", []) ? $returnDocBlock : $modelName;
262
+	/**
263
+	 * Get the route response object type.
264
+	 *
265
+	 * @param  string $modelName
266
+	 * @param  string $method
267
+	 * @param  string $returnDocBlock
268
+	 * @return array
269
+	 */
270
+	protected function getResponseObject($modelName, $method, $returnDocBlock)
271
+	{
272
+		$config    = \CoreConfig::getConfig();
273
+		$relations = Arr::has($config['relations'], $modelName) ? Arr::has($config['relations'][$modelName], $method) ? $config['relations'][$modelName] : false : false;
274
+		$modelName = call_user_func_array("\Core::{$returnDocBlock}", []) ? $returnDocBlock : $modelName;
275 275
 
276
-        return $relations ? [$modelName => $relations && $relations[$method] ? $relations[$method] : []] : false;
277
-    }
276
+		return $relations ? [$modelName => $relations && $relations[$method] ? $relations[$method] : []] : false;
277
+	}
278 278
 }
Please login to merge, or discard this patch.