@@ -7,10 +7,10 @@ |
||
| 7 | 7 | |
| 8 | 8 | class PermissionsController extends BaseApiController |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * The name of the model that is used by the base api controller |
|
| 12 | - * to preform actions like (add, edit ... etc). |
|
| 13 | - * @var string |
|
| 14 | - */ |
|
| 15 | - protected $model = 'permissions'; |
|
| 10 | + /** |
|
| 11 | + * The name of the model that is used by the base api controller |
|
| 12 | + * to preform actions like (add, edit ... etc). |
|
| 13 | + * @var string |
|
| 14 | + */ |
|
| 15 | + protected $model = 'permissions'; |
|
| 16 | 16 | } |
@@ -4,13 +4,13 @@ |
||
| 4 | 4 | { |
| 5 | 5 | /** |
| 6 | 6 | * Construct the repository class name based on |
| 7 | - * the method name called, search in the |
|
| 8 | - * given namespaces for the class and |
|
| 9 | - * return an instance. |
|
| 10 | - * |
|
| 11 | - * @param string $name the called method name |
|
| 12 | - * @param array $arguments the method arguments |
|
| 13 | - * @return object |
|
| 14 | - */ |
|
| 7 | + * the method name called, search in the |
|
| 8 | + * given namespaces for the class and |
|
| 9 | + * return an instance. |
|
| 10 | + * |
|
| 11 | + * @param string $name the called method name |
|
| 12 | + * @param array $arguments the method arguments |
|
| 13 | + * @return object |
|
| 14 | + */ |
|
| 15 | 15 | public function __call($name, $arguments); |
| 16 | 16 | } |
| 17 | 17 | \ No newline at end of file |
@@ -22,15 +22,15 @@ |
||
| 22 | 22 | "); |
| 23 | 23 | |
| 24 | 24 | DB::table('reports')->insert( |
| 25 | - [ |
|
| 26 | - [ |
|
| 25 | + [ |
|
| 26 | + [ |
|
| 27 | 27 | 'report_name' => 'admin_count', |
| 28 | 28 | 'view_name' => 'admin_count', |
| 29 | 29 | 'created_at' => \DB::raw('NOW()'), |
| 30 | 30 | 'updated_at' => \DB::raw('NOW()') |
| 31 | - ] |
|
| 32 | - ] |
|
| 33 | - ); |
|
| 31 | + ] |
|
| 32 | + ] |
|
| 33 | + ); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | $table->string('view_name',100); |
| 19 | 19 | $table->softDeletes(); |
| 20 | 20 | $table->timestamps(); |
| 21 | - }); |
|
| 21 | + }); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -123,6 +123,7 @@ discard block |
||
| 123 | 123 | * |
| 124 | 124 | * @param array &$route |
| 125 | 125 | * @param object $reflectionMethod] |
| 126 | + * @param \ReflectionMethod $reflectionMethod |
|
| 126 | 127 | * @return void |
| 127 | 128 | */ |
| 128 | 129 | protected function processDocBlock(&$route, $reflectionMethod) |
@@ -145,7 +146,7 @@ discard block |
||
| 145 | 146 | * Generate post body for the given route. |
| 146 | 147 | * |
| 147 | 148 | * @param array &$route |
| 148 | - * @param object $reflectionMethod |
|
| 149 | + * @param \ReflectionMethod $reflectionMethod |
|
| 149 | 150 | * @param array $validationRules |
| 150 | 151 | * @return void |
| 151 | 152 | */ |
@@ -6,276 +6,276 @@ |
||
| 6 | 6 | |
| 7 | 7 | class GenerateDoc extends Command |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * The name and signature of the console command. |
|
| 11 | - * |
|
| 12 | - * @var string |
|
| 13 | - */ |
|
| 14 | - protected $signature = 'doc:generate'; |
|
| 9 | + /** |
|
| 10 | + * The name and signature of the console command. |
|
| 11 | + * |
|
| 12 | + * @var string |
|
| 13 | + */ |
|
| 14 | + protected $signature = 'doc:generate'; |
|
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * The console command description. |
|
| 18 | - * |
|
| 19 | - * @var string |
|
| 20 | - */ |
|
| 21 | - protected $description = 'Generate api documentation'; |
|
| 16 | + /** |
|
| 17 | + * The console command description. |
|
| 18 | + * |
|
| 19 | + * @var string |
|
| 20 | + */ |
|
| 21 | + protected $description = 'Generate api documentation'; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Create a new command instance. |
|
| 25 | - * |
|
| 26 | - * @return void |
|
| 27 | - */ |
|
| 28 | - public function __construct() |
|
| 29 | - { |
|
| 30 | - parent::__construct(); |
|
| 31 | - } |
|
| 23 | + /** |
|
| 24 | + * Create a new command instance. |
|
| 25 | + * |
|
| 26 | + * @return void |
|
| 27 | + */ |
|
| 28 | + public function __construct() |
|
| 29 | + { |
|
| 30 | + parent::__construct(); |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Execute the console command. |
|
| 35 | - * |
|
| 36 | - * @return mixed |
|
| 37 | - */ |
|
| 38 | - public function handle() |
|
| 39 | - { |
|
| 40 | - $docData = []; |
|
| 41 | - $docData['models'] = []; |
|
| 42 | - $routes = $this->getRoutes(); |
|
| 43 | - foreach ($routes as $route) |
|
| 44 | - { |
|
| 45 | - if ($route) |
|
| 46 | - { |
|
| 47 | - $actoinArray = explode('@', $route['action']); |
|
| 48 | - if(array_get($actoinArray, 1, false)) |
|
| 49 | - { |
|
| 50 | - $controller = $actoinArray[0]; |
|
| 51 | - $method = $actoinArray[1]; |
|
| 52 | - $route['name'] = $method !== 'index' ? $method : 'list'; |
|
| 33 | + /** |
|
| 34 | + * Execute the console command. |
|
| 35 | + * |
|
| 36 | + * @return mixed |
|
| 37 | + */ |
|
| 38 | + public function handle() |
|
| 39 | + { |
|
| 40 | + $docData = []; |
|
| 41 | + $docData['models'] = []; |
|
| 42 | + $routes = $this->getRoutes(); |
|
| 43 | + foreach ($routes as $route) |
|
| 44 | + { |
|
| 45 | + if ($route) |
|
| 46 | + { |
|
| 47 | + $actoinArray = explode('@', $route['action']); |
|
| 48 | + if(array_get($actoinArray, 1, false)) |
|
| 49 | + { |
|
| 50 | + $controller = $actoinArray[0]; |
|
| 51 | + $method = $actoinArray[1]; |
|
| 52 | + $route['name'] = $method !== 'index' ? $method : 'list'; |
|
| 53 | 53 | |
| 54 | - $reflectionClass = new \ReflectionClass($controller); |
|
| 55 | - $reflectionMethod = $reflectionClass->getMethod($method); |
|
| 56 | - $classProperties = $reflectionClass->getDefaultProperties(); |
|
| 57 | - $skipLoginCheck = array_key_exists('skipLoginCheck', $classProperties) ? $classProperties['skipLoginCheck'] : false; |
|
| 58 | - $validationRules = array_key_exists('validationRules', $classProperties) ? $classProperties['validationRules'] : false; |
|
| 54 | + $reflectionClass = new \ReflectionClass($controller); |
|
| 55 | + $reflectionMethod = $reflectionClass->getMethod($method); |
|
| 56 | + $classProperties = $reflectionClass->getDefaultProperties(); |
|
| 57 | + $skipLoginCheck = array_key_exists('skipLoginCheck', $classProperties) ? $classProperties['skipLoginCheck'] : false; |
|
| 58 | + $validationRules = array_key_exists('validationRules', $classProperties) ? $classProperties['validationRules'] : false; |
|
| 59 | 59 | |
| 60 | - $this->processDocBlock($route, $reflectionMethod); |
|
| 61 | - $this->getHeaders($route, $method, $skipLoginCheck); |
|
| 62 | - $this->getPostData($route, $reflectionMethod, $validationRules); |
|
| 60 | + $this->processDocBlock($route, $reflectionMethod); |
|
| 61 | + $this->getHeaders($route, $method, $skipLoginCheck); |
|
| 62 | + $this->getPostData($route, $reflectionMethod, $validationRules); |
|
| 63 | 63 | |
| 64 | - $route['response'] = $this->getResponseObject($classProperties['model'], $route['name'], $route['returnDocBlock']); |
|
| 64 | + $route['response'] = $this->getResponseObject($classProperties['model'], $route['name'], $route['returnDocBlock']); |
|
| 65 | 65 | |
| 66 | - preg_match('/api\/([^#]+)\//iU', $route['uri'], $module); |
|
| 67 | - $docData['modules'][$module[1]][substr($route['prefix'], strlen('/api/' . $module[1] . '/') - 1)][] = $route; |
|
| 66 | + preg_match('/api\/([^#]+)\//iU', $route['uri'], $module); |
|
| 67 | + $docData['modules'][$module[1]][substr($route['prefix'], strlen('/api/' . $module[1] . '/') - 1)][] = $route; |
|
| 68 | 68 | |
| 69 | - $this->getModels($classProperties['model'], $docData); |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | - } |
|
| 69 | + $this->getModels($classProperties['model'], $docData); |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - $docData['errors'] = $this->getErrors(); |
|
| 75 | - $docData['reports'] = \Core::reports()->all(); |
|
| 76 | - \File::put(app_path('Modules/Core/Resources/api.json'), json_encode($docData)); |
|
| 77 | - } |
|
| 74 | + $docData['errors'] = $this->getErrors(); |
|
| 75 | + $docData['reports'] = \Core::reports()->all(); |
|
| 76 | + \File::put(app_path('Modules/Core/Resources/api.json'), json_encode($docData)); |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * Get list of all registered routes. |
|
| 81 | - * |
|
| 82 | - * @return collection |
|
| 83 | - */ |
|
| 84 | - protected function getRoutes() |
|
| 85 | - { |
|
| 86 | - return collect(\Route::getRoutes())->map(function ($route) { |
|
| 87 | - if (strpos($route->uri(), 'api') !== false) |
|
| 88 | - { |
|
| 89 | - return [ |
|
| 90 | - 'method' => $route->methods()[0], |
|
| 91 | - 'uri' => $route->uri(), |
|
| 92 | - 'action' => $route->getActionName(), |
|
| 93 | - 'prefix' => $route->getPrefix() |
|
| 94 | - ]; |
|
| 95 | - } |
|
| 96 | - return false; |
|
| 97 | - })->all(); |
|
| 98 | - } |
|
| 79 | + /** |
|
| 80 | + * Get list of all registered routes. |
|
| 81 | + * |
|
| 82 | + * @return collection |
|
| 83 | + */ |
|
| 84 | + protected function getRoutes() |
|
| 85 | + { |
|
| 86 | + return collect(\Route::getRoutes())->map(function ($route) { |
|
| 87 | + if (strpos($route->uri(), 'api') !== false) |
|
| 88 | + { |
|
| 89 | + return [ |
|
| 90 | + 'method' => $route->methods()[0], |
|
| 91 | + 'uri' => $route->uri(), |
|
| 92 | + 'action' => $route->getActionName(), |
|
| 93 | + 'prefix' => $route->getPrefix() |
|
| 94 | + ]; |
|
| 95 | + } |
|
| 96 | + return false; |
|
| 97 | + })->all(); |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - /** |
|
| 101 | - * Generate headers for the given route. |
|
| 102 | - * |
|
| 103 | - * @param array &$route |
|
| 104 | - * @param string $method |
|
| 105 | - * @param array $skipLoginCheck |
|
| 106 | - * @return void |
|
| 107 | - */ |
|
| 108 | - protected function getHeaders(&$route, $method, $skipLoginCheck) |
|
| 109 | - { |
|
| 110 | - $route['headers'] = [ |
|
| 111 | - 'Accept' => 'application/json', |
|
| 112 | - 'Content-Type' => 'application/json', |
|
| 113 | - 'locale' => 'The language of the returned data: ar, en or all.', |
|
| 114 | - 'time-zone' => 'Your locale time zone', |
|
| 115 | - ]; |
|
| 100 | + /** |
|
| 101 | + * Generate headers for the given route. |
|
| 102 | + * |
|
| 103 | + * @param array &$route |
|
| 104 | + * @param string $method |
|
| 105 | + * @param array $skipLoginCheck |
|
| 106 | + * @return void |
|
| 107 | + */ |
|
| 108 | + protected function getHeaders(&$route, $method, $skipLoginCheck) |
|
| 109 | + { |
|
| 110 | + $route['headers'] = [ |
|
| 111 | + 'Accept' => 'application/json', |
|
| 112 | + 'Content-Type' => 'application/json', |
|
| 113 | + 'locale' => 'The language of the returned data: ar, en or all.', |
|
| 114 | + 'time-zone' => 'Your locale time zone', |
|
| 115 | + ]; |
|
| 116 | 116 | |
| 117 | 117 | |
| 118 | - if (! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) |
|
| 119 | - { |
|
| 120 | - $route['headers']['Authorization'] = 'Bearer {token}'; |
|
| 121 | - } |
|
| 122 | - } |
|
| 118 | + if (! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) |
|
| 119 | + { |
|
| 120 | + $route['headers']['Authorization'] = 'Bearer {token}'; |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - /** |
|
| 125 | - * Generate description and params for the given route |
|
| 126 | - * based on the docblock. |
|
| 127 | - * |
|
| 128 | - * @param array &$route |
|
| 129 | - * @param object $reflectionMethod] |
|
| 130 | - * @return void |
|
| 131 | - */ |
|
| 132 | - protected function processDocBlock(&$route, $reflectionMethod) |
|
| 133 | - { |
|
| 134 | - $factory = \phpDocumentor\Reflection\DocBlockFactory::createInstance(); |
|
| 135 | - $docblock = $factory->create($reflectionMethod->getDocComment()); |
|
| 136 | - $route['description'] = trim(preg_replace('/\s+/', ' ', $docblock->getSummary())); |
|
| 137 | - $params = $docblock->getTagsByName('param'); |
|
| 138 | - $route['returnDocBlock'] = $docblock->getTagsByName('return')[0]->getType()->getFqsen()->getName(); |
|
| 139 | - foreach ($params as $param) |
|
| 140 | - { |
|
| 141 | - $name = $param->getVariableName(); |
|
| 142 | - if ($name !== 'request') |
|
| 143 | - { |
|
| 144 | - $route['parametars'][$param->getVariableName()] = $param->getDescription()->render(); |
|
| 145 | - } |
|
| 146 | - } |
|
| 147 | - } |
|
| 124 | + /** |
|
| 125 | + * Generate description and params for the given route |
|
| 126 | + * based on the docblock. |
|
| 127 | + * |
|
| 128 | + * @param array &$route |
|
| 129 | + * @param object $reflectionMethod] |
|
| 130 | + * @return void |
|
| 131 | + */ |
|
| 132 | + protected function processDocBlock(&$route, $reflectionMethod) |
|
| 133 | + { |
|
| 134 | + $factory = \phpDocumentor\Reflection\DocBlockFactory::createInstance(); |
|
| 135 | + $docblock = $factory->create($reflectionMethod->getDocComment()); |
|
| 136 | + $route['description'] = trim(preg_replace('/\s+/', ' ', $docblock->getSummary())); |
|
| 137 | + $params = $docblock->getTagsByName('param'); |
|
| 138 | + $route['returnDocBlock'] = $docblock->getTagsByName('return')[0]->getType()->getFqsen()->getName(); |
|
| 139 | + foreach ($params as $param) |
|
| 140 | + { |
|
| 141 | + $name = $param->getVariableName(); |
|
| 142 | + if ($name !== 'request') |
|
| 143 | + { |
|
| 144 | + $route['parametars'][$param->getVariableName()] = $param->getDescription()->render(); |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - /** |
|
| 150 | - * Generate post body for the given route. |
|
| 151 | - * |
|
| 152 | - * @param array &$route |
|
| 153 | - * @param object $reflectionMethod |
|
| 154 | - * @param array $validationRules |
|
| 155 | - * @return void |
|
| 156 | - */ |
|
| 157 | - protected function getPostData(&$route, $reflectionMethod, $validationRules) |
|
| 158 | - { |
|
| 159 | - if ($route['method'] == 'POST') |
|
| 160 | - { |
|
| 161 | - $body = $this->getMethodBody($reflectionMethod); |
|
| 149 | + /** |
|
| 150 | + * Generate post body for the given route. |
|
| 151 | + * |
|
| 152 | + * @param array &$route |
|
| 153 | + * @param object $reflectionMethod |
|
| 154 | + * @param array $validationRules |
|
| 155 | + * @return void |
|
| 156 | + */ |
|
| 157 | + protected function getPostData(&$route, $reflectionMethod, $validationRules) |
|
| 158 | + { |
|
| 159 | + if ($route['method'] == 'POST') |
|
| 160 | + { |
|
| 161 | + $body = $this->getMethodBody($reflectionMethod); |
|
| 162 | 162 | |
| 163 | - preg_match('/\$this->validate\(\$request,([^#]+)\);/iU', $body, $match); |
|
| 164 | - if (count($match)) |
|
| 165 | - { |
|
| 166 | - if ($match[1] == '$this->validationRules') |
|
| 167 | - { |
|
| 168 | - $route['body'] = $validationRules; |
|
| 169 | - } |
|
| 170 | - else |
|
| 171 | - { |
|
| 172 | - $route['body'] = eval('return ' . str_replace(',\'.$request->get(\'id\')', ',{id}\'', $match[1]) . ';'); |
|
| 173 | - } |
|
| 163 | + preg_match('/\$this->validate\(\$request,([^#]+)\);/iU', $body, $match); |
|
| 164 | + if (count($match)) |
|
| 165 | + { |
|
| 166 | + if ($match[1] == '$this->validationRules') |
|
| 167 | + { |
|
| 168 | + $route['body'] = $validationRules; |
|
| 169 | + } |
|
| 170 | + else |
|
| 171 | + { |
|
| 172 | + $route['body'] = eval('return ' . str_replace(',\'.$request->get(\'id\')', ',{id}\'', $match[1]) . ';'); |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - foreach ($route['body'] as &$rule) |
|
| 176 | - { |
|
| 177 | - if(strpos($rule, 'unique')) |
|
| 178 | - { |
|
| 179 | - $rule = substr($rule, 0, strpos($rule, 'unique') + 6); |
|
| 180 | - } |
|
| 181 | - elseif(strpos($rule, 'exists')) |
|
| 182 | - { |
|
| 183 | - $rule = substr($rule, 0, strpos($rule, 'exists') - 1); |
|
| 184 | - } |
|
| 185 | - } |
|
| 186 | - } |
|
| 187 | - else |
|
| 188 | - { |
|
| 189 | - $route['body'] = 'conditions'; |
|
| 190 | - } |
|
| 191 | - } |
|
| 192 | - } |
|
| 175 | + foreach ($route['body'] as &$rule) |
|
| 176 | + { |
|
| 177 | + if(strpos($rule, 'unique')) |
|
| 178 | + { |
|
| 179 | + $rule = substr($rule, 0, strpos($rule, 'unique') + 6); |
|
| 180 | + } |
|
| 181 | + elseif(strpos($rule, 'exists')) |
|
| 182 | + { |
|
| 183 | + $rule = substr($rule, 0, strpos($rule, 'exists') - 1); |
|
| 184 | + } |
|
| 185 | + } |
|
| 186 | + } |
|
| 187 | + else |
|
| 188 | + { |
|
| 189 | + $route['body'] = 'conditions'; |
|
| 190 | + } |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | - /** |
|
| 195 | - * Generate application errors. |
|
| 196 | - * |
|
| 197 | - * @return array |
|
| 198 | - */ |
|
| 199 | - protected function getErrors() |
|
| 200 | - { |
|
| 201 | - $errors = []; |
|
| 202 | - $reflectionClass = new \ReflectionClass('App\Modules\Core\Utl\ErrorHandler'); |
|
| 203 | - foreach ($reflectionClass->getMethods() as $method) |
|
| 204 | - { |
|
| 205 | - $methodName = $method->getName(); |
|
| 206 | - $reflectionMethod = $reflectionClass->getMethod($methodName); |
|
| 207 | - $body = $this->getMethodBody($reflectionMethod); |
|
| 194 | + /** |
|
| 195 | + * Generate application errors. |
|
| 196 | + * |
|
| 197 | + * @return array |
|
| 198 | + */ |
|
| 199 | + protected function getErrors() |
|
| 200 | + { |
|
| 201 | + $errors = []; |
|
| 202 | + $reflectionClass = new \ReflectionClass('App\Modules\Core\Utl\ErrorHandler'); |
|
| 203 | + foreach ($reflectionClass->getMethods() as $method) |
|
| 204 | + { |
|
| 205 | + $methodName = $method->getName(); |
|
| 206 | + $reflectionMethod = $reflectionClass->getMethod($methodName); |
|
| 207 | + $body = $this->getMethodBody($reflectionMethod); |
|
| 208 | 208 | |
| 209 | - preg_match('/\$error=\[\'status\'=>([^#]+)\,/iU', $body, $match); |
|
| 209 | + preg_match('/\$error=\[\'status\'=>([^#]+)\,/iU', $body, $match); |
|
| 210 | 210 | |
| 211 | - if (count($match)) |
|
| 212 | - { |
|
| 213 | - $errors[$match[1]][] = $methodName; |
|
| 214 | - } |
|
| 215 | - } |
|
| 211 | + if (count($match)) |
|
| 212 | + { |
|
| 213 | + $errors[$match[1]][] = $methodName; |
|
| 214 | + } |
|
| 215 | + } |
|
| 216 | 216 | |
| 217 | - return $errors; |
|
| 218 | - } |
|
| 217 | + return $errors; |
|
| 218 | + } |
|
| 219 | 219 | |
| 220 | - /** |
|
| 221 | - * Get the given method body code. |
|
| 222 | - * |
|
| 223 | - * @param object $reflectionMethod |
|
| 224 | - * @return string |
|
| 225 | - */ |
|
| 226 | - protected function getMethodBody($reflectionMethod) |
|
| 227 | - { |
|
| 228 | - $filename = $reflectionMethod->getFileName(); |
|
| 229 | - $start_line = $reflectionMethod->getStartLine() - 1; |
|
| 230 | - $end_line = $reflectionMethod->getEndLine(); |
|
| 231 | - $length = $end_line - $start_line; |
|
| 232 | - $source = file($filename); |
|
| 233 | - $body = implode("", array_slice($source, $start_line, $length)); |
|
| 234 | - $body = trim(preg_replace('/\s+/', '', $body)); |
|
| 220 | + /** |
|
| 221 | + * Get the given method body code. |
|
| 222 | + * |
|
| 223 | + * @param object $reflectionMethod |
|
| 224 | + * @return string |
|
| 225 | + */ |
|
| 226 | + protected function getMethodBody($reflectionMethod) |
|
| 227 | + { |
|
| 228 | + $filename = $reflectionMethod->getFileName(); |
|
| 229 | + $start_line = $reflectionMethod->getStartLine() - 1; |
|
| 230 | + $end_line = $reflectionMethod->getEndLine(); |
|
| 231 | + $length = $end_line - $start_line; |
|
| 232 | + $source = file($filename); |
|
| 233 | + $body = implode("", array_slice($source, $start_line, $length)); |
|
| 234 | + $body = trim(preg_replace('/\s+/', '', $body)); |
|
| 235 | 235 | |
| 236 | - return $body; |
|
| 237 | - } |
|
| 236 | + return $body; |
|
| 237 | + } |
|
| 238 | 238 | |
| 239 | - /** |
|
| 240 | - * Get example object of all availble models. |
|
| 241 | - * |
|
| 242 | - * @param string $modelName |
|
| 243 | - * @param array $docData |
|
| 244 | - * @return string |
|
| 245 | - */ |
|
| 246 | - protected function getModels($modelName, &$docData) |
|
| 247 | - { |
|
| 248 | - if ($modelName && ! array_key_exists($modelName, $docData['models'])) |
|
| 249 | - { |
|
| 250 | - $modelClass = call_user_func_array("\Core::{$modelName}", [])->modelClass; |
|
| 251 | - $model = factory($modelClass)->make(); |
|
| 252 | - $modelArr = $model->toArray(); |
|
| 239 | + /** |
|
| 240 | + * Get example object of all availble models. |
|
| 241 | + * |
|
| 242 | + * @param string $modelName |
|
| 243 | + * @param array $docData |
|
| 244 | + * @return string |
|
| 245 | + */ |
|
| 246 | + protected function getModels($modelName, &$docData) |
|
| 247 | + { |
|
| 248 | + if ($modelName && ! array_key_exists($modelName, $docData['models'])) |
|
| 249 | + { |
|
| 250 | + $modelClass = call_user_func_array("\Core::{$modelName}", [])->modelClass; |
|
| 251 | + $model = factory($modelClass)->make(); |
|
| 252 | + $modelArr = $model->toArray(); |
|
| 253 | 253 | |
| 254 | - if ( $model->trans && ! $model->trans->count()) |
|
| 255 | - { |
|
| 256 | - $modelArr['trans'] = [ |
|
| 257 | - 'en' => factory($modelClass . 'Translation')->make()->toArray() |
|
| 258 | - ]; |
|
| 259 | - } |
|
| 254 | + if ( $model->trans && ! $model->trans->count()) |
|
| 255 | + { |
|
| 256 | + $modelArr['trans'] = [ |
|
| 257 | + 'en' => factory($modelClass . 'Translation')->make()->toArray() |
|
| 258 | + ]; |
|
| 259 | + } |
|
| 260 | 260 | |
| 261 | - $docData['models'][$modelName] = json_encode($modelArr, JSON_PRETTY_PRINT); |
|
| 262 | - } |
|
| 263 | - } |
|
| 261 | + $docData['models'][$modelName] = json_encode($modelArr, JSON_PRETTY_PRINT); |
|
| 262 | + } |
|
| 263 | + } |
|
| 264 | 264 | |
| 265 | - /** |
|
| 266 | - * Get the route response object type. |
|
| 267 | - * |
|
| 268 | - * @param string $modelName |
|
| 269 | - * @param string $method |
|
| 270 | - * @param string $returnDocBlock |
|
| 271 | - * @return array |
|
| 272 | - */ |
|
| 273 | - protected function getResponseObject($modelName, $method, $returnDocBlock) |
|
| 274 | - { |
|
| 275 | - $config = \CoreConfig::getConfig(); |
|
| 276 | - $relations = array_key_exists($modelName, $config['relations']) ? array_key_exists($method, $config['relations'][$modelName]) ? $config['relations'][$modelName] : false : false; |
|
| 277 | - $modelName = call_user_func_array("\Core::{$returnDocBlock}", []) ? $returnDocBlock : $modelName; |
|
| 265 | + /** |
|
| 266 | + * Get the route response object type. |
|
| 267 | + * |
|
| 268 | + * @param string $modelName |
|
| 269 | + * @param string $method |
|
| 270 | + * @param string $returnDocBlock |
|
| 271 | + * @return array |
|
| 272 | + */ |
|
| 273 | + protected function getResponseObject($modelName, $method, $returnDocBlock) |
|
| 274 | + { |
|
| 275 | + $config = \CoreConfig::getConfig(); |
|
| 276 | + $relations = array_key_exists($modelName, $config['relations']) ? array_key_exists($method, $config['relations'][$modelName]) ? $config['relations'][$modelName] : false : false; |
|
| 277 | + $modelName = call_user_func_array("\Core::{$returnDocBlock}", []) ? $returnDocBlock : $modelName; |
|
| 278 | 278 | |
| 279 | - return $relations ? [$modelName => $relations && $relations[$method] ? $relations[$method] : []] : false; |
|
| 280 | - } |
|
| 279 | + return $relations ? [$modelName => $relations && $relations[$method] ? $relations[$method] : []] : false; |
|
| 280 | + } |
|
| 281 | 281 | } |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | * Get the notification's delivery channels. |
| 29 | 29 | * |
| 30 | 30 | * @param mixed $notifiable |
| 31 | - * @return array |
|
| 31 | + * @return string[] |
|
| 32 | 32 | */ |
| 33 | 33 | public function via($notifiable) |
| 34 | 34 | { |
@@ -10,43 +10,43 @@ |
||
| 10 | 10 | |
| 11 | 11 | class ResetPassword extends Notification implements ShouldQueue |
| 12 | 12 | { |
| 13 | - use Queueable; |
|
| 13 | + use Queueable; |
|
| 14 | 14 | |
| 15 | - protected $token; |
|
| 15 | + protected $token; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Create a new notification instance. |
|
| 19 | - * |
|
| 20 | - * @return void |
|
| 21 | - */ |
|
| 22 | - public function __construct($token) |
|
| 23 | - { |
|
| 24 | - $this->token = $token; |
|
| 25 | - } |
|
| 17 | + /** |
|
| 18 | + * Create a new notification instance. |
|
| 19 | + * |
|
| 20 | + * @return void |
|
| 21 | + */ |
|
| 22 | + public function __construct($token) |
|
| 23 | + { |
|
| 24 | + $this->token = $token; |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Get the notification's delivery channels. |
|
| 29 | - * |
|
| 30 | - * @param mixed $notifiable |
|
| 31 | - * @return array |
|
| 32 | - */ |
|
| 33 | - public function via($notifiable) |
|
| 34 | - { |
|
| 35 | - return ['mail']; |
|
| 36 | - } |
|
| 27 | + /** |
|
| 28 | + * Get the notification's delivery channels. |
|
| 29 | + * |
|
| 30 | + * @param mixed $notifiable |
|
| 31 | + * @return array |
|
| 32 | + */ |
|
| 33 | + public function via($notifiable) |
|
| 34 | + { |
|
| 35 | + return ['mail']; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Get the mail representation of the notification. |
|
| 40 | - * |
|
| 41 | - * @param mixed $notifiable |
|
| 42 | - * @return \Illuminate\Notifications\Messages\MailMessage |
|
| 43 | - */ |
|
| 44 | - public function toMail($notifiable) |
|
| 45 | - { |
|
| 46 | - return (new MailMessage) |
|
| 47 | - ->subject('Reset passowrd') |
|
| 48 | - ->line('Reset passowrd') |
|
| 49 | - ->line('To reset your password click on the button below') |
|
| 50 | - ->action('Reset password', config('skeleton.reset_password_url') . '/' . $this->token); |
|
| 51 | - } |
|
| 38 | + /** |
|
| 39 | + * Get the mail representation of the notification. |
|
| 40 | + * |
|
| 41 | + * @param mixed $notifiable |
|
| 42 | + * @return \Illuminate\Notifications\Messages\MailMessage |
|
| 43 | + */ |
|
| 44 | + public function toMail($notifiable) |
|
| 45 | + { |
|
| 46 | + return (new MailMessage) |
|
| 47 | + ->subject('Reset passowrd') |
|
| 48 | + ->line('Reset passowrd') |
|
| 49 | + ->line('To reset your password click on the button below') |
|
| 50 | + ->action('Reset password', config('skeleton.reset_password_url') . '/' . $this->token); |
|
| 51 | + } |
|
| 52 | 52 | } |
| 53 | 53 | \ No newline at end of file |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | * Register the given device to the logged in user. |
| 22 | 22 | * |
| 23 | 23 | * @param string $data |
| 24 | - * @return void |
|
| 24 | + * @return boolean |
|
| 25 | 25 | */ |
| 26 | 26 | public function registerDevice($data) |
| 27 | 27 | { |
@@ -7,56 +7,56 @@ |
||
| 7 | 7 | |
| 8 | 8 | class PushNotificationDeviceRepository extends AbstractRepository |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * Return the model full namespace. |
|
| 12 | - * |
|
| 13 | - * @return string |
|
| 14 | - */ |
|
| 15 | - protected function getModel() |
|
| 16 | - { |
|
| 17 | - return 'App\Modules\Notifications\PushNotificationDevice'; |
|
| 18 | - } |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * Register the given device to the logged in user. |
|
| 22 | - * |
|
| 23 | - * @param string $data |
|
| 24 | - * @return void |
|
| 25 | - */ |
|
| 26 | - public function registerDevice($data) |
|
| 27 | - { |
|
| 28 | - $data['access_token'] = \Auth::user()->token(); |
|
| 29 | - $data['user_id'] = \Auth::id(); |
|
| 30 | - if ($device = $this->model->where('device_token', $data['device_token'])->where('user_id', $data['user_id'])->first()) |
|
| 31 | - { |
|
| 32 | - $data['id'] = $device->id; |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - return $this->save($data); |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * Generate the given message data. |
|
| 40 | - * |
|
| 41 | - * @param string $title |
|
| 42 | - * @param string $message |
|
| 43 | - * @param string $data |
|
| 44 | - * @return void |
|
| 45 | - */ |
|
| 46 | - public function generateMessageData($title, $message, $data = []) |
|
| 47 | - { |
|
| 48 | - $optionBuilder = new OptionsBuilder(); |
|
| 49 | - $notificationBuilder = new PayloadNotificationBuilder($title); |
|
| 50 | - $dataBuilder = new PayloadDataBuilder(); |
|
| 51 | - |
|
| 52 | - $optionBuilder->setTimeToLive(60*20); |
|
| 53 | - $notificationBuilder->setBody($message); |
|
| 54 | - $dataBuilder->addData($data); |
|
| 55 | - |
|
| 56 | - $options = $optionBuilder->build(); |
|
| 57 | - $notification = $notificationBuilder->build(); |
|
| 58 | - $data = $dataBuilder->build(); |
|
| 59 | - |
|
| 60 | - return compact('options', 'notification', 'data'); |
|
| 61 | - } |
|
| 10 | + /** |
|
| 11 | + * Return the model full namespace. |
|
| 12 | + * |
|
| 13 | + * @return string |
|
| 14 | + */ |
|
| 15 | + protected function getModel() |
|
| 16 | + { |
|
| 17 | + return 'App\Modules\Notifications\PushNotificationDevice'; |
|
| 18 | + } |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * Register the given device to the logged in user. |
|
| 22 | + * |
|
| 23 | + * @param string $data |
|
| 24 | + * @return void |
|
| 25 | + */ |
|
| 26 | + public function registerDevice($data) |
|
| 27 | + { |
|
| 28 | + $data['access_token'] = \Auth::user()->token(); |
|
| 29 | + $data['user_id'] = \Auth::id(); |
|
| 30 | + if ($device = $this->model->where('device_token', $data['device_token'])->where('user_id', $data['user_id'])->first()) |
|
| 31 | + { |
|
| 32 | + $data['id'] = $device->id; |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + return $this->save($data); |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * Generate the given message data. |
|
| 40 | + * |
|
| 41 | + * @param string $title |
|
| 42 | + * @param string $message |
|
| 43 | + * @param string $data |
|
| 44 | + * @return void |
|
| 45 | + */ |
|
| 46 | + public function generateMessageData($title, $message, $data = []) |
|
| 47 | + { |
|
| 48 | + $optionBuilder = new OptionsBuilder(); |
|
| 49 | + $notificationBuilder = new PayloadNotificationBuilder($title); |
|
| 50 | + $dataBuilder = new PayloadDataBuilder(); |
|
| 51 | + |
|
| 52 | + $optionBuilder->setTimeToLive(60*20); |
|
| 53 | + $notificationBuilder->setBody($message); |
|
| 54 | + $dataBuilder->addData($data); |
|
| 55 | + |
|
| 56 | + $options = $optionBuilder->build(); |
|
| 57 | + $notification = $notificationBuilder->build(); |
|
| 58 | + $data = $dataBuilder->build(); |
|
| 59 | + |
|
| 60 | + return compact('options', 'notification', 'data'); |
|
| 61 | + } |
|
| 62 | 62 | } |
@@ -5,32 +5,32 @@ |
||
| 5 | 5 | |
| 6 | 6 | class Report extends Model{ |
| 7 | 7 | |
| 8 | - use SoftDeletes; |
|
| 8 | + use SoftDeletes; |
|
| 9 | 9 | protected $table = 'reports'; |
| 10 | 10 | protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
| 11 | 11 | protected $hidden = ['deleted_at']; |
| 12 | 12 | protected $guarded = ['id']; |
| 13 | 13 | protected $fillable = ['report_name', 'view_name']; |
| 14 | - public $searchable = ['report_name', 'view_name']; |
|
| 14 | + public $searchable = ['report_name', 'view_name']; |
|
| 15 | 15 | |
| 16 | 16 | public function getCreatedAtAttribute($value) |
| 17 | - { |
|
| 18 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 19 | - } |
|
| 17 | + { |
|
| 18 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - public function getUpdatedAtAttribute($value) |
|
| 22 | - { |
|
| 23 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 24 | - } |
|
| 21 | + public function getUpdatedAtAttribute($value) |
|
| 22 | + { |
|
| 23 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - public function getDeletedAtAttribute($value) |
|
| 27 | - { |
|
| 28 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 29 | - } |
|
| 26 | + public function getDeletedAtAttribute($value) |
|
| 27 | + { |
|
| 28 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - public static function boot() |
|
| 32 | - { |
|
| 33 | - parent::boot(); |
|
| 34 | - parent::observe(\App::make('App\Modules\Reporting\ModelObservers\ReprotObserver')); |
|
| 35 | - } |
|
| 31 | + public static function boot() |
|
| 32 | + { |
|
| 33 | + parent::boot(); |
|
| 34 | + parent::observe(\App::make('App\Modules\Reporting\ModelObservers\ReprotObserver')); |
|
| 35 | + } |
|
| 36 | 36 | } |
@@ -8,72 +8,72 @@ |
||
| 8 | 8 | class RouteServiceProvider extends ServiceProvider |
| 9 | 9 | { |
| 10 | 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\Reporting\Http\Controllers'; |
|
| 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\Reporting\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('reporting', 'Routes/web.php'); |
|
| 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('reporting', 'Routes/web.php'); |
|
| 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('reporting', 'Routes/api.php'); |
|
| 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('reporting', 'Routes/api.php'); |
|
| 77 | + }); |
|
| 78 | + } |
|
| 79 | 79 | } |