Completed
Push — master ( 0dfd17...a38508 )
by Sherif
02:04
created
src/Modules/OauthClients/Http/Requests/UpdateOauthClient.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -6,29 +6,29 @@
 block discarded – undo
6 6
 
7 7
 class UpdateOauthClient extends FormRequest
8 8
 {
9
-    /**
10
-     * Determine if the user is authorized to make this request.
11
-     *
12
-     * @return bool
13
-     */
14
-    public function authorize()
15
-    {
16
-        return true;
17
-    }
9
+	/**
10
+	 * Determine if the user is authorized to make this request.
11
+	 *
12
+	 * @return bool
13
+	 */
14
+	public function authorize()
15
+	{
16
+		return true;
17
+	}
18 18
 
19
-    /**
20
-     * Get the validation rules that apply to the request.
21
-     *
22
-     * @return array
23
-     */
24
-    public function rules()
25
-    {
26
-        return [
27
-            'id'       => 'required|exists:oauth_clients,id',
28
-            'name'     => 'required|max:255',
29
-            'redirect' => 'required|url',
30
-            'user_id'  => 'required|exists:users,id',
31
-            'revoked'  => 'boolean'
32
-        ];
33
-    }
19
+	/**
20
+	 * Get the validation rules that apply to the request.
21
+	 *
22
+	 * @return array
23
+	 */
24
+	public function rules()
25
+	{
26
+		return [
27
+			'id'       => 'required|exists:oauth_clients,id',
28
+			'name'     => 'required|max:255',
29
+			'redirect' => 'required|url',
30
+			'user_id'  => 'required|exists:users,id',
31
+			'revoked'  => 'boolean'
32
+		];
33
+	}
34 34
 }
Please login to merge, or discard this patch.
src/Modules/Notifications/Repositories/NotificationRepository.php 1 patch
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -5,73 +5,73 @@
 block discarded – undo
5 5
 
6 6
 class NotificationRepository extends BaseRepository
7 7
 {
8
-    /**
9
-     * Init new object.
10
-     *
11
-     * @param   Notification $model
12
-     * @return  void
13
-     */
14
-    public function __construct(Notification $model)
15
-    {
16
-        parent::__construct($model);
17
-    }
8
+	/**
9
+	 * Init new object.
10
+	 *
11
+	 * @param   Notification $model
12
+	 * @return  void
13
+	 */
14
+	public function __construct(Notification $model)
15
+	{
16
+		parent::__construct($model);
17
+	}
18 18
 
19
-    /**
20
-     * Retrieve all notifications of the logged in user.
21
-     *
22
-     * @param  integer $perPage
23
-     * @return Collection
24
-     */
25
-    public function my($perPage)
26
-    {
27
-        return \Auth::user()->notifications()->paginate($perPage);
28
-    }
19
+	/**
20
+	 * Retrieve all notifications of the logged in user.
21
+	 *
22
+	 * @param  integer $perPage
23
+	 * @return Collection
24
+	 */
25
+	public function my($perPage)
26
+	{
27
+		return \Auth::user()->notifications()->paginate($perPage);
28
+	}
29 29
 
30
-    /**
31
-     * Retrieve unread notifications of the logged in user.
32
-     *
33
-     * @param  integer $perPage
34
-     * @return Collection
35
-     */
36
-    public function unread($perPage)
37
-    {
38
-        return \Auth::user()->unreadNotifications()->paginate($perPage);
39
-    }
30
+	/**
31
+	 * Retrieve unread notifications of the logged in user.
32
+	 *
33
+	 * @param  integer $perPage
34
+	 * @return Collection
35
+	 */
36
+	public function unread($perPage)
37
+	{
38
+		return \Auth::user()->unreadNotifications()->paginate($perPage);
39
+	}
40 40
 
41
-    /**
42
-     * Mark the notification as read.
43
-     *
44
-     * @param  integer  $id
45
-     * @return object
46
-     */
47
-    public function markAsRead($id)
48
-    {
49
-        if ($notification = \Auth::user()->unreadNotifications()->where('id', $id)->first()) {
50
-            $notification->markAsRead();
51
-        }
52
-    }
41
+	/**
42
+	 * Mark the notification as read.
43
+	 *
44
+	 * @param  integer  $id
45
+	 * @return object
46
+	 */
47
+	public function markAsRead($id)
48
+	{
49
+		if ($notification = \Auth::user()->unreadNotifications()->where('id', $id)->first()) {
50
+			$notification->markAsRead();
51
+		}
52
+	}
53 53
 
54
-    /**
55
-     * Mark all notifications as read.
56
-     *
57
-     * @return void
58
-     */
59
-    public function markAllAsRead()
60
-    {
61
-        \Auth::user()->unreadNotifications()->update(['read_at' => now()]);
62
-    }
54
+	/**
55
+	 * Mark all notifications as read.
56
+	 *
57
+	 * @return void
58
+	 */
59
+	public function markAllAsRead()
60
+	{
61
+		\Auth::user()->unreadNotifications()->update(['read_at' => now()]);
62
+	}
63 63
 
64
-    /**
65
-     * Notify th given user with the given notification.
66
-     *
67
-     * @param  collection $users
68
-     * @param  string     $notification
69
-     * @param  object     $notificationData
70
-     * @return void
71
-     */
72
-    public function notify($users, $notification, $notificationData = false)
73
-    {
74
-        $notification = 'App\Modules\Notifications\Notifications\\'.$notification;
75
-        \Notification::send($users, new $notification($notificationData));
76
-    }
64
+	/**
65
+	 * Notify th given user with the given notification.
66
+	 *
67
+	 * @param  collection $users
68
+	 * @param  string     $notification
69
+	 * @param  object     $notificationData
70
+	 * @return void
71
+	 */
72
+	public function notify($users, $notification, $notificationData = false)
73
+	{
74
+		$notification = 'App\Modules\Notifications\Notifications\\'.$notification;
75
+		\Notification::send($users, new $notification($notificationData));
76
+	}
77 77
 }
Please login to merge, or discard this patch.
src/Modules/Notifications/Routes/api.php 1 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' => 'notifications'], function () {
15 15
 
16
-    Route::get('/', 'NotificationController@index');
17
-    Route::get('unread', 'NotificationController@unread');
18
-    Route::get('read/{id}', 'NotificationController@markAsRead');
19
-    Route::get('read/all', 'NotificationController@markAllAsRead');
16
+	Route::get('/', 'NotificationController@index');
17
+	Route::get('unread', 'NotificationController@unread');
18
+	Route::get('read/{id}', 'NotificationController@markAsRead');
19
+	Route::get('read/all', 'NotificationController@markAllAsRead');
20 20
 });
Please login to merge, or discard this patch.
src/Modules/Notifications/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', 'notifications');
17
-        $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'notifications');
9
+	/**
10
+	 * Bootstrap the module services.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function boot()
15
+	{
16
+		$this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'notifications');
17
+		$this->loadViewsFrom(__DIR__.'/../Resources/Views', 'notifications');
18 18
 
19
-        $this->loadMigrationsFrom(module_path('notifications', 'Database/Migrations', 'app'));
20
-        $this->loadFactoriesFrom(module_path('notifications', 'Database/Factories', 'app'));
21
-    }
19
+		$this->loadMigrationsFrom(module_path('notifications', 'Database/Migrations', 'app'));
20
+		$this->loadFactoriesFrom(module_path('notifications', '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/Notifications/Http/Resources/Notification.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 Notification extends JsonResource
8 8
 {
9
-    /**
10
-     * Transform the resource into an array.
11
-     *
12
-     * @param Request $request
13
-     * @return array
14
-     */
15
-    public function toArray($request)
16
-    {
17
-        if (! $this->resource) {
18
-            return [];
19
-        }
9
+	/**
10
+	 * Transform the resource into an array.
11
+	 *
12
+	 * @param Request $request
13
+	 * @return array
14
+	 */
15
+	public function toArray($request)
16
+	{
17
+		if (! $this->resource) {
18
+			return [];
19
+		}
20 20
 
21
-        return [
22
-            'id' => $this->id,
23
-            'type' => $this->type,
24
-            'data' => $this->data,
25
-            'read_at' => $this->read_at,
26
-            'created_at' => $this->created_at,
27
-            'updated_at' => $this->updated_at,
28
-        ];
29
-    }
21
+		return [
22
+			'id' => $this->id,
23
+			'type' => $this->type,
24
+			'data' => $this->data,
25
+			'read_at' => $this->read_at,
26
+			'created_at' => $this->created_at,
27
+			'updated_at' => $this->updated_at,
28
+		];
29
+	}
30 30
 }
Please login to merge, or discard this patch.
src/Modules/Notifications/Http/Controllers/NotificationController.php 1 patch
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -10,65 +10,65 @@
 block discarded – undo
10 10
 
11 11
 class NotificationController extends BaseApiController
12 12
 {
13
-    /**
14
-     * List of all route actions that the base api controller
15
-     * will skip permissions check for them.
16
-     * @var array
17
-     */
18
-    protected $skipPermissionCheck = ['markAsRead', 'markAllAsRead', 'index', 'unread'];
13
+	/**
14
+	 * List of all route actions that the base api controller
15
+	 * will skip permissions check for them.
16
+	 * @var array
17
+	 */
18
+	protected $skipPermissionCheck = ['markAsRead', 'markAllAsRead', 'index', 'unread'];
19 19
 
20
-    /**
21
-     * Init new object.
22
-     *
23
-     * @param   NotificationRepository $repo
24
-     * @param   CoreConfig             $config
25
-     * @return  void
26
-     */
27
-    public function __construct(NotificationRepository $repo, CoreConfig $config)
28
-    {
29
-        parent::__construct($repo, $config, 'App\Modules\Notifications\Http\Resources\Notification');
30
-    }
20
+	/**
21
+	 * Init new object.
22
+	 *
23
+	 * @param   NotificationRepository $repo
24
+	 * @param   CoreConfig             $config
25
+	 * @return  void
26
+	 */
27
+	public function __construct(NotificationRepository $repo, CoreConfig $config)
28
+	{
29
+		parent::__construct($repo, $config, 'App\Modules\Notifications\Http\Resources\Notification');
30
+	}
31 31
 
32
-    /**
33
-     * Retrieve all notifications of the logged in user.
34
-     *
35
-     * @param Request $request
36
-     * @return \Illuminate\Http\Response
37
-     */
38
-    public function index(Request $request)
39
-    {
40
-        return $this->modelResource::collection($this->repo->my($request->query('perPage')));
41
-    }
32
+	/**
33
+	 * Retrieve all notifications of the logged in user.
34
+	 *
35
+	 * @param Request $request
36
+	 * @return \Illuminate\Http\Response
37
+	 */
38
+	public function index(Request $request)
39
+	{
40
+		return $this->modelResource::collection($this->repo->my($request->query('perPage')));
41
+	}
42 42
 
43
-    /**
44
-     * Retrieve unread notifications of the logged in user.
45
-     *
46
-     * @param Request $request
47
-     * @return \Illuminate\Http\Response
48
-     */
49
-    public function unread(Request $request)
50
-    {
51
-        return $this->modelResource::collection($this->repo->unread($request->query('perPage')));
52
-    }
43
+	/**
44
+	 * Retrieve unread notifications of the logged in user.
45
+	 *
46
+	 * @param Request $request
47
+	 * @return \Illuminate\Http\Response
48
+	 */
49
+	public function unread(Request $request)
50
+	{
51
+		return $this->modelResource::collection($this->repo->unread($request->query('perPage')));
52
+	}
53 53
 
54
-    /**
55
-     * Mark the notification as read.
56
-     *
57
-     * @param  integer  $id Id of the notification.
58
-     * @return \Illuminate\Http\Response
59
-     */
60
-    public function markAsRead($id)
61
-    {
62
-        return new GeneralResource($this->repo->markAsRead($id));
63
-    }
54
+	/**
55
+	 * Mark the notification as read.
56
+	 *
57
+	 * @param  integer  $id Id of the notification.
58
+	 * @return \Illuminate\Http\Response
59
+	 */
60
+	public function markAsRead($id)
61
+	{
62
+		return new GeneralResource($this->repo->markAsRead($id));
63
+	}
64 64
 
65
-    /**
66
-     * Mark all notifications as read.
67
-     *
68
-     * @return \Illuminate\Http\Response
69
-     */
70
-    public function markAllAsRead()
71
-    {
72
-        return new GeneralResource($this->repo->markAllAsRead());
73
-    }
65
+	/**
66
+	 * Mark all notifications as read.
67
+	 *
68
+	 * @return \Illuminate\Http\Response
69
+	 */
70
+	public function markAllAsRead()
71
+	{
72
+		return new GeneralResource($this->repo->markAllAsRead());
73
+	}
74 74
 }
Please login to merge, or discard this patch.
src/Modules/Core/Core.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -4,26 +4,26 @@
 block discarded – undo
4 4
 
5 5
 class Core implements BaseFactoryInterface
6 6
 {
7
-    /**
8
-     * Construct the repository class name based on
9
-     * the method name called, search in the
10
-     * given namespaces for the class and
11
-     * return an instance.
12
-     *
13
-     * @param  string $name the called method name
14
-     * @param  array  $arguments the method arguments
15
-     * @return object
16
-     */
17
-    public function __call($name, $arguments)
18
-    {
19
-        foreach (\Module::all() as $module) {
20
-            $nameSpace = 'App\\Modules\\' . $module['basename'] ;
21
-            $model = ucfirst(\Str::singular($name));
22
-            $class = $nameSpace . '\\Repositories\\' . $model . 'Repository';
7
+	/**
8
+	 * Construct the repository class name based on
9
+	 * the method name called, search in the
10
+	 * given namespaces for the class and
11
+	 * return an instance.
12
+	 *
13
+	 * @param  string $name the called method name
14
+	 * @param  array  $arguments the method arguments
15
+	 * @return object
16
+	 */
17
+	public function __call($name, $arguments)
18
+	{
19
+		foreach (\Module::all() as $module) {
20
+			$nameSpace = 'App\\Modules\\' . $module['basename'] ;
21
+			$model = ucfirst(\Str::singular($name));
22
+			$class = $nameSpace . '\\Repositories\\' . $model . 'Repository';
23 23
 
24
-            if (class_exists($class)) {
25
-                return \App::make($class);
26
-            }
27
-        }
28
-    }
24
+			if (class_exists($class)) {
25
+				return \App::make($class);
26
+			}
27
+		}
28
+	}
29 29
 }
Please login to merge, or discard this patch.
src/Modules/Core/Console/Commands/GenerateDoc.php 1 patch
Indentation   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -7,255 +7,255 @@
 block discarded – undo
7 7
 
8 8
 class GenerateDoc extends Command
9 9
 {
10
-    /**
11
-     * The name and signature of the console command.
12
-     *
13
-     * @var string
14
-     */
15
-    protected $signature = 'doc:generate';
10
+	/**
11
+	 * The name and signature of the console command.
12
+	 *
13
+	 * @var string
14
+	 */
15
+	protected $signature = 'doc:generate';
16 16
 
17
-    /**
18
-     * The console command description.
19
-     *
20
-     * @var string
21
-     */
22
-    protected $description = 'Generate api documentation';
17
+	/**
18
+	 * The console command description.
19
+	 *
20
+	 * @var string
21
+	 */
22
+	protected $description = 'Generate api documentation';
23 23
 
24
-    /**
25
-     * Init new object.
26
-     *
27
-     * @return  void
28
-     */
29
-    public function __construct()
30
-    {
31
-        parent::__construct();
32
-    }
24
+	/**
25
+	 * Init new object.
26
+	 *
27
+	 * @return  void
28
+	 */
29
+	public function __construct()
30
+	{
31
+		parent::__construct();
32
+	}
33 33
 
34
-    /**
35
-     * Execute the console command.
36
-     *
37
-     * @return mixed
38
-     */
39
-    public function handle()
40
-    {
41
-        $docData           = [];
42
-        $docData['models'] = [];
43
-        $routes            = $this->getRoutes();
44
-        foreach ($routes as $route) {
45
-            if ($route) {
46
-                $actoinArray = explode('@', $route['action']);
47
-                if (Arr::get($actoinArray, 1, false)) {
48
-                    $controller       = $actoinArray[0];
49
-                    $method           = $actoinArray[1];
50
-                    $route['name']    = $method !== 'index' ? $method : 'list';
34
+	/**
35
+	 * Execute the console command.
36
+	 *
37
+	 * @return mixed
38
+	 */
39
+	public function handle()
40
+	{
41
+		$docData           = [];
42
+		$docData['models'] = [];
43
+		$routes            = $this->getRoutes();
44
+		foreach ($routes as $route) {
45
+			if ($route) {
46
+				$actoinArray = explode('@', $route['action']);
47
+				if (Arr::get($actoinArray, 1, false)) {
48
+					$controller       = $actoinArray[0];
49
+					$method           = $actoinArray[1];
50
+					$route['name']    = $method !== 'index' ? $method : 'list';
51 51
                     
52
-                    $reflectionClass  = new \ReflectionClass($controller);
53
-                    $reflectionMethod = $reflectionClass->getMethod($method);
54
-                    $classProperties  = $reflectionClass->getDefaultProperties();
55
-                    $skipLoginCheck   = Arr::get($classProperties, 'skipLoginCheck', false);
56
-                    $validationRules  = Arr::get($classProperties, 'validationRules', false);
52
+					$reflectionClass  = new \ReflectionClass($controller);
53
+					$reflectionMethod = $reflectionClass->getMethod($method);
54
+					$classProperties  = $reflectionClass->getDefaultProperties();
55
+					$skipLoginCheck   = Arr::get($classProperties, 'skipLoginCheck', false);
56
+					$validationRules  = Arr::get($classProperties, 'validationRules', false);
57 57
 
58
-                    dd($classProperties);
59
-                    $this->processDocBlock($route, $reflectionMethod);
60
-                    $this->getHeaders($route, $method, $skipLoginCheck);
61
-                    $this->getPostData($route, $reflectionMethod, $validationRules);
58
+					dd($classProperties);
59
+					$this->processDocBlock($route, $reflectionMethod);
60
+					$this->getHeaders($route, $method, $skipLoginCheck);
61
+					$this->getPostData($route, $reflectionMethod, $validationRules);
62 62
 
63
-                    $route['response'] = $this->getResponseObject($classProperties['model'], $route['name'], $route['returnDocBlock']);
63
+					$route['response'] = $this->getResponseObject($classProperties['model'], $route['name'], $route['returnDocBlock']);
64 64
 
65
-                    preg_match('/api\/([^#]+)\//iU', $route['uri'], $module);
66
-                    $docData['modules'][$module[1]][substr($route['prefix'], strlen('/api/'.$module[1].'/') - 1)][] = $route;
65
+					preg_match('/api\/([^#]+)\//iU', $route['uri'], $module);
66
+					$docData['modules'][$module[1]][substr($route['prefix'], strlen('/api/'.$module[1].'/') - 1)][] = $route;
67 67
 
68
-                    $this->getModels($classProperties['model'], $docData);
69
-                }
70
-            }
71
-        }
68
+					$this->getModels($classProperties['model'], $docData);
69
+				}
70
+			}
71
+		}
72 72
         
73
-        $docData['errors']  = $this->getErrors();
74
-        $docData['reports'] = \Core::reports()->all();
75
-        \File::put(app_path('Modules/Core/Resources/api.json'), json_encode($docData));
76
-    }
73
+		$docData['errors']  = $this->getErrors();
74
+		$docData['reports'] = \Core::reports()->all();
75
+		\File::put(app_path('Modules/Core/Resources/api.json'), json_encode($docData));
76
+	}
77 77
 
78
-    /**
79
-     * Get list of all registered routes.
80
-     *
81
-     * @return collection
82
-     */
83
-    protected function getRoutes()
84
-    {
85
-        return collect(\Route::getRoutes())->map(function ($route) {
86
-            if (strpos($route->uri(), 'api/') !== false) {
87
-                return [
88
-                    'method' => $route->methods()[0],
89
-                    'uri'    => $route->uri(),
90
-                    'action' => $route->getActionName(),
91
-                    'prefix' => $route->getPrefix()
92
-                ];
93
-            }
94
-            return false;
95
-        })->all();
96
-    }
78
+	/**
79
+	 * Get list of all registered routes.
80
+	 *
81
+	 * @return collection
82
+	 */
83
+	protected function getRoutes()
84
+	{
85
+		return collect(\Route::getRoutes())->map(function ($route) {
86
+			if (strpos($route->uri(), 'api/') !== false) {
87
+				return [
88
+					'method' => $route->methods()[0],
89
+					'uri'    => $route->uri(),
90
+					'action' => $route->getActionName(),
91
+					'prefix' => $route->getPrefix()
92
+				];
93
+			}
94
+			return false;
95
+		})->all();
96
+	}
97 97
 
98
-    /**
99
-     * Generate headers for the given route.
100
-     *
101
-     * @param  array  &$route
102
-     * @param  string $method
103
-     * @param  array  $skipLoginCheck
104
-     * @return void
105
-     */
106
-    protected function getHeaders(&$route, $method, $skipLoginCheck)
107
-    {
108
-        $route['headers'] = [
109
-        'Accept'       => 'application/json',
110
-        'Content-Type' => 'application/json',
111
-        'locale'       => 'The language of the returned data: ar, en or all.',
112
-        'time-zone'    => 'Your locale time zone',
113
-        ];
98
+	/**
99
+	 * Generate headers for the given route.
100
+	 *
101
+	 * @param  array  &$route
102
+	 * @param  string $method
103
+	 * @param  array  $skipLoginCheck
104
+	 * @return void
105
+	 */
106
+	protected function getHeaders(&$route, $method, $skipLoginCheck)
107
+	{
108
+		$route['headers'] = [
109
+		'Accept'       => 'application/json',
110
+		'Content-Type' => 'application/json',
111
+		'locale'       => 'The language of the returned data: ar, en or all.',
112
+		'time-zone'    => 'Your locale time zone',
113
+		];
114 114
 
115 115
 
116
-        if (! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) {
117
-            $route['headers']['Authorization'] = 'Bearer {token}';
118
-        }
119
-    }
116
+		if (! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) {
117
+			$route['headers']['Authorization'] = 'Bearer {token}';
118
+		}
119
+	}
120 120
 
121
-    /**
122
-     * Generate description and params for the given route
123
-     * based on the docblock.
124
-     *
125
-     * @param  array  &$route
126
-     * @param  \ReflectionMethod $reflectionMethod
127
-     * @return void
128
-     */
129
-    protected function processDocBlock(&$route, $reflectionMethod)
130
-    {
131
-        $factory                 = \phpDocumentor\Reflection\DocBlockFactory::createInstance();
132
-        $docblock                = $factory->create($reflectionMethod->getDocComment());
133
-        $route['description']    = trim(preg_replace('/\s+/', ' ', $docblock->getSummary()));
134
-        $params                  = $docblock->getTagsByName('param');
135
-        $route['returnDocBlock'] = $docblock->getTagsByName('return')[0]->getType()->getFqsen()->getName();
136
-        foreach ($params as $param) {
137
-            $name = $param->getVariableName();
138
-            if ($name !== 'request') {
139
-                $route['parametars'][$param->getVariableName()] = $param->getDescription()->render();
140
-            }
141
-        }
142
-    }
121
+	/**
122
+	 * Generate description and params for the given route
123
+	 * based on the docblock.
124
+	 *
125
+	 * @param  array  &$route
126
+	 * @param  \ReflectionMethod $reflectionMethod
127
+	 * @return void
128
+	 */
129
+	protected function processDocBlock(&$route, $reflectionMethod)
130
+	{
131
+		$factory                 = \phpDocumentor\Reflection\DocBlockFactory::createInstance();
132
+		$docblock                = $factory->create($reflectionMethod->getDocComment());
133
+		$route['description']    = trim(preg_replace('/\s+/', ' ', $docblock->getSummary()));
134
+		$params                  = $docblock->getTagsByName('param');
135
+		$route['returnDocBlock'] = $docblock->getTagsByName('return')[0]->getType()->getFqsen()->getName();
136
+		foreach ($params as $param) {
137
+			$name = $param->getVariableName();
138
+			if ($name !== 'request') {
139
+				$route['parametars'][$param->getVariableName()] = $param->getDescription()->render();
140
+			}
141
+		}
142
+	}
143 143
 
144
-    /**
145
-     * Generate post body for the given route.
146
-     *
147
-     * @param  array  &$route
148
-     * @param  \ReflectionMethod $reflectionMethod
149
-     * @param  array  $validationRules
150
-     * @return void
151
-     */
152
-    protected function getPostData(&$route, $reflectionMethod, $validationRules)
153
-    {
154
-        if ($route['method'] == 'POST') {
155
-            $body = $this->getMethodBody($reflectionMethod);
144
+	/**
145
+	 * Generate post body for the given route.
146
+	 *
147
+	 * @param  array  &$route
148
+	 * @param  \ReflectionMethod $reflectionMethod
149
+	 * @param  array  $validationRules
150
+	 * @return void
151
+	 */
152
+	protected function getPostData(&$route, $reflectionMethod, $validationRules)
153
+	{
154
+		if ($route['method'] == 'POST') {
155
+			$body = $this->getMethodBody($reflectionMethod);
156 156
 
157
-            preg_match('/\$this->validate\(\$request,([^#]+)\);/iU', $body, $match);
158
-            if (count($match)) {
159
-                if ($match[1] == '$this->validationRules') {
160
-                    $route['body'] = $validationRules;
161
-                } else {
162
-                    $route['body'] = eval('return '.str_replace(',\'.$request->get(\'id\')', ',{id}\'', $match[1]).';');
163
-                }
157
+			preg_match('/\$this->validate\(\$request,([^#]+)\);/iU', $body, $match);
158
+			if (count($match)) {
159
+				if ($match[1] == '$this->validationRules') {
160
+					$route['body'] = $validationRules;
161
+				} else {
162
+					$route['body'] = eval('return '.str_replace(',\'.$request->get(\'id\')', ',{id}\'', $match[1]).';');
163
+				}
164 164
 
165
-                foreach ($route['body'] as &$rule) {
166
-                    if (strpos($rule, 'unique')) {
167
-                        $rule = substr($rule, 0, strpos($rule, 'unique') + 6);
168
-                    } elseif (strpos($rule, 'exists')) {
169
-                        $rule = substr($rule, 0, strpos($rule, 'exists') - 1);
170
-                    }
171
-                }
172
-            } else {
173
-                $route['body'] = 'conditions';
174
-            }
175
-        }
176
-    }
165
+				foreach ($route['body'] as &$rule) {
166
+					if (strpos($rule, 'unique')) {
167
+						$rule = substr($rule, 0, strpos($rule, 'unique') + 6);
168
+					} elseif (strpos($rule, 'exists')) {
169
+						$rule = substr($rule, 0, strpos($rule, 'exists') - 1);
170
+					}
171
+				}
172
+			} else {
173
+				$route['body'] = 'conditions';
174
+			}
175
+		}
176
+	}
177 177
 
178
-    /**
179
-     * Generate application errors.
180
-     *
181
-     * @return array
182
-     */
183
-    protected function getErrors()
184
-    {
185
-        $errors          = [];
186
-        $reflectionClass = new \ReflectionClass('App\Modules\Core\Utl\ErrorHandler');
187
-        foreach ($reflectionClass->getMethods() as $method) {
188
-            $methodName       = $method->name;
189
-            $reflectionMethod = $reflectionClass->getMethod($methodName);
190
-            $body             = $this->getMethodBody($reflectionMethod);
178
+	/**
179
+	 * Generate application errors.
180
+	 *
181
+	 * @return array
182
+	 */
183
+	protected function getErrors()
184
+	{
185
+		$errors          = [];
186
+		$reflectionClass = new \ReflectionClass('App\Modules\Core\Utl\ErrorHandler');
187
+		foreach ($reflectionClass->getMethods() as $method) {
188
+			$methodName       = $method->name;
189
+			$reflectionMethod = $reflectionClass->getMethod($methodName);
190
+			$body             = $this->getMethodBody($reflectionMethod);
191 191
 
192
-            preg_match('/\$error=\[\'status\'=>([^#]+)\,/iU', $body, $match);
192
+			preg_match('/\$error=\[\'status\'=>([^#]+)\,/iU', $body, $match);
193 193
 
194
-            if (count($match)) {
195
-                $errors[$match[1]][] = $methodName;
196
-            }
197
-        }
194
+			if (count($match)) {
195
+				$errors[$match[1]][] = $methodName;
196
+			}
197
+		}
198 198
 
199
-        return $errors;
200
-    }
199
+		return $errors;
200
+	}
201 201
 
202
-    /**
203
-     * Get the given method body code.
204
-     *
205
-     * @param  object $reflectionMethod
206
-     * @return string
207
-     */
208
-    protected function getMethodBody($reflectionMethod)
209
-    {
210
-        $filename   = $reflectionMethod->getFileName();
211
-        $start_line = $reflectionMethod->getStartLine() - 1;
212
-        $end_line   = $reflectionMethod->getEndLine();
213
-        $length     = $end_line - $start_line;
214
-        $source     = file($filename);
215
-        $body       = implode("", array_slice($source, $start_line, $length));
216
-        $body       = trim(preg_replace('/\s+/', '', $body));
202
+	/**
203
+	 * Get the given method body code.
204
+	 *
205
+	 * @param  object $reflectionMethod
206
+	 * @return string
207
+	 */
208
+	protected function getMethodBody($reflectionMethod)
209
+	{
210
+		$filename   = $reflectionMethod->getFileName();
211
+		$start_line = $reflectionMethod->getStartLine() - 1;
212
+		$end_line   = $reflectionMethod->getEndLine();
213
+		$length     = $end_line - $start_line;
214
+		$source     = file($filename);
215
+		$body       = implode("", array_slice($source, $start_line, $length));
216
+		$body       = trim(preg_replace('/\s+/', '', $body));
217 217
 
218
-        return $body;
219
-    }
218
+		return $body;
219
+	}
220 220
 
221
-    /**
222
-     * Get example object of all availble models.
223
-     *
224
-     * @param  string $modelName
225
-     * @param  array  $docData
226
-     * @return string
227
-     */
228
-    protected function getModels($modelName, &$docData)
229
-    {
230
-        if ($modelName && ! Arr::has($docData['models'], $modelName)) {
231
-            $modelClass = call_user_func_array("\Core::{$modelName}", [])->modelClass;
232
-            $model      = factory($modelClass)->make();
233
-            $modelArr   = $model->toArray();
221
+	/**
222
+	 * Get example object of all availble models.
223
+	 *
224
+	 * @param  string $modelName
225
+	 * @param  array  $docData
226
+	 * @return string
227
+	 */
228
+	protected function getModels($modelName, &$docData)
229
+	{
230
+		if ($modelName && ! Arr::has($docData['models'], $modelName)) {
231
+			$modelClass = call_user_func_array("\Core::{$modelName}", [])->modelClass;
232
+			$model      = factory($modelClass)->make();
233
+			$modelArr   = $model->toArray();
234 234
 
235
-            if ($model->trans && ! $model->trans->count()) {
236
-                $modelArr['trans'] = [
237
-                    'en' => factory($modelClass.'Translation')->make()->toArray()
238
-                ];
239
-            }
235
+			if ($model->trans && ! $model->trans->count()) {
236
+				$modelArr['trans'] = [
237
+					'en' => factory($modelClass.'Translation')->make()->toArray()
238
+				];
239
+			}
240 240
 
241
-            $docData['models'][$modelName] = json_encode($modelArr, JSON_PRETTY_PRINT);
242
-        }
243
-    }
241
+			$docData['models'][$modelName] = json_encode($modelArr, JSON_PRETTY_PRINT);
242
+		}
243
+	}
244 244
 
245
-    /**
246
-     * Get the route response object type.
247
-     *
248
-     * @param  string $modelName
249
-     * @param  string $method
250
-     * @param  string $returnDocBlock
251
-     * @return array
252
-     */
253
-    protected function getResponseObject($modelName, $method, $returnDocBlock)
254
-    {
255
-        $config    = \CoreConfig::getConfig();
256
-        $relations = Arr::has($config['relations'], $modelName) ? Arr::has($config['relations'][$modelName], $method) ? $config['relations'][$modelName] : false : false;
257
-        $modelName = call_user_func_array("\Core::{$returnDocBlock}", []) ? $returnDocBlock : $modelName;
245
+	/**
246
+	 * Get the route response object type.
247
+	 *
248
+	 * @param  string $modelName
249
+	 * @param  string $method
250
+	 * @param  string $returnDocBlock
251
+	 * @return array
252
+	 */
253
+	protected function getResponseObject($modelName, $method, $returnDocBlock)
254
+	{
255
+		$config    = \CoreConfig::getConfig();
256
+		$relations = Arr::has($config['relations'], $modelName) ? Arr::has($config['relations'][$modelName], $method) ? $config['relations'][$modelName] : false : false;
257
+		$modelName = call_user_func_array("\Core::{$returnDocBlock}", []) ? $returnDocBlock : $modelName;
258 258
 
259
-        return $relations ? [$modelName => $relations && $relations[$method] ? $relations[$method] : []] : false;
260
-    }
259
+		return $relations ? [$modelName => $relations && $relations[$method] ? $relations[$method] : []] : false;
260
+	}
261 261
 }
Please login to merge, or discard this patch.
src/Modules/Core/Routes/api.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@
 block discarded – undo
13 13
 
14 14
 Route::group(['prefix' => 'settings'], function () {
15 15
         
16
-    Route::get('/', 'SettingController@index');
17
-    Route::get('/{id}', 'SettingController@find');
18
-    Route::put('/', 'SettingController@update');
19
-    Route::delete('/{id}', 'SettingController@delete');
20
-    Route::get('list/deleted', 'SettingController@deleted');
21
-    Route::patch('restore/{id}', 'SettingController@restore');
22
-    Route::post('save/many', 'SettingController@saveMany');
16
+	Route::get('/', 'SettingController@index');
17
+	Route::get('/{id}', 'SettingController@find');
18
+	Route::put('/', 'SettingController@update');
19
+	Route::delete('/{id}', 'SettingController@delete');
20
+	Route::get('list/deleted', 'SettingController@deleted');
21
+	Route::patch('restore/{id}', 'SettingController@restore');
22
+	Route::post('save/many', 'SettingController@saveMany');
23 23
 });
24 24
\ No newline at end of file
Please login to merge, or discard this patch.