Completed
Push — master ( 4b6f70...bf5864 )
by Sherif
02:04
created
src/Modules/Reporting/Database/Seeds/ReportsTableSeeder.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -6,40 +6,40 @@
 block discarded – undo
6 6
 
7 7
 class ReportsTableSeeder extends Seeder
8 8
 {
9
-    /**
10
-     * Run the database seeds.
11
-     *
12
-     * @return void
13
-     */
14
-    public function run()
15
-    {
16
-        /**
17
-         * Insert the permissions related to settings table.
18
-         */
19
-        \DB::table('permissions')->insert(
20
-            [
21
-                /**
22
-                 * Reports model permissions.
23
-                 */
24
-                [
25
-                'name'       => 'index',
26
-                'model'      => 'report',
27
-                'created_at' => \DB::raw('NOW()'),
28
-                'updated_at' => \DB::raw('NOW()')
29
-                ],
30
-                [
31
-                'name'       => 'show',
32
-                'model'      => 'report',
33
-                'created_at' => \DB::raw('NOW()'),
34
-                'updated_at' => \DB::raw('NOW()')
35
-                ],
36
-                [
37
-                'name'       => 'admin_count',
38
-                'model'      => 'report',
39
-                'created_at' => \DB::raw('NOW()'),
40
-                'updated_at' => \DB::raw('NOW()')
41
-                ]
42
-            ]
43
-        );
44
-    }
9
+	/**
10
+	 * Run the database seeds.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function run()
15
+	{
16
+		/**
17
+		 * Insert the permissions related to settings table.
18
+		 */
19
+		\DB::table('permissions')->insert(
20
+			[
21
+				/**
22
+				 * Reports model permissions.
23
+				 */
24
+				[
25
+				'name'       => 'index',
26
+				'model'      => 'report',
27
+				'created_at' => \DB::raw('NOW()'),
28
+				'updated_at' => \DB::raw('NOW()')
29
+				],
30
+				[
31
+				'name'       => 'show',
32
+				'model'      => 'report',
33
+				'created_at' => \DB::raw('NOW()'),
34
+				'updated_at' => \DB::raw('NOW()')
35
+				],
36
+				[
37
+				'name'       => 'admin_count',
38
+				'model'      => 'report',
39
+				'created_at' => \DB::raw('NOW()'),
40
+				'updated_at' => \DB::raw('NOW()')
41
+				]
42
+			]
43
+		);
44
+	}
45 45
 }
Please login to merge, or discard this patch.
src/Modules/Reporting/Routes/api.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
 
14 14
 Route::group(['prefix' => 'reports'], function () {
15 15
         
16
-    Route::get('/', 'ReportController@index');
17
-    Route::get('/{id}', 'ReportController@show');
18
-    Route::post('get/{reportName}', 'ReportController@getReport');
16
+	Route::get('/', 'ReportController@index');
17
+	Route::get('/{id}', 'ReportController@show');
18
+	Route::post('get/{reportName}', 'ReportController@getReport');
19 19
 });
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 |
12 12
 */
13 13
 
14
-Route::group(['prefix' => 'reports'], function () {
14
+Route::group(['prefix' => 'reports'], function() {
15 15
         
16 16
     Route::get('/', 'ReportController@index');
17 17
     Route::get('/{id}', 'ReportController@show');
Please login to merge, or discard this patch.
Http/Controllers/PushNotificationDeviceController.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -8,46 +8,46 @@
 block discarded – undo
8 8
 
9 9
 class PushNotificationDeviceController extends BaseApiController
10 10
 {
11
-    /**
12
-     * Path of the sotre form request.
13
-     *
14
-     * @var string
15
-     */
16
-    protected $storeFormRequest = 'App\Modules\Users\Http\PushNotificationDevices\StorePushNotificationDevice';
11
+	/**
12
+	 * Path of the sotre form request.
13
+	 *
14
+	 * @var string
15
+	 */
16
+	protected $storeFormRequest = 'App\Modules\Users\Http\PushNotificationDevices\StorePushNotificationDevice';
17 17
 
18
-    /**
19
-     * Path of the model resource
20
-     *
21
-     * @var string
22
-     */
23
-    protected $modelResource = 'App\Modules\PushNotificationDevices\Http\Resources\PushNotificationDevice';
18
+	/**
19
+	 * Path of the model resource
20
+	 *
21
+	 * @var string
22
+	 */
23
+	protected $modelResource = 'App\Modules\PushNotificationDevices\Http\Resources\PushNotificationDevice';
24 24
 
25
-    /**
26
-     * List of all route actions that the base api controller
27
-     * will skip permissions check for them.
28
-     * @var array
29
-     */
30
-    protected $skipPermissionCheck = ['registerDevice'];
25
+	/**
26
+	 * List of all route actions that the base api controller
27
+	 * will skip permissions check for them.
28
+	 * @var array
29
+	 */
30
+	protected $skipPermissionCheck = ['registerDevice'];
31 31
 
32
-    /**
33
-     * Init new object.
34
-     *
35
-     * @param   PushNotificationDeviceService $service
36
-     * @return  void
37
-     */
38
-    public function __construct(PushNotificationDeviceService $service)
39
-    {
40
-        parent::__construct($service);
41
-    }
32
+	/**
33
+	 * Init new object.
34
+	 *
35
+	 * @param   PushNotificationDeviceService $service
36
+	 * @return  void
37
+	 */
38
+	public function __construct(PushNotificationDeviceService $service)
39
+	{
40
+		parent::__construct($service);
41
+	}
42 42
 
43
-    /**
44
-     * Register the given device to the logged in user.
45
-     *
46
-     * @param RegisterDevice $request
47
-     * @return \Illuminate\Http\Response
48
-     */
49
-    public function registerDevice(RegisterDevice $request)
50
-    {
51
-        return new $this->modelResource($this->service->registerDevice($request->all()));
52
-    }
43
+	/**
44
+	 * Register the given device to the logged in user.
45
+	 *
46
+	 * @param RegisterDevice $request
47
+	 * @return \Illuminate\Http\Response
48
+	 */
49
+	public function registerDevice(RegisterDevice $request)
50
+	{
51
+		return new $this->modelResource($this->service->registerDevice($request->all()));
52
+	}
53 53
 }
Please login to merge, or discard this patch.
src/Modules/Core/Database/Seeds/SettingsTableSeeder.php 1 patch
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -6,52 +6,52 @@
 block discarded – undo
6 6
 
7 7
 class SettingsTableSeeder extends Seeder
8 8
 {
9
-    /**
10
-     * Run the database seeds.
11
-     *
12
-     * @return void
13
-     */
14
-    public function run()
15
-    {
16
-        /**
17
-         * Insert the permissions related to settings table.
18
-         */
19
-        \DB::table('permissions')->insert(
20
-            [
21
-                /**
22
-                 * Settings model permissions.
23
-                 */
24
-                [
25
-                'name'       => 'index',
26
-                'model'      => 'setting',
27
-                'created_at' => \DB::raw('NOW()'),
28
-                'updated_at' => \DB::raw('NOW()')
29
-                ],
30
-                [
31
-                'name'       => 'show',
32
-                'model'      => 'setting',
33
-                'created_at' => \DB::raw('NOW()'),
34
-                'updated_at' => \DB::raw('NOW()')
35
-                ],
36
-                [
37
-                'name'       => 'update',
38
-                'model'      => 'setting',
39
-                'created_at' => \DB::raw('NOW()'),
40
-                'updated_at' => \DB::raw('NOW()')
41
-                ],
42
-                [
43
-                'name'       => 'destroy',
44
-                'model'      => 'setting',
45
-                'created_at' => \DB::raw('NOW()'),
46
-                'updated_at' => \DB::raw('NOW()')
47
-                ],
48
-                [
49
-                'name'       => 'saveMany',
50
-                'model'      => 'setting',
51
-                'created_at' => \DB::raw('NOW()'),
52
-                'updated_at' => \DB::raw('NOW()')
53
-                ]
54
-            ]
55
-        );
56
-    }
9
+	/**
10
+	 * Run the database seeds.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function run()
15
+	{
16
+		/**
17
+		 * Insert the permissions related to settings table.
18
+		 */
19
+		\DB::table('permissions')->insert(
20
+			[
21
+				/**
22
+				 * Settings model permissions.
23
+				 */
24
+				[
25
+				'name'       => 'index',
26
+				'model'      => 'setting',
27
+				'created_at' => \DB::raw('NOW()'),
28
+				'updated_at' => \DB::raw('NOW()')
29
+				],
30
+				[
31
+				'name'       => 'show',
32
+				'model'      => 'setting',
33
+				'created_at' => \DB::raw('NOW()'),
34
+				'updated_at' => \DB::raw('NOW()')
35
+				],
36
+				[
37
+				'name'       => 'update',
38
+				'model'      => 'setting',
39
+				'created_at' => \DB::raw('NOW()'),
40
+				'updated_at' => \DB::raw('NOW()')
41
+				],
42
+				[
43
+				'name'       => 'destroy',
44
+				'model'      => 'setting',
45
+				'created_at' => \DB::raw('NOW()'),
46
+				'updated_at' => \DB::raw('NOW()')
47
+				],
48
+				[
49
+				'name'       => 'saveMany',
50
+				'model'      => 'setting',
51
+				'created_at' => \DB::raw('NOW()'),
52
+				'updated_at' => \DB::raw('NOW()')
53
+				]
54
+			]
55
+		);
56
+	}
57 57
 }
Please login to merge, or discard this patch.
src/Modules/Core/Http/Controllers/SettingController.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -9,39 +9,39 @@
 block discarded – undo
9 9
 
10 10
 class SettingController extends BaseApiController
11 11
 {
12
-    /**
13
-     * Path of the sotre form request.
14
-     *
15
-     * @var string
16
-     */
17
-    protected $storeFormRequest = 'App\Modules\Core\Http\Requests\StoreSetting';
12
+	/**
13
+	 * Path of the sotre form request.
14
+	 *
15
+	 * @var string
16
+	 */
17
+	protected $storeFormRequest = 'App\Modules\Core\Http\Requests\StoreSetting';
18 18
 
19
-    /**
20
-     * Path of the model resource
21
-     *
22
-     * @var string
23
-     */
24
-    protected $modelResource = 'App\Modules\Core\Http\Resources\Setting';
19
+	/**
20
+	 * Path of the model resource
21
+	 *
22
+	 * @var string
23
+	 */
24
+	protected $modelResource = 'App\Modules\Core\Http\Resources\Setting';
25 25
 
26
-    /**
27
-     * Init new object.
28
-     *
29
-     * @param   SettingService $service
30
-     * @return  void
31
-     */
32
-    public function __construct(SettingService $service)
33
-    {
34
-        parent::__construct($service);
35
-    }
26
+	/**
27
+	 * Init new object.
28
+	 *
29
+	 * @param   SettingService $service
30
+	 * @return  void
31
+	 */
32
+	public function __construct(SettingService $service)
33
+	{
34
+		parent::__construct($service);
35
+	}
36 36
 
37
-    /**
38
-     * Save list of settings.
39
-     *
40
-     * @param Request $request
41
-     * @return \Illuminate\Http\Response
42
-     */
43
-    public function saveMany(Request $request)
44
-    {
45
-        return new GeneralResource($this->service->saveMany($request->all()));
46
-    }
37
+	/**
38
+	 * Save list of settings.
39
+	 *
40
+	 * @param Request $request
41
+	 * @return \Illuminate\Http\Response
42
+	 */
43
+	public function saveMany(Request $request)
44
+	{
45
+		return new GeneralResource($this->service->saveMany($request->all()));
46
+	}
47 47
 }
Please login to merge, or discard this patch.
src/Modules/Core/Http/Requests/StoreSetting.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -6,25 +6,25 @@
 block discarded – undo
6 6
 
7 7
 class StoreSetting 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
-            'value' => 'required|string'
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
+			'value' => 'required|string'
28
+		];
29
+	}
30 30
 }
Please login to merge, or discard this patch.
src/Modules/Core/Routes/api.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 |
12 12
 */
13 13
 
14
-Route::group(['prefix' => 'settings'], function () {
14
+Route::group(['prefix' => 'settings'], function() {
15 15
 
16 16
     Route::get('/', 'SettingController@index');
17 17
     Route::get('{id}', 'SettingController@show');
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -13,8 +13,8 @@
 block discarded – undo
13 13
 
14 14
 Route::group(['prefix' => 'settings'], function () {
15 15
 
16
-    Route::get('/', 'SettingController@index');
17
-    Route::get('{id}', 'SettingController@show');
18
-    Route::patch('{id}', 'SettingController@update');
19
-    Route::post('save/many', 'SettingController@saveMany');
16
+	Route::get('/', 'SettingController@index');
17
+	Route::get('{id}', 'SettingController@show');
18
+	Route::patch('{id}', 'SettingController@update');
19
+	Route::post('save/many', 'SettingController@saveMany');
20 20
 });
Please login to merge, or discard this patch.
src/Modules/Core/Console/Commands/GenerateDocCommand.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   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      */
93 93
     protected function getRoutes()
94 94
     {
95
-        return collect(\Route::getRoutes())->map(function ($route) {
95
+        return collect(\Route::getRoutes())->map(function($route) {
96 96
             if (strpos($route->uri(), 'api/') !== false) {
97 97
                 return [
98 98
                     'method' => $route->methods()[0],
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         ];
124 124
 
125 125
 
126
-        if (! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) {
126
+        if ( ! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) {
127 127
             $route['headers']['Authorization'] = 'Bearer {token}';
128 128
         }
129 129
     }
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
         if ($className) {
182 182
             $reflectionClass  = new \ReflectionClass($className);
183 183
         } elseif (in_array($reflectionMethod->getName(), ['store', 'update'])) {
184
-            $className = 'App\\Modules\\' . ucfirst($module) . '\\Http\\Requests\\Store'  . ucfirst($modelName);
184
+            $className = 'App\\Modules\\'.ucfirst($module).'\\Http\\Requests\\Store'.ucfirst($modelName);
185 185
             $reflectionClass  = new \ReflectionClass($className);
186 186
         }
187 187
 
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
     {
209 209
         $errors = [];
210 210
         foreach (\Module::all() as $module) {
211
-            $nameSpace = 'App\\Modules\\' . $module['basename'];
212
-            $class = $nameSpace . '\\Errors\\'  . $module['basename'] . 'Errors';
211
+            $nameSpace = 'App\\Modules\\'.$module['basename'];
212
+            $class = $nameSpace.'\\Errors\\'.$module['basename'].'Errors';
213 213
             $reflectionClass = new \ReflectionClass($class);
214 214
             foreach ($reflectionClass->getMethods() as $method) {
215 215
                 $methodName       = $method->name;
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
     {
258 258
         if ($modelName && ! Arr::has($docData['models'], $modelName)) {
259 259
             $repo = call_user_func_array("\Core::{$modelName}", []);
260
-            if (! $repo) {
260
+            if ( ! $repo) {
261 261
                 return;
262 262
             }
263 263
             
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
                 $body = $this->getMethodBody($reflectionMethod);
276 276
                 foreach ($relationMethods as $relationMethod) {
277 277
                     $relation = $reflectionMethod->getName();
278
-                    if (strpos($body, '$this->' . $relationMethod) && $relation !== 'morphedByMany') {
278
+                    if (strpos($body, '$this->'.$relationMethod) && $relation !== 'morphedByMany') {
279 279
                         $relations[] = $relation;
280 280
                         break;
281 281
                     }
Please login to merge, or discard this patch.
Indentation   +302 added lines, -302 removed lines patch added patch discarded remove patch
@@ -8,308 +8,308 @@
 block discarded – undo
8 8
 
9 9
 class GenerateDocCommand extends Command
10 10
 {
11
-    /**
12
-     * The name and signature of the console command.
13
-     *
14
-     * @var string
15
-     */
16
-    protected $signature = 'doc:generate';
17
-
18
-    /**
19
-     * The console command description.
20
-     *
21
-     * @var string
22
-     */
23
-    protected $description = 'Generate api documentation';
24
-
25
-    /**
26
-     * @var ReprotService
27
-     */
28
-    protected $reportService;
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
-    }
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
-                    $prefix = $route['prefix'];
56
-                    $module = \Str::camel(str_replace('/', '_', str_replace('api', '', $prefix)));
57
-                    if ($prefix === 'telescope') {
58
-                        continue;
59
-                    }
60
-
61
-                    $controller       = $actoinArray[0];
62
-                    $method           = $actoinArray[1];
63
-                    $route['name']    = $method;
64
-                    $reflectionClass  = new \ReflectionClass($controller);
65
-                    $reflectionMethod = $reflectionClass->getMethod($method);
66
-                    $classProperties  = $reflectionClass->getDefaultProperties();
67
-                    $skipLoginCheck   = Arr::get($classProperties, 'skipLoginCheck', false);
68
-                    $modelName        = explode('\\', $controller);
69
-                    $modelName        = lcfirst(str_replace('Controller', '', end($modelName)));
70
-
71
-                    $this->processDocBlock($route, $reflectionMethod);
72
-                    $this->getHeaders($route, $method, $skipLoginCheck);
73
-                    $this->getPostData($route, $reflectionMethod, explode('\\', $reflectionClass->getName())[2], $modelName);
74
-
75
-                    $route['response'] = $this->getResponseObject($modelName, $route['name'], $route['returnDocBlock']);
76
-                    $docData['modules'][$module][] = $route;
77
-
78
-                    $this->getModels($modelName, $docData, $reflectionClass);
79
-                }
80
-            }
81
-        }
11
+	/**
12
+	 * The name and signature of the console command.
13
+	 *
14
+	 * @var string
15
+	 */
16
+	protected $signature = 'doc:generate';
17
+
18
+	/**
19
+	 * The console command description.
20
+	 *
21
+	 * @var string
22
+	 */
23
+	protected $description = 'Generate api documentation';
24
+
25
+	/**
26
+	 * @var ReprotService
27
+	 */
28
+	protected $reportService;
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
+	}
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
+					$prefix = $route['prefix'];
56
+					$module = \Str::camel(str_replace('/', '_', str_replace('api', '', $prefix)));
57
+					if ($prefix === 'telescope') {
58
+						continue;
59
+					}
60
+
61
+					$controller       = $actoinArray[0];
62
+					$method           = $actoinArray[1];
63
+					$route['name']    = $method;
64
+					$reflectionClass  = new \ReflectionClass($controller);
65
+					$reflectionMethod = $reflectionClass->getMethod($method);
66
+					$classProperties  = $reflectionClass->getDefaultProperties();
67
+					$skipLoginCheck   = Arr::get($classProperties, 'skipLoginCheck', false);
68
+					$modelName        = explode('\\', $controller);
69
+					$modelName        = lcfirst(str_replace('Controller', '', end($modelName)));
70
+
71
+					$this->processDocBlock($route, $reflectionMethod);
72
+					$this->getHeaders($route, $method, $skipLoginCheck);
73
+					$this->getPostData($route, $reflectionMethod, explode('\\', $reflectionClass->getName())[2], $modelName);
74
+
75
+					$route['response'] = $this->getResponseObject($modelName, $route['name'], $route['returnDocBlock']);
76
+					$docData['modules'][$module][] = $route;
77
+
78
+					$this->getModels($modelName, $docData, $reflectionClass);
79
+				}
80
+			}
81
+		}
82 82
         
83
-        $docData['errors']  = $this->getErrors();
84
-        $docData['reports'] = $this->reportService->all();
85
-        \File::put(app_path('Modules/Core/Resources/api.json'), json_encode($docData));
86
-    }
87
-
88
-    /**
89
-     * Get list of all registered routes.
90
-     *
91
-     * @return collection
92
-     */
93
-    protected function getRoutes()
94
-    {
95
-        return collect(\Route::getRoutes())->map(function ($route) {
96
-            if (strpos($route->uri(), 'api/') !== false) {
97
-                return [
98
-                    'method' => $route->methods()[0],
99
-                    'uri'    => $route->uri(),
100
-                    'action' => $route->getActionName(),
101
-                    'prefix' => $route->getPrefix()
102
-                ];
103
-            }
104
-            return false;
105
-        })->all();
106
-    }
107
-
108
-    /**
109
-     * Generate headers for the given route.
110
-     *
111
-     * @param  array  &$route
112
-     * @param  string $method
113
-     * @param  array  $skipLoginCheck
114
-     * @return void
115
-     */
116
-    protected function getHeaders(&$route, $method, $skipLoginCheck)
117
-    {
118
-        $route['headers'] = [
119
-        'Accept'         => 'application/json',
120
-        'Content-Type'   => 'application/json',
121
-        'Accept-Language' => 'The language of the returned data: ar, en or all.',
122
-        'time-zone'       => 'Your locale time zone',
123
-        ];
124
-
125
-
126
-        if (! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) {
127
-            $route['headers']['Authorization'] = 'Bearer {token}';
128
-        }
129
-    }
130
-
131
-    /**
132
-     * Generate description and params for the given route
133
-     * based on the docblock.
134
-     *
135
-     * @param  array  &$route
136
-     * @param  \ReflectionMethod $reflectionMethod
137
-     * @return void
138
-     */
139
-    protected function processDocBlock(&$route, $reflectionMethod)
140
-    {
141
-        $factory                 = \phpDocumentor\Reflection\DocBlockFactory::createInstance();
142
-        $docblock                = $factory->create($reflectionMethod->getDocComment());
143
-        $route['description']    = trim(preg_replace('/\s+/', ' ', $docblock->getSummary()));
144
-        $params                  = $docblock->getTagsByName('param');
145
-        $route['returnDocBlock'] = $docblock->getTagsByName('return')[0]->getType()->getFqsen()->getName();
146
-
147
-        foreach ($params as $param) {
148
-            $name = $param->getVariableName();
149
-            if ($name == 'perPage') {
150
-                $route['parametars'][$name] = 'perPage? number of records per page default 15';
151
-            } elseif ($name == 'sortBy') {
152
-                $route['parametars'][$name] = 'sortBy? sort column default created_at';
153
-            } elseif ($name == 'desc') {
154
-                $route['parametars'][$name] = 'desc? sort descending or ascending default is descending';
155
-            } elseif ($name !== 'request') {
156
-                $route['parametars'][$name] = $param->getDescription()->render();
157
-            }
158
-        }
159
-
160
-        if ($route['name'] === 'index') {
161
-            $route['parametars']['perPage'] = 'perPage? number of records per page default 15';
162
-            $route['parametars']['sortBy']  = 'sortBy? sort column default created_at';
163
-            $route['parametars']['desc']    = 'desc? sort descending or ascending default is descending';
164
-            $route['parametars']['trashed'] = 'trashed? retreive trashed or not default not';
165
-        }
166
-    }
167
-
168
-    /**
169
-     * Generate post body for the given route.
170
-     *
171
-     * @param  array  &$route
172
-     * @param  \ReflectionMethod $reflectionMethod
173
-     * @param  string $module
174
-     * @param  string $modelName
175
-     * @return void
176
-     */
177
-    protected function getPostData(&$route, $reflectionMethod, $module, $modelName)
178
-    {
179
-        request()->setMethod($route['method']);
180
-        $parameters = $reflectionMethod->getParameters();
181
-        $className = optional(optional(\Arr::get($parameters, 0))->getType())->getName();
182
-        if ($className) {
183
-            $reflectionClass  = new \ReflectionClass($className);
184
-        } elseif (in_array($reflectionMethod->getName(), ['store', 'update'])) {
185
-            $className = 'App\\Modules\\' . ucfirst($module) . '\\Http\\Requests\\Store'  . ucfirst($modelName);
186
-            $reflectionClass  = new \ReflectionClass($className);
187
-        }
188
-
189
-        if (isset($reflectionClass) && $reflectionClass->hasMethod('rules')) {
190
-            $reflectionMethod = $reflectionClass->getMethod('rules');
191
-            $route['body'] = $reflectionMethod->invoke(new $className);
192
-
193
-            foreach ($route['body'] as &$rule) {
194
-                if (strpos($rule, 'unique')) {
195
-                    $rule = substr($rule, 0, strpos($rule, 'unique') + 6);
196
-                } elseif (strpos($rule, 'exists')) {
197
-                    $rule = substr($rule, 0, strpos($rule, 'exists') - 1);
198
-                }
199
-            }
200
-        }
201
-    }
202
-
203
-    /**
204
-     * Generate application errors.
205
-     *
206
-     * @return array
207
-     */
208
-    protected function getErrors()
209
-    {
210
-        $errors = [];
211
-        foreach (\Module::all() as $module) {
212
-            $nameSpace = 'App\\Modules\\' . $module['basename'];
213
-            $class = $nameSpace . '\\Errors\\'  . $module['basename'] . 'Errors';
214
-            $reflectionClass = new \ReflectionClass($class);
215
-            foreach ($reflectionClass->getMethods() as $method) {
216
-                $methodName       = $method->name;
217
-                $reflectionMethod = $reflectionClass->getMethod($methodName);
218
-                $body             = $this->getMethodBody($reflectionMethod);
219
-
220
-                preg_match('/abort\(([^#]+)\,/iU', $body, $match);
221
-
222
-                if (count($match)) {
223
-                    $errors[$match[1]][] = $methodName;
224
-                }
225
-            }
226
-        }
227
-
228
-        return $errors;
229
-    }
230
-
231
-    /**
232
-     * Get the given method body code.
233
-     *
234
-     * @param  object $reflectionMethod
235
-     * @return string
236
-     */
237
-    protected function getMethodBody($reflectionMethod)
238
-    {
239
-        $filename   = $reflectionMethod->getFileName();
240
-        $start_line = $reflectionMethod->getStartLine() - 1;
241
-        $end_line   = $reflectionMethod->getEndLine();
242
-        $length     = $end_line - $start_line;
243
-        $source     = file($filename);
244
-        $body       = implode("", array_slice($source, $start_line, $length));
245
-        $body       = trim(preg_replace('/\s+/', '', $body));
246
-
247
-        return $body;
248
-    }
249
-
250
-    /**
251
-     * Get example object of all availble models.
252
-     *
253
-     * @param  string $modelName
254
-     * @param  array  $docData
255
-     * @return string
256
-     */
257
-    protected function getModels($modelName, &$docData, $reflectionClass)
258
-    {
259
-        if ($modelName && ! Arr::has($docData['models'], $modelName)) {
260
-            $repo = call_user_func_array("\Core::{$modelName}", []);
261
-            if (! $repo) {
262
-                return;
263
-            }
83
+		$docData['errors']  = $this->getErrors();
84
+		$docData['reports'] = $this->reportService->all();
85
+		\File::put(app_path('Modules/Core/Resources/api.json'), json_encode($docData));
86
+	}
87
+
88
+	/**
89
+	 * Get list of all registered routes.
90
+	 *
91
+	 * @return collection
92
+	 */
93
+	protected function getRoutes()
94
+	{
95
+		return collect(\Route::getRoutes())->map(function ($route) {
96
+			if (strpos($route->uri(), 'api/') !== false) {
97
+				return [
98
+					'method' => $route->methods()[0],
99
+					'uri'    => $route->uri(),
100
+					'action' => $route->getActionName(),
101
+					'prefix' => $route->getPrefix()
102
+				];
103
+			}
104
+			return false;
105
+		})->all();
106
+	}
107
+
108
+	/**
109
+	 * Generate headers for the given route.
110
+	 *
111
+	 * @param  array  &$route
112
+	 * @param  string $method
113
+	 * @param  array  $skipLoginCheck
114
+	 * @return void
115
+	 */
116
+	protected function getHeaders(&$route, $method, $skipLoginCheck)
117
+	{
118
+		$route['headers'] = [
119
+		'Accept'         => 'application/json',
120
+		'Content-Type'   => 'application/json',
121
+		'Accept-Language' => 'The language of the returned data: ar, en or all.',
122
+		'time-zone'       => 'Your locale time zone',
123
+		];
124
+
125
+
126
+		if (! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) {
127
+			$route['headers']['Authorization'] = 'Bearer {token}';
128
+		}
129
+	}
130
+
131
+	/**
132
+	 * Generate description and params for the given route
133
+	 * based on the docblock.
134
+	 *
135
+	 * @param  array  &$route
136
+	 * @param  \ReflectionMethod $reflectionMethod
137
+	 * @return void
138
+	 */
139
+	protected function processDocBlock(&$route, $reflectionMethod)
140
+	{
141
+		$factory                 = \phpDocumentor\Reflection\DocBlockFactory::createInstance();
142
+		$docblock                = $factory->create($reflectionMethod->getDocComment());
143
+		$route['description']    = trim(preg_replace('/\s+/', ' ', $docblock->getSummary()));
144
+		$params                  = $docblock->getTagsByName('param');
145
+		$route['returnDocBlock'] = $docblock->getTagsByName('return')[0]->getType()->getFqsen()->getName();
146
+
147
+		foreach ($params as $param) {
148
+			$name = $param->getVariableName();
149
+			if ($name == 'perPage') {
150
+				$route['parametars'][$name] = 'perPage? number of records per page default 15';
151
+			} elseif ($name == 'sortBy') {
152
+				$route['parametars'][$name] = 'sortBy? sort column default created_at';
153
+			} elseif ($name == 'desc') {
154
+				$route['parametars'][$name] = 'desc? sort descending or ascending default is descending';
155
+			} elseif ($name !== 'request') {
156
+				$route['parametars'][$name] = $param->getDescription()->render();
157
+			}
158
+		}
159
+
160
+		if ($route['name'] === 'index') {
161
+			$route['parametars']['perPage'] = 'perPage? number of records per page default 15';
162
+			$route['parametars']['sortBy']  = 'sortBy? sort column default created_at';
163
+			$route['parametars']['desc']    = 'desc? sort descending or ascending default is descending';
164
+			$route['parametars']['trashed'] = 'trashed? retreive trashed or not default not';
165
+		}
166
+	}
167
+
168
+	/**
169
+	 * Generate post body for the given route.
170
+	 *
171
+	 * @param  array  &$route
172
+	 * @param  \ReflectionMethod $reflectionMethod
173
+	 * @param  string $module
174
+	 * @param  string $modelName
175
+	 * @return void
176
+	 */
177
+	protected function getPostData(&$route, $reflectionMethod, $module, $modelName)
178
+	{
179
+		request()->setMethod($route['method']);
180
+		$parameters = $reflectionMethod->getParameters();
181
+		$className = optional(optional(\Arr::get($parameters, 0))->getType())->getName();
182
+		if ($className) {
183
+			$reflectionClass  = new \ReflectionClass($className);
184
+		} elseif (in_array($reflectionMethod->getName(), ['store', 'update'])) {
185
+			$className = 'App\\Modules\\' . ucfirst($module) . '\\Http\\Requests\\Store'  . ucfirst($modelName);
186
+			$reflectionClass  = new \ReflectionClass($className);
187
+		}
188
+
189
+		if (isset($reflectionClass) && $reflectionClass->hasMethod('rules')) {
190
+			$reflectionMethod = $reflectionClass->getMethod('rules');
191
+			$route['body'] = $reflectionMethod->invoke(new $className);
192
+
193
+			foreach ($route['body'] as &$rule) {
194
+				if (strpos($rule, 'unique')) {
195
+					$rule = substr($rule, 0, strpos($rule, 'unique') + 6);
196
+				} elseif (strpos($rule, 'exists')) {
197
+					$rule = substr($rule, 0, strpos($rule, 'exists') - 1);
198
+				}
199
+			}
200
+		}
201
+	}
202
+
203
+	/**
204
+	 * Generate application errors.
205
+	 *
206
+	 * @return array
207
+	 */
208
+	protected function getErrors()
209
+	{
210
+		$errors = [];
211
+		foreach (\Module::all() as $module) {
212
+			$nameSpace = 'App\\Modules\\' . $module['basename'];
213
+			$class = $nameSpace . '\\Errors\\'  . $module['basename'] . 'Errors';
214
+			$reflectionClass = new \ReflectionClass($class);
215
+			foreach ($reflectionClass->getMethods() as $method) {
216
+				$methodName       = $method->name;
217
+				$reflectionMethod = $reflectionClass->getMethod($methodName);
218
+				$body             = $this->getMethodBody($reflectionMethod);
219
+
220
+				preg_match('/abort\(([^#]+)\,/iU', $body, $match);
221
+
222
+				if (count($match)) {
223
+					$errors[$match[1]][] = $methodName;
224
+				}
225
+			}
226
+		}
227
+
228
+		return $errors;
229
+	}
230
+
231
+	/**
232
+	 * Get the given method body code.
233
+	 *
234
+	 * @param  object $reflectionMethod
235
+	 * @return string
236
+	 */
237
+	protected function getMethodBody($reflectionMethod)
238
+	{
239
+		$filename   = $reflectionMethod->getFileName();
240
+		$start_line = $reflectionMethod->getStartLine() - 1;
241
+		$end_line   = $reflectionMethod->getEndLine();
242
+		$length     = $end_line - $start_line;
243
+		$source     = file($filename);
244
+		$body       = implode("", array_slice($source, $start_line, $length));
245
+		$body       = trim(preg_replace('/\s+/', '', $body));
246
+
247
+		return $body;
248
+	}
249
+
250
+	/**
251
+	 * Get example object of all availble models.
252
+	 *
253
+	 * @param  string $modelName
254
+	 * @param  array  $docData
255
+	 * @return string
256
+	 */
257
+	protected function getModels($modelName, &$docData, $reflectionClass)
258
+	{
259
+		if ($modelName && ! Arr::has($docData['models'], $modelName)) {
260
+			$repo = call_user_func_array("\Core::{$modelName}", []);
261
+			if (! $repo) {
262
+				return;
263
+			}
264 264
             
265
-            $modelClass = get_class($repo->model);
266
-            $model      = factory($modelClass)->make();
267
-
268
-            $property = $reflectionClass->getProperty('modelResource');
269
-            $property->setAccessible(true);
270
-            $modelResource = $property->getValue(\App::make($reflectionClass->getName()));
271
-
272
-            $relations = [];
273
-            $relationMethods = ['hasOne', 'hasMany', 'belongsTo', 'belongsToMany', 'morphToMany', 'morphTo'];
274
-            $reflector = new \ReflectionClass($model);
275
-            foreach ($reflector->getMethods() as $reflectionMethod) {
276
-                $body = $this->getMethodBody($reflectionMethod);
277
-                foreach ($relationMethods as $relationMethod) {
278
-                    $relation = $reflectionMethod->getName();
279
-                    if (strpos($body, '$this->' . $relationMethod) && $relation !== 'morphedByMany') {
280
-                        $relations[] = $relation;
281
-                        break;
282
-                    }
283
-                }
284
-            }
285
-
286
-            $modelResource = new $modelResource($model->load($relations));
287
-            $modelArr      = $modelResource->toArray([]);
288
-
289
-            foreach ($modelArr as $key => $attr) {
290
-                if (is_object($attr) && property_exists($attr, 'resource') && $attr->resource instanceof \Illuminate\Http\Resources\MissingValue) {
291
-                    unset($modelArr[$key]);
292
-                }
293
-            }
294
-
295
-            $docData['models'][$modelName] = json_encode($modelArr, JSON_PRETTY_PRINT);
296
-        }
297
-    }
298
-
299
-    /**
300
-     * Get the route response object type.
301
-     *
302
-     * @param  string $modelName
303
-     * @param  string $method
304
-     * @param  string $returnDocBlock
305
-     * @return array
306
-     */
307
-    protected function getResponseObject($modelName, $method, $returnDocBlock)
308
-    {
309
-        $relations = config('core.relations');
310
-        $relations = Arr::has($relations, $modelName) ? Arr::has($relations[$modelName], $method) ? $relations[$modelName] : false : false;
311
-        $modelName = call_user_func_array("\Core::{$returnDocBlock}", []) ? $returnDocBlock : $modelName;
312
-
313
-        return $relations ? [$modelName => $relations && $relations[$method] ? $relations[$method] : []] : false;
314
-    }
265
+			$modelClass = get_class($repo->model);
266
+			$model      = factory($modelClass)->make();
267
+
268
+			$property = $reflectionClass->getProperty('modelResource');
269
+			$property->setAccessible(true);
270
+			$modelResource = $property->getValue(\App::make($reflectionClass->getName()));
271
+
272
+			$relations = [];
273
+			$relationMethods = ['hasOne', 'hasMany', 'belongsTo', 'belongsToMany', 'morphToMany', 'morphTo'];
274
+			$reflector = new \ReflectionClass($model);
275
+			foreach ($reflector->getMethods() as $reflectionMethod) {
276
+				$body = $this->getMethodBody($reflectionMethod);
277
+				foreach ($relationMethods as $relationMethod) {
278
+					$relation = $reflectionMethod->getName();
279
+					if (strpos($body, '$this->' . $relationMethod) && $relation !== 'morphedByMany') {
280
+						$relations[] = $relation;
281
+						break;
282
+					}
283
+				}
284
+			}
285
+
286
+			$modelResource = new $modelResource($model->load($relations));
287
+			$modelArr      = $modelResource->toArray([]);
288
+
289
+			foreach ($modelArr as $key => $attr) {
290
+				if (is_object($attr) && property_exists($attr, 'resource') && $attr->resource instanceof \Illuminate\Http\Resources\MissingValue) {
291
+					unset($modelArr[$key]);
292
+				}
293
+			}
294
+
295
+			$docData['models'][$modelName] = json_encode($modelArr, JSON_PRETTY_PRINT);
296
+		}
297
+	}
298
+
299
+	/**
300
+	 * Get the route response object type.
301
+	 *
302
+	 * @param  string $modelName
303
+	 * @param  string $method
304
+	 * @param  string $returnDocBlock
305
+	 * @return array
306
+	 */
307
+	protected function getResponseObject($modelName, $method, $returnDocBlock)
308
+	{
309
+		$relations = config('core.relations');
310
+		$relations = Arr::has($relations, $modelName) ? Arr::has($relations[$modelName], $method) ? $relations[$modelName] : false : false;
311
+		$modelName = call_user_func_array("\Core::{$returnDocBlock}", []) ? $returnDocBlock : $modelName;
312
+
313
+		return $relations ? [$modelName => $relations && $relations[$method] ? $relations[$method] : []] : false;
314
+	}
315 315
 }
Please login to merge, or discard this patch.
files/Kernel.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -11,39 +11,39 @@
 block discarded – undo
11 11
 
12 12
 class Kernel extends ConsoleKernel
13 13
 {
14
-    /**
15
-     * The Artisan commands provided by your application.
16
-     *
17
-     * @var array
18
-     */
19
-    protected $commands = [
20
-        GenerateDocCommand::class,
21
-        PassportInstallCommand::class,
22
-        MakeNotificationsCommand::class,
23
-        MakeModuleCommand::class
24
-    ];
14
+	/**
15
+	 * The Artisan commands provided by your application.
16
+	 *
17
+	 * @var array
18
+	 */
19
+	protected $commands = [
20
+		GenerateDocCommand::class,
21
+		PassportInstallCommand::class,
22
+		MakeNotificationsCommand::class,
23
+		MakeModuleCommand::class
24
+	];
25 25
 
26
-    /**
27
-     * Define the application's command schedule.
28
-     *
29
-     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
30
-     * @return void
31
-     */
32
-    protected function schedule(Schedule $schedule)
33
-    {
34
-        // $schedule->command('inspire')
35
-        //          ->hourly();
36
-    }
26
+	/**
27
+	 * Define the application's command schedule.
28
+	 *
29
+	 * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
30
+	 * @return void
31
+	 */
32
+	protected function schedule(Schedule $schedule)
33
+	{
34
+		// $schedule->command('inspire')
35
+		//          ->hourly();
36
+	}
37 37
 
38
-    /**
39
-     * Register the commands for the application.
40
-     *
41
-     * @return void
42
-     */
43
-    protected function commands()
44
-    {
45
-        $this->load(__DIR__.'/Commands');
38
+	/**
39
+	 * Register the commands for the application.
40
+	 *
41
+	 * @return void
42
+	 */
43
+	protected function commands()
44
+	{
45
+		$this->load(__DIR__.'/Commands');
46 46
 
47
-        require base_path('routes/console.php');
48
-    }
47
+		require base_path('routes/console.php');
48
+	}
49 49
 }
Please login to merge, or discard this patch.