@@ -9,311 +9,311 @@ |
||
9 | 9 | |
10 | 10 | class GenerateDocCommand extends Command |
11 | 11 | { |
12 | - /** |
|
13 | - * The name and signature of the console command. |
|
14 | - * |
|
15 | - * @var string |
|
16 | - */ |
|
17 | - protected $signature = 'doc:generate'; |
|
18 | - |
|
19 | - /** |
|
20 | - * The console command description. |
|
21 | - * |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - protected $description = 'Generate api documentation'; |
|
25 | - |
|
26 | - /** |
|
27 | - * @var ReprotService |
|
28 | - */ |
|
29 | - protected $reportService; |
|
30 | - |
|
31 | - /** |
|
32 | - * Init new object. |
|
33 | - * |
|
34 | - * @return void |
|
35 | - */ |
|
36 | - public function __construct(ReportService $reportService) |
|
37 | - { |
|
38 | - $this->reportService = $reportService; |
|
39 | - parent::__construct(); |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * Execute the console command. |
|
44 | - * |
|
45 | - * @return mixed |
|
46 | - */ |
|
47 | - public function handle() |
|
48 | - { |
|
49 | - $docData = []; |
|
50 | - $docData['models'] = []; |
|
51 | - $routes = $this->getRoutes(); |
|
52 | - foreach ($routes as $route) { |
|
53 | - if ($route) { |
|
54 | - $actoinArray = explode('@', $route['action']); |
|
55 | - if (Arr::get($actoinArray, 1, false)) { |
|
56 | - $prefix = $route['prefix']; |
|
57 | - $module = \Str::camel(str_replace('/', '_', str_replace('api', '', $prefix))); |
|
58 | - if ($prefix === 'telescope') { |
|
59 | - continue; |
|
60 | - } |
|
61 | - |
|
62 | - $controller = $actoinArray[0]; |
|
63 | - $method = $actoinArray[1]; |
|
64 | - $route['name'] = $method; |
|
65 | - $reflectionClass = new \ReflectionClass($controller); |
|
66 | - $reflectionMethod = $reflectionClass->getMethod($method); |
|
67 | - $classProperties = $reflectionClass->getDefaultProperties(); |
|
68 | - $skipLoginCheck = Arr::get($classProperties, 'skipLoginCheck', false); |
|
69 | - $modelName = explode('\\', $controller); |
|
70 | - $modelName = lcfirst(str_replace('Controller', '', end($modelName))); |
|
71 | - |
|
72 | - $this->processDocBlock($route, $reflectionMethod); |
|
73 | - $this->getHeaders($route, $method, $skipLoginCheck); |
|
74 | - $this->getPostData($route, $reflectionMethod, explode('\\', $reflectionClass->getName())[2], $modelName); |
|
75 | - |
|
76 | - $route['response'] = $this->getResponseObject($modelName, $route['name'], $route['returnDocBlock']); |
|
77 | - $docData['modules'][$module][] = $route; |
|
78 | - |
|
79 | - $this->getModels($modelName, $docData, $reflectionClass); |
|
80 | - } |
|
81 | - } |
|
82 | - } |
|
12 | + /** |
|
13 | + * The name and signature of the console command. |
|
14 | + * |
|
15 | + * @var string |
|
16 | + */ |
|
17 | + protected $signature = 'doc:generate'; |
|
18 | + |
|
19 | + /** |
|
20 | + * The console command description. |
|
21 | + * |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + protected $description = 'Generate api documentation'; |
|
25 | + |
|
26 | + /** |
|
27 | + * @var ReprotService |
|
28 | + */ |
|
29 | + protected $reportService; |
|
30 | + |
|
31 | + /** |
|
32 | + * Init new object. |
|
33 | + * |
|
34 | + * @return void |
|
35 | + */ |
|
36 | + public function __construct(ReportService $reportService) |
|
37 | + { |
|
38 | + $this->reportService = $reportService; |
|
39 | + parent::__construct(); |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * Execute the console command. |
|
44 | + * |
|
45 | + * @return mixed |
|
46 | + */ |
|
47 | + public function handle() |
|
48 | + { |
|
49 | + $docData = []; |
|
50 | + $docData['models'] = []; |
|
51 | + $routes = $this->getRoutes(); |
|
52 | + foreach ($routes as $route) { |
|
53 | + if ($route) { |
|
54 | + $actoinArray = explode('@', $route['action']); |
|
55 | + if (Arr::get($actoinArray, 1, false)) { |
|
56 | + $prefix = $route['prefix']; |
|
57 | + $module = \Str::camel(str_replace('/', '_', str_replace('api', '', $prefix))); |
|
58 | + if ($prefix === 'telescope') { |
|
59 | + continue; |
|
60 | + } |
|
61 | + |
|
62 | + $controller = $actoinArray[0]; |
|
63 | + $method = $actoinArray[1]; |
|
64 | + $route['name'] = $method; |
|
65 | + $reflectionClass = new \ReflectionClass($controller); |
|
66 | + $reflectionMethod = $reflectionClass->getMethod($method); |
|
67 | + $classProperties = $reflectionClass->getDefaultProperties(); |
|
68 | + $skipLoginCheck = Arr::get($classProperties, 'skipLoginCheck', false); |
|
69 | + $modelName = explode('\\', $controller); |
|
70 | + $modelName = lcfirst(str_replace('Controller', '', end($modelName))); |
|
71 | + |
|
72 | + $this->processDocBlock($route, $reflectionMethod); |
|
73 | + $this->getHeaders($route, $method, $skipLoginCheck); |
|
74 | + $this->getPostData($route, $reflectionMethod, explode('\\', $reflectionClass->getName())[2], $modelName); |
|
75 | + |
|
76 | + $route['response'] = $this->getResponseObject($modelName, $route['name'], $route['returnDocBlock']); |
|
77 | + $docData['modules'][$module][] = $route; |
|
78 | + |
|
79 | + $this->getModels($modelName, $docData, $reflectionClass); |
|
80 | + } |
|
81 | + } |
|
82 | + } |
|
83 | 83 | |
84 | - $docData['errors'] = $this->getErrors(); |
|
85 | - $docData['reports'] = $this->reportService->all(); |
|
86 | - \File::put(app_path('Modules/Core/Resources/api.json'), json_encode($docData)); |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * Get list of all registered routes. |
|
91 | - * |
|
92 | - * @return collection |
|
93 | - */ |
|
94 | - protected function getRoutes() |
|
95 | - { |
|
96 | - return collect(\Route::getRoutes())->map(function ($route) { |
|
97 | - if (strpos($route->uri(), 'api/') !== false) { |
|
98 | - return [ |
|
99 | - 'method' => $route->methods()[0], |
|
100 | - 'uri' => $route->uri(), |
|
101 | - 'action' => $route->getActionName(), |
|
102 | - 'prefix' => $route->getPrefix() |
|
103 | - ]; |
|
104 | - } |
|
105 | - return false; |
|
106 | - })->all(); |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * Generate headers for the given route. |
|
111 | - * |
|
112 | - * @param array &$route |
|
113 | - * @param string $method |
|
114 | - * @param array $skipLoginCheck |
|
115 | - * @return void |
|
116 | - */ |
|
117 | - protected function getHeaders(&$route, $method, $skipLoginCheck) |
|
118 | - { |
|
119 | - $route['headers'] = [ |
|
120 | - 'Accept' => 'application/json', |
|
121 | - 'Content-Type' => 'application/json', |
|
122 | - 'Accept-Language' => 'The language of the returned data: ar, en or all.', |
|
123 | - 'time-zone' => 'Your locale time zone', |
|
124 | - ]; |
|
125 | - |
|
126 | - |
|
127 | - if (! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) { |
|
128 | - $route['headers']['Authorization'] = 'Bearer {token}'; |
|
129 | - } |
|
130 | - } |
|
131 | - |
|
132 | - /** |
|
133 | - * Generate description and params for the given route |
|
134 | - * based on the docblock. |
|
135 | - * |
|
136 | - * @param array &$route |
|
137 | - * @param \ReflectionMethod $reflectionMethod |
|
138 | - * @return void |
|
139 | - */ |
|
140 | - protected function processDocBlock(&$route, $reflectionMethod) |
|
141 | - { |
|
142 | - $factory = \phpDocumentor\Reflection\DocBlockFactory::createInstance(); |
|
143 | - $docblock = $factory->create($reflectionMethod->getDocComment()); |
|
144 | - $route['description'] = trim(preg_replace('/\s+/', ' ', $docblock->getSummary())); |
|
145 | - $params = $docblock->getTagsByName('param'); |
|
146 | - $route['returnDocBlock'] = $docblock->getTagsByName('return')[0]->getType()->getFqsen()->getName(); |
|
147 | - |
|
148 | - foreach ($params as $param) { |
|
149 | - $name = $param->getVariableName(); |
|
150 | - if ($name == 'perPage') { |
|
151 | - $route['parametars'][$name] = 'perPage? number of records per page default 15'; |
|
152 | - } elseif ($name == 'sortBy') { |
|
153 | - $route['parametars'][$name] = 'sortBy? sort column default created_at'; |
|
154 | - } elseif ($name == 'desc') { |
|
155 | - $route['parametars'][$name] = 'desc? sort descending or ascending default is descending'; |
|
156 | - } elseif ($name !== 'request') { |
|
157 | - $route['parametars'][$name] = $param->getDescription()->render(); |
|
158 | - } |
|
159 | - } |
|
160 | - |
|
161 | - if ($route['name'] === 'index') { |
|
162 | - $route['parametars']['perPage'] = 'perPage? number of records per page default 15'; |
|
163 | - $route['parametars']['sortBy'] = 'sortBy? sort column default created_at'; |
|
164 | - $route['parametars']['desc'] = 'desc? sort descending or ascending default is descending'; |
|
165 | - $route['parametars']['trashed'] = 'trashed? retreive trashed or not default not'; |
|
166 | - } |
|
167 | - } |
|
168 | - |
|
169 | - /** |
|
170 | - * Generate post body for the given route. |
|
171 | - * |
|
172 | - * @param array &$route |
|
173 | - * @param \ReflectionMethod $reflectionMethod |
|
174 | - * @param string $module |
|
175 | - * @param string $modelName |
|
176 | - * @return void |
|
177 | - */ |
|
178 | - protected function getPostData(&$route, $reflectionMethod, $module, $modelName) |
|
179 | - { |
|
180 | - request()->setMethod($route['method']); |
|
181 | - $parameters = $reflectionMethod->getParameters(); |
|
182 | - $className = optional(optional(\Arr::get($parameters, 0))->getType())->getName(); |
|
183 | - if ($className) { |
|
184 | - $reflectionClass = new \ReflectionClass($className); |
|
185 | - } elseif (in_array($reflectionMethod->getName(), ['store', 'update'])) { |
|
186 | - $className = 'App\\Modules\\' . ucfirst($module) . '\\Http\\Requests\\Store' . ucfirst($modelName); |
|
187 | - $reflectionClass = new \ReflectionClass($className); |
|
188 | - } |
|
189 | - |
|
190 | - if (isset($reflectionClass) && $reflectionClass->hasMethod('rules')) { |
|
191 | - $reflectionMethod = $reflectionClass->getMethod('rules'); |
|
192 | - $route['body'] = $reflectionMethod->invoke(new $className); |
|
193 | - |
|
194 | - foreach ($route['body'] as &$rule) { |
|
195 | - if (strpos($rule, 'unique')) { |
|
196 | - $rule = substr($rule, 0, strpos($rule, 'unique') + 6); |
|
197 | - } elseif (strpos($rule, 'exists')) { |
|
198 | - $rule = substr($rule, 0, strpos($rule, 'exists') - 1); |
|
199 | - } |
|
200 | - } |
|
201 | - } |
|
202 | - } |
|
203 | - |
|
204 | - /** |
|
205 | - * Generate application errors. |
|
206 | - * |
|
207 | - * @return array |
|
208 | - */ |
|
209 | - protected function getErrors() |
|
210 | - { |
|
211 | - $errors = []; |
|
212 | - foreach (\Module::all() as $module) { |
|
213 | - $nameSpace = 'App\\Modules\\' . $module['basename']; |
|
214 | - $class = $nameSpace . '\\Errors\\' . $module['basename'] . 'Errors'; |
|
215 | - $reflectionClass = new \ReflectionClass($class); |
|
216 | - foreach ($reflectionClass->getMethods() as $method) { |
|
217 | - $methodName = $method->name; |
|
218 | - $reflectionMethod = $reflectionClass->getMethod($methodName); |
|
219 | - $body = $this->getMethodBody($reflectionMethod); |
|
220 | - |
|
221 | - preg_match('/abort\(([^#]+)\,/iU', $body, $match); |
|
222 | - |
|
223 | - if (count($match)) { |
|
224 | - $errors[$match[1]][] = $methodName; |
|
225 | - } |
|
226 | - } |
|
227 | - } |
|
228 | - |
|
229 | - return $errors; |
|
230 | - } |
|
231 | - |
|
232 | - /** |
|
233 | - * Get the given method body code. |
|
234 | - * |
|
235 | - * @param object $reflectionMethod |
|
236 | - * @return string |
|
237 | - */ |
|
238 | - protected function getMethodBody($reflectionMethod) |
|
239 | - { |
|
240 | - $filename = $reflectionMethod->getFileName(); |
|
241 | - $start_line = $reflectionMethod->getStartLine() - 1; |
|
242 | - $end_line = $reflectionMethod->getEndLine(); |
|
243 | - $length = $end_line - $start_line; |
|
244 | - $source = file($filename); |
|
245 | - $body = implode("", array_slice($source, $start_line, $length)); |
|
246 | - $body = trim(preg_replace('/\s+/', '', $body)); |
|
247 | - |
|
248 | - return $body; |
|
249 | - } |
|
250 | - |
|
251 | - /** |
|
252 | - * Get example object of all availble models. |
|
253 | - * |
|
254 | - * @param string $modelName |
|
255 | - * @param array $docData |
|
256 | - * @return string |
|
257 | - */ |
|
258 | - protected function getModels($modelName, &$docData, $reflectionClass) |
|
259 | - { |
|
260 | - if ($modelName && ! Arr::has($docData['models'], $modelName)) { |
|
261 | - $repo = call_user_func_array("\Core::{$modelName}", []); |
|
262 | - if (! $repo) { |
|
263 | - return; |
|
264 | - } |
|
84 | + $docData['errors'] = $this->getErrors(); |
|
85 | + $docData['reports'] = $this->reportService->all(); |
|
86 | + \File::put(app_path('Modules/Core/Resources/api.json'), json_encode($docData)); |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * Get list of all registered routes. |
|
91 | + * |
|
92 | + * @return collection |
|
93 | + */ |
|
94 | + protected function getRoutes() |
|
95 | + { |
|
96 | + return collect(\Route::getRoutes())->map(function ($route) { |
|
97 | + if (strpos($route->uri(), 'api/') !== false) { |
|
98 | + return [ |
|
99 | + 'method' => $route->methods()[0], |
|
100 | + 'uri' => $route->uri(), |
|
101 | + 'action' => $route->getActionName(), |
|
102 | + 'prefix' => $route->getPrefix() |
|
103 | + ]; |
|
104 | + } |
|
105 | + return false; |
|
106 | + })->all(); |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * Generate headers for the given route. |
|
111 | + * |
|
112 | + * @param array &$route |
|
113 | + * @param string $method |
|
114 | + * @param array $skipLoginCheck |
|
115 | + * @return void |
|
116 | + */ |
|
117 | + protected function getHeaders(&$route, $method, $skipLoginCheck) |
|
118 | + { |
|
119 | + $route['headers'] = [ |
|
120 | + 'Accept' => 'application/json', |
|
121 | + 'Content-Type' => 'application/json', |
|
122 | + 'Accept-Language' => 'The language of the returned data: ar, en or all.', |
|
123 | + 'time-zone' => 'Your locale time zone', |
|
124 | + ]; |
|
125 | + |
|
126 | + |
|
127 | + if (! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) { |
|
128 | + $route['headers']['Authorization'] = 'Bearer {token}'; |
|
129 | + } |
|
130 | + } |
|
131 | + |
|
132 | + /** |
|
133 | + * Generate description and params for the given route |
|
134 | + * based on the docblock. |
|
135 | + * |
|
136 | + * @param array &$route |
|
137 | + * @param \ReflectionMethod $reflectionMethod |
|
138 | + * @return void |
|
139 | + */ |
|
140 | + protected function processDocBlock(&$route, $reflectionMethod) |
|
141 | + { |
|
142 | + $factory = \phpDocumentor\Reflection\DocBlockFactory::createInstance(); |
|
143 | + $docblock = $factory->create($reflectionMethod->getDocComment()); |
|
144 | + $route['description'] = trim(preg_replace('/\s+/', ' ', $docblock->getSummary())); |
|
145 | + $params = $docblock->getTagsByName('param'); |
|
146 | + $route['returnDocBlock'] = $docblock->getTagsByName('return')[0]->getType()->getFqsen()->getName(); |
|
147 | + |
|
148 | + foreach ($params as $param) { |
|
149 | + $name = $param->getVariableName(); |
|
150 | + if ($name == 'perPage') { |
|
151 | + $route['parametars'][$name] = 'perPage? number of records per page default 15'; |
|
152 | + } elseif ($name == 'sortBy') { |
|
153 | + $route['parametars'][$name] = 'sortBy? sort column default created_at'; |
|
154 | + } elseif ($name == 'desc') { |
|
155 | + $route['parametars'][$name] = 'desc? sort descending or ascending default is descending'; |
|
156 | + } elseif ($name !== 'request') { |
|
157 | + $route['parametars'][$name] = $param->getDescription()->render(); |
|
158 | + } |
|
159 | + } |
|
160 | + |
|
161 | + if ($route['name'] === 'index') { |
|
162 | + $route['parametars']['perPage'] = 'perPage? number of records per page default 15'; |
|
163 | + $route['parametars']['sortBy'] = 'sortBy? sort column default created_at'; |
|
164 | + $route['parametars']['desc'] = 'desc? sort descending or ascending default is descending'; |
|
165 | + $route['parametars']['trashed'] = 'trashed? retreive trashed or not default not'; |
|
166 | + } |
|
167 | + } |
|
168 | + |
|
169 | + /** |
|
170 | + * Generate post body for the given route. |
|
171 | + * |
|
172 | + * @param array &$route |
|
173 | + * @param \ReflectionMethod $reflectionMethod |
|
174 | + * @param string $module |
|
175 | + * @param string $modelName |
|
176 | + * @return void |
|
177 | + */ |
|
178 | + protected function getPostData(&$route, $reflectionMethod, $module, $modelName) |
|
179 | + { |
|
180 | + request()->setMethod($route['method']); |
|
181 | + $parameters = $reflectionMethod->getParameters(); |
|
182 | + $className = optional(optional(\Arr::get($parameters, 0))->getType())->getName(); |
|
183 | + if ($className) { |
|
184 | + $reflectionClass = new \ReflectionClass($className); |
|
185 | + } elseif (in_array($reflectionMethod->getName(), ['store', 'update'])) { |
|
186 | + $className = 'App\\Modules\\' . ucfirst($module) . '\\Http\\Requests\\Store' . ucfirst($modelName); |
|
187 | + $reflectionClass = new \ReflectionClass($className); |
|
188 | + } |
|
189 | + |
|
190 | + if (isset($reflectionClass) && $reflectionClass->hasMethod('rules')) { |
|
191 | + $reflectionMethod = $reflectionClass->getMethod('rules'); |
|
192 | + $route['body'] = $reflectionMethod->invoke(new $className); |
|
193 | + |
|
194 | + foreach ($route['body'] as &$rule) { |
|
195 | + if (strpos($rule, 'unique')) { |
|
196 | + $rule = substr($rule, 0, strpos($rule, 'unique') + 6); |
|
197 | + } elseif (strpos($rule, 'exists')) { |
|
198 | + $rule = substr($rule, 0, strpos($rule, 'exists') - 1); |
|
199 | + } |
|
200 | + } |
|
201 | + } |
|
202 | + } |
|
203 | + |
|
204 | + /** |
|
205 | + * Generate application errors. |
|
206 | + * |
|
207 | + * @return array |
|
208 | + */ |
|
209 | + protected function getErrors() |
|
210 | + { |
|
211 | + $errors = []; |
|
212 | + foreach (\Module::all() as $module) { |
|
213 | + $nameSpace = 'App\\Modules\\' . $module['basename']; |
|
214 | + $class = $nameSpace . '\\Errors\\' . $module['basename'] . 'Errors'; |
|
215 | + $reflectionClass = new \ReflectionClass($class); |
|
216 | + foreach ($reflectionClass->getMethods() as $method) { |
|
217 | + $methodName = $method->name; |
|
218 | + $reflectionMethod = $reflectionClass->getMethod($methodName); |
|
219 | + $body = $this->getMethodBody($reflectionMethod); |
|
220 | + |
|
221 | + preg_match('/abort\(([^#]+)\,/iU', $body, $match); |
|
222 | + |
|
223 | + if (count($match)) { |
|
224 | + $errors[$match[1]][] = $methodName; |
|
225 | + } |
|
226 | + } |
|
227 | + } |
|
228 | + |
|
229 | + return $errors; |
|
230 | + } |
|
231 | + |
|
232 | + /** |
|
233 | + * Get the given method body code. |
|
234 | + * |
|
235 | + * @param object $reflectionMethod |
|
236 | + * @return string |
|
237 | + */ |
|
238 | + protected function getMethodBody($reflectionMethod) |
|
239 | + { |
|
240 | + $filename = $reflectionMethod->getFileName(); |
|
241 | + $start_line = $reflectionMethod->getStartLine() - 1; |
|
242 | + $end_line = $reflectionMethod->getEndLine(); |
|
243 | + $length = $end_line - $start_line; |
|
244 | + $source = file($filename); |
|
245 | + $body = implode("", array_slice($source, $start_line, $length)); |
|
246 | + $body = trim(preg_replace('/\s+/', '', $body)); |
|
247 | + |
|
248 | + return $body; |
|
249 | + } |
|
250 | + |
|
251 | + /** |
|
252 | + * Get example object of all availble models. |
|
253 | + * |
|
254 | + * @param string $modelName |
|
255 | + * @param array $docData |
|
256 | + * @return string |
|
257 | + */ |
|
258 | + protected function getModels($modelName, &$docData, $reflectionClass) |
|
259 | + { |
|
260 | + if ($modelName && ! Arr::has($docData['models'], $modelName)) { |
|
261 | + $repo = call_user_func_array("\Core::{$modelName}", []); |
|
262 | + if (! $repo) { |
|
263 | + return; |
|
264 | + } |
|
265 | 265 | |
266 | - $modelClass = get_class($repo->model); |
|
267 | - $nameSpaceArr = explode('\\', $modelClass); |
|
268 | - array_pop($nameSpaceArr); |
|
269 | - $factory = implode('\\', $nameSpaceArr) . '\\Database\Factories\\' . ucfirst($modelName) . 'Factory'; |
|
270 | - $model = App::make($factory)->make(); |
|
271 | - |
|
272 | - $property = $reflectionClass->getProperty('modelResource'); |
|
273 | - $property->setAccessible(true); |
|
274 | - $modelResource = $property->getValue(\App::make($reflectionClass->getName())); |
|
275 | - |
|
276 | - $relations = []; |
|
277 | - $relationMethods = ['hasOne', 'hasMany', 'belongsTo', 'belongsToMany', 'morphToMany', 'morphTo']; |
|
278 | - $reflector = new \ReflectionClass($model); |
|
279 | - foreach ($reflector->getMethods() as $reflectionMethod) { |
|
280 | - $body = $this->getMethodBody($reflectionMethod); |
|
281 | - foreach ($relationMethods as $relationMethod) { |
|
282 | - $relation = $reflectionMethod->getName(); |
|
283 | - if (strpos($body, '$this->' . $relationMethod) && $relation !== 'morphedByMany') { |
|
284 | - $relations[] = $relation; |
|
285 | - break; |
|
286 | - } |
|
287 | - } |
|
288 | - } |
|
289 | - |
|
290 | - $modelResource = new $modelResource($model->load($relations)); |
|
291 | - $modelArr = $modelResource->toArray([]); |
|
292 | - |
|
293 | - foreach ($modelArr as $key => $attr) { |
|
294 | - if (is_object($attr) && property_exists($attr, 'resource') && $attr->resource instanceof \Illuminate\Http\Resources\MissingValue) { |
|
295 | - unset($modelArr[$key]); |
|
296 | - } |
|
297 | - } |
|
298 | - |
|
299 | - $docData['models'][$modelName] = json_encode($modelArr, JSON_PRETTY_PRINT); |
|
300 | - } |
|
301 | - } |
|
302 | - |
|
303 | - /** |
|
304 | - * Get the route response object type. |
|
305 | - * |
|
306 | - * @param string $modelName |
|
307 | - * @param string $method |
|
308 | - * @param string $returnDocBlock |
|
309 | - * @return array |
|
310 | - */ |
|
311 | - protected function getResponseObject($modelName, $method, $returnDocBlock) |
|
312 | - { |
|
313 | - $relations = config('core.relations'); |
|
314 | - $relations = Arr::has($relations, $modelName) ? Arr::has($relations[$modelName], $method) ? $relations[$modelName] : false : false; |
|
315 | - $modelName = call_user_func_array("\Core::{$returnDocBlock}", []) ? $returnDocBlock : $modelName; |
|
316 | - |
|
317 | - return $relations ? [$modelName => $relations && $relations[$method] ? $relations[$method] : []] : false; |
|
318 | - } |
|
266 | + $modelClass = get_class($repo->model); |
|
267 | + $nameSpaceArr = explode('\\', $modelClass); |
|
268 | + array_pop($nameSpaceArr); |
|
269 | + $factory = implode('\\', $nameSpaceArr) . '\\Database\Factories\\' . ucfirst($modelName) . 'Factory'; |
|
270 | + $model = App::make($factory)->make(); |
|
271 | + |
|
272 | + $property = $reflectionClass->getProperty('modelResource'); |
|
273 | + $property->setAccessible(true); |
|
274 | + $modelResource = $property->getValue(\App::make($reflectionClass->getName())); |
|
275 | + |
|
276 | + $relations = []; |
|
277 | + $relationMethods = ['hasOne', 'hasMany', 'belongsTo', 'belongsToMany', 'morphToMany', 'morphTo']; |
|
278 | + $reflector = new \ReflectionClass($model); |
|
279 | + foreach ($reflector->getMethods() as $reflectionMethod) { |
|
280 | + $body = $this->getMethodBody($reflectionMethod); |
|
281 | + foreach ($relationMethods as $relationMethod) { |
|
282 | + $relation = $reflectionMethod->getName(); |
|
283 | + if (strpos($body, '$this->' . $relationMethod) && $relation !== 'morphedByMany') { |
|
284 | + $relations[] = $relation; |
|
285 | + break; |
|
286 | + } |
|
287 | + } |
|
288 | + } |
|
289 | + |
|
290 | + $modelResource = new $modelResource($model->load($relations)); |
|
291 | + $modelArr = $modelResource->toArray([]); |
|
292 | + |
|
293 | + foreach ($modelArr as $key => $attr) { |
|
294 | + if (is_object($attr) && property_exists($attr, 'resource') && $attr->resource instanceof \Illuminate\Http\Resources\MissingValue) { |
|
295 | + unset($modelArr[$key]); |
|
296 | + } |
|
297 | + } |
|
298 | + |
|
299 | + $docData['models'][$modelName] = json_encode($modelArr, JSON_PRETTY_PRINT); |
|
300 | + } |
|
301 | + } |
|
302 | + |
|
303 | + /** |
|
304 | + * Get the route response object type. |
|
305 | + * |
|
306 | + * @param string $modelName |
|
307 | + * @param string $method |
|
308 | + * @param string $returnDocBlock |
|
309 | + * @return array |
|
310 | + */ |
|
311 | + protected function getResponseObject($modelName, $method, $returnDocBlock) |
|
312 | + { |
|
313 | + $relations = config('core.relations'); |
|
314 | + $relations = Arr::has($relations, $modelName) ? Arr::has($relations[$modelName], $method) ? $relations[$modelName] : false : false; |
|
315 | + $modelName = call_user_func_array("\Core::{$returnDocBlock}", []) ? $returnDocBlock : $modelName; |
|
316 | + |
|
317 | + return $relations ? [$modelName => $relations && $relations[$method] ? $relations[$method] : []] : false; |
|
318 | + } |
|
319 | 319 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | protected function getRoutes() |
95 | 95 | { |
96 | - return collect(\Route::getRoutes())->map(function ($route) { |
|
96 | + return collect(\Route::getRoutes())->map(function($route) { |
|
97 | 97 | if (strpos($route->uri(), 'api/') !== false) { |
98 | 98 | return [ |
99 | 99 | 'method' => $route->methods()[0], |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | ]; |
125 | 125 | |
126 | 126 | |
127 | - if (! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) { |
|
127 | + if ( ! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) { |
|
128 | 128 | $route['headers']['Authorization'] = 'Bearer {token}'; |
129 | 129 | } |
130 | 130 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | if ($className) { |
184 | 184 | $reflectionClass = new \ReflectionClass($className); |
185 | 185 | } elseif (in_array($reflectionMethod->getName(), ['store', 'update'])) { |
186 | - $className = 'App\\Modules\\' . ucfirst($module) . '\\Http\\Requests\\Store' . ucfirst($modelName); |
|
186 | + $className = 'App\\Modules\\'.ucfirst($module).'\\Http\\Requests\\Store'.ucfirst($modelName); |
|
187 | 187 | $reflectionClass = new \ReflectionClass($className); |
188 | 188 | } |
189 | 189 | |
@@ -210,8 +210,8 @@ discard block |
||
210 | 210 | { |
211 | 211 | $errors = []; |
212 | 212 | foreach (\Module::all() as $module) { |
213 | - $nameSpace = 'App\\Modules\\' . $module['basename']; |
|
214 | - $class = $nameSpace . '\\Errors\\' . $module['basename'] . 'Errors'; |
|
213 | + $nameSpace = 'App\\Modules\\'.$module['basename']; |
|
214 | + $class = $nameSpace.'\\Errors\\'.$module['basename'].'Errors'; |
|
215 | 215 | $reflectionClass = new \ReflectionClass($class); |
216 | 216 | foreach ($reflectionClass->getMethods() as $method) { |
217 | 217 | $methodName = $method->name; |
@@ -259,14 +259,14 @@ discard block |
||
259 | 259 | { |
260 | 260 | if ($modelName && ! Arr::has($docData['models'], $modelName)) { |
261 | 261 | $repo = call_user_func_array("\Core::{$modelName}", []); |
262 | - if (! $repo) { |
|
262 | + if ( ! $repo) { |
|
263 | 263 | return; |
264 | 264 | } |
265 | 265 | |
266 | 266 | $modelClass = get_class($repo->model); |
267 | 267 | $nameSpaceArr = explode('\\', $modelClass); |
268 | 268 | array_pop($nameSpaceArr); |
269 | - $factory = implode('\\', $nameSpaceArr) . '\\Database\Factories\\' . ucfirst($modelName) . 'Factory'; |
|
269 | + $factory = implode('\\', $nameSpaceArr).'\\Database\Factories\\'.ucfirst($modelName).'Factory'; |
|
270 | 270 | $model = App::make($factory)->make(); |
271 | 271 | |
272 | 272 | $property = $reflectionClass->getProperty('modelResource'); |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | $body = $this->getMethodBody($reflectionMethod); |
281 | 281 | foreach ($relationMethods as $relationMethod) { |
282 | 282 | $relation = $reflectionMethod->getName(); |
283 | - if (strpos($body, '$this->' . $relationMethod) && $relation !== 'morphedByMany') { |
|
283 | + if (strpos($body, '$this->'.$relationMethod) && $relation !== 'morphedByMany') { |
|
284 | 284 | $relations[] = $relation; |
285 | 285 | break; |
286 | 286 | } |
@@ -6,29 +6,29 @@ |
||
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', 'DummyModuleSlug'); |
|
17 | - $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'DummyModuleSlug'); |
|
9 | + /** |
|
10 | + * Bootstrap the module services. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function boot() |
|
15 | + { |
|
16 | + $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'DummyModuleSlug'); |
|
17 | + $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'DummyModuleSlug'); |
|
18 | 18 | |
19 | - $this->loadMigrationsFrom(module_path('DummyModuleSlug', 'Database/Migrations', 'app')); |
|
20 | - if (!$this->app->configurationIsCached()) { |
|
21 | - $this->loadConfigsFrom(module_path('DummyModuleSlug', 'Config', 'app')); |
|
22 | - } |
|
23 | - } |
|
19 | + $this->loadMigrationsFrom(module_path('DummyModuleSlug', 'Database/Migrations', 'app')); |
|
20 | + if (!$this->app->configurationIsCached()) { |
|
21 | + $this->loadConfigsFrom(module_path('DummyModuleSlug', 'Config', 'app')); |
|
22 | + } |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * Register the module services. |
|
27 | - * |
|
28 | - * @return void |
|
29 | - */ |
|
30 | - public function register() |
|
31 | - { |
|
32 | - $this->app->register(RouteServiceProvider::class); |
|
33 | - } |
|
25 | + /** |
|
26 | + * Register the module services. |
|
27 | + * |
|
28 | + * @return void |
|
29 | + */ |
|
30 | + public function register() |
|
31 | + { |
|
32 | + $this->app->register(RouteServiceProvider::class); |
|
33 | + } |
|
34 | 34 | } |
@@ -17,7 +17,7 @@ |
||
17 | 17 | $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'DummyModuleSlug'); |
18 | 18 | |
19 | 19 | $this->loadMigrationsFrom(module_path('DummyModuleSlug', 'Database/Migrations', 'app')); |
20 | - if (!$this->app->configurationIsCached()) { |
|
20 | + if ( ! $this->app->configurationIsCached()) { |
|
21 | 21 | $this->loadConfigsFrom(module_path('DummyModuleSlug', 'Config', 'app')); |
22 | 22 | } |
23 | 23 | } |
@@ -7,24 +7,24 @@ |
||
7 | 7 | |
8 | 8 | class DummyFactory extends Factory |
9 | 9 | { |
10 | - /** |
|
11 | - * The name of the factory's corresponding model. |
|
12 | - * |
|
13 | - * @var string |
|
14 | - */ |
|
15 | - protected $model = DummyModel::class; |
|
10 | + /** |
|
11 | + * The name of the factory's corresponding model. |
|
12 | + * |
|
13 | + * @var string |
|
14 | + */ |
|
15 | + protected $model = DummyModel::class; |
|
16 | 16 | |
17 | - /** |
|
18 | - * Define the model's default state. |
|
19 | - * |
|
20 | - * @return array |
|
21 | - */ |
|
22 | - public function definition() |
|
23 | - { |
|
24 | - return [ |
|
25 | - // Add factory attributes |
|
26 | - 'created_at' => $this->faker->dateTimeBetween('-1 years', 'now'), |
|
27 | - 'updated_at' => $this->faker->dateTimeBetween('-1 years', 'now') |
|
28 | - ]; |
|
29 | - } |
|
17 | + /** |
|
18 | + * Define the model's default state. |
|
19 | + * |
|
20 | + * @return array |
|
21 | + */ |
|
22 | + public function definition() |
|
23 | + { |
|
24 | + return [ |
|
25 | + // Add factory attributes |
|
26 | + 'created_at' => $this->faker->dateTimeBetween('-1 years', 'now'), |
|
27 | + 'updated_at' => $this->faker->dateTimeBetween('-1 years', 'now') |
|
28 | + ]; |
|
29 | + } |
|
30 | 30 | } |
@@ -6,29 +6,29 @@ |
||
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 | - if (!$this->app->configurationIsCached()) { |
|
21 | - $this->loadConfigsFrom(module_path('notifications', 'Config', 'app')); |
|
22 | - } |
|
23 | - } |
|
19 | + $this->loadMigrationsFrom(module_path('notifications', 'Database/Migrations', 'app')); |
|
20 | + if (!$this->app->configurationIsCached()) { |
|
21 | + $this->loadConfigsFrom(module_path('notifications', 'Config', 'app')); |
|
22 | + } |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * Register the module services. |
|
27 | - * |
|
28 | - * @return void |
|
29 | - */ |
|
30 | - public function register() |
|
31 | - { |
|
32 | - $this->app->register(RouteServiceProvider::class); |
|
33 | - } |
|
25 | + /** |
|
26 | + * Register the module services. |
|
27 | + * |
|
28 | + * @return void |
|
29 | + */ |
|
30 | + public function register() |
|
31 | + { |
|
32 | + $this->app->register(RouteServiceProvider::class); |
|
33 | + } |
|
34 | 34 | } |
@@ -17,7 +17,7 @@ |
||
17 | 17 | $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'notifications'); |
18 | 18 | |
19 | 19 | $this->loadMigrationsFrom(module_path('notifications', 'Database/Migrations', 'app')); |
20 | - if (!$this->app->configurationIsCached()) { |
|
20 | + if ( ! $this->app->configurationIsCached()) { |
|
21 | 21 | $this->loadConfigsFrom(module_path('notifications', 'Config', 'app')); |
22 | 22 | } |
23 | 23 | } |
@@ -8,78 +8,78 @@ |
||
8 | 8 | |
9 | 9 | class NotificationService extends BaseService |
10 | 10 | { |
11 | - /** |
|
12 | - * @var UserRepository |
|
13 | - */ |
|
14 | - protected $userRepository; |
|
11 | + /** |
|
12 | + * @var UserRepository |
|
13 | + */ |
|
14 | + protected $userRepository; |
|
15 | 15 | |
16 | - /** |
|
17 | - * Init new object. |
|
18 | - * |
|
19 | - * @param NotificationRepository $repo |
|
20 | - * @return void |
|
21 | - */ |
|
22 | - public function __construct(NotificationRepository $repo, UserRepository $userRepository) |
|
23 | - { |
|
24 | - $this->userRepository = $userRepository; |
|
25 | - parent::__construct($repo); |
|
26 | - } |
|
16 | + /** |
|
17 | + * Init new object. |
|
18 | + * |
|
19 | + * @param NotificationRepository $repo |
|
20 | + * @return void |
|
21 | + */ |
|
22 | + public function __construct(NotificationRepository $repo, UserRepository $userRepository) |
|
23 | + { |
|
24 | + $this->userRepository = $userRepository; |
|
25 | + parent::__construct($repo); |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * Retrieve all notifications of the logged in user. |
|
30 | - * |
|
31 | - * @param integer $perPage |
|
32 | - * @return Collection |
|
33 | - */ |
|
34 | - public function my($perPage) |
|
35 | - { |
|
36 | - return $this->repo->my($perPage); |
|
37 | - } |
|
28 | + /** |
|
29 | + * Retrieve all notifications of the logged in user. |
|
30 | + * |
|
31 | + * @param integer $perPage |
|
32 | + * @return Collection |
|
33 | + */ |
|
34 | + public function my($perPage) |
|
35 | + { |
|
36 | + return $this->repo->my($perPage); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * Retrieve unread notifications of the logged in user. |
|
41 | - * |
|
42 | - * @param integer $perPage |
|
43 | - * @return Collection |
|
44 | - */ |
|
45 | - public function unread($perPage) |
|
46 | - { |
|
47 | - return $this->repo->unread($perPage); |
|
48 | - } |
|
39 | + /** |
|
40 | + * Retrieve unread notifications of the logged in user. |
|
41 | + * |
|
42 | + * @param integer $perPage |
|
43 | + * @return Collection |
|
44 | + */ |
|
45 | + public function unread($perPage) |
|
46 | + { |
|
47 | + return $this->repo->unread($perPage); |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * Mark the notification as read. |
|
52 | - * |
|
53 | - * @param integer $id |
|
54 | - * @return object |
|
55 | - */ |
|
56 | - public function markAsRead($id) |
|
57 | - { |
|
58 | - return $this->repo->markAsRead($id); |
|
59 | - } |
|
50 | + /** |
|
51 | + * Mark the notification as read. |
|
52 | + * |
|
53 | + * @param integer $id |
|
54 | + * @return object |
|
55 | + */ |
|
56 | + public function markAsRead($id) |
|
57 | + { |
|
58 | + return $this->repo->markAsRead($id); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * Mark all notifications as read. |
|
63 | - * |
|
64 | - * @return void |
|
65 | - */ |
|
66 | - public function markAllAsRead() |
|
67 | - { |
|
68 | - return $this->repo->markAllAsRead(); |
|
69 | - } |
|
61 | + /** |
|
62 | + * Mark all notifications as read. |
|
63 | + * |
|
64 | + * @return void |
|
65 | + */ |
|
66 | + public function markAllAsRead() |
|
67 | + { |
|
68 | + return $this->repo->markAllAsRead(); |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * Notify th given user with the given notification. |
|
73 | - * |
|
74 | - * @param collection $users |
|
75 | - * @param string $notification |
|
76 | - * @param Variadic $notificationData |
|
77 | - * @return void |
|
78 | - */ |
|
79 | - public function notify($users, $notification, ...$notificationData) |
|
80 | - { |
|
81 | - $users = is_array($users) ? $this->userRepository->findBy(['id' => ['op' => 'in', 'val' => $users]]) : $users; |
|
82 | - $notification = 'App\Modules\Notifications\Notifications\\'.$notification; |
|
83 | - \Notification::send($users, new $notification(...$notificationData)); |
|
84 | - } |
|
71 | + /** |
|
72 | + * Notify th given user with the given notification. |
|
73 | + * |
|
74 | + * @param collection $users |
|
75 | + * @param string $notification |
|
76 | + * @param Variadic $notificationData |
|
77 | + * @return void |
|
78 | + */ |
|
79 | + public function notify($users, $notification, ...$notificationData) |
|
80 | + { |
|
81 | + $users = is_array($users) ? $this->userRepository->findBy(['id' => ['op' => 'in', 'val' => $users]]) : $users; |
|
82 | + $notification = 'App\Modules\Notifications\Notifications\\'.$notification; |
|
83 | + \Notification::send($users, new $notification(...$notificationData)); |
|
84 | + } |
|
85 | 85 | } |
@@ -9,44 +9,44 @@ |
||
9 | 9 | |
10 | 10 | class ResetPassword extends Notification implements ShouldQueue |
11 | 11 | { |
12 | - use Queueable; |
|
12 | + use Queueable; |
|
13 | 13 | |
14 | - protected $token; |
|
14 | + protected $token; |
|
15 | 15 | |
16 | - /** |
|
17 | - * Init new object. |
|
18 | - * |
|
19 | - * @return void |
|
20 | - */ |
|
21 | - public function __construct($token) |
|
22 | - { |
|
23 | - $this->token = $token; |
|
24 | - } |
|
16 | + /** |
|
17 | + * Init new object. |
|
18 | + * |
|
19 | + * @return void |
|
20 | + */ |
|
21 | + public function __construct($token) |
|
22 | + { |
|
23 | + $this->token = $token; |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * Get the notification's delivery channels. |
|
28 | - * |
|
29 | - * @param mixed $notifiable |
|
30 | - * @return string[] |
|
31 | - */ |
|
32 | - public function via($notifiable) |
|
33 | - { |
|
34 | - return ['mail']; |
|
35 | - } |
|
26 | + /** |
|
27 | + * Get the notification's delivery channels. |
|
28 | + * |
|
29 | + * @param mixed $notifiable |
|
30 | + * @return string[] |
|
31 | + */ |
|
32 | + public function via($notifiable) |
|
33 | + { |
|
34 | + return ['mail']; |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * Get the mail representation of the notification. |
|
39 | - * |
|
40 | - * @param mixed $notifiable |
|
41 | - * @return \Illuminate\Notifications\Messages\MailMessage |
|
42 | - */ |
|
43 | - public function toMail($notifiable) |
|
44 | - { |
|
45 | - $url = config('user.confrim_email_url') ? config('user.reset_password_url').'/'.$this->token : route('reset_password_page', $this->token); |
|
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', $url); |
|
51 | - } |
|
37 | + /** |
|
38 | + * Get the mail representation of the notification. |
|
39 | + * |
|
40 | + * @param mixed $notifiable |
|
41 | + * @return \Illuminate\Notifications\Messages\MailMessage |
|
42 | + */ |
|
43 | + public function toMail($notifiable) |
|
44 | + { |
|
45 | + $url = config('user.confrim_email_url') ? config('user.reset_password_url').'/'.$this->token : route('reset_password_page', $this->token); |
|
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', $url); |
|
51 | + } |
|
52 | 52 | } |
@@ -9,43 +9,43 @@ |
||
9 | 9 | |
10 | 10 | class ConfirmEmail extends Notification implements ShouldQueue |
11 | 11 | { |
12 | - use Queueable; |
|
12 | + use Queueable; |
|
13 | 13 | |
14 | - /** |
|
15 | - * Init new object. |
|
16 | - * |
|
17 | - * @return void |
|
18 | - */ |
|
19 | - public function __construct() |
|
20 | - { |
|
21 | - // |
|
22 | - } |
|
14 | + /** |
|
15 | + * Init new object. |
|
16 | + * |
|
17 | + * @return void |
|
18 | + */ |
|
19 | + public function __construct() |
|
20 | + { |
|
21 | + // |
|
22 | + } |
|
23 | 23 | |
24 | - /** |
|
25 | - * Get the notification's delivery channels. |
|
26 | - * |
|
27 | - * @param mixed $notifiable |
|
28 | - * @return string[] |
|
29 | - */ |
|
30 | - public function via($notifiable) |
|
31 | - { |
|
32 | - return ['mail']; |
|
33 | - } |
|
24 | + /** |
|
25 | + * Get the notification's delivery channels. |
|
26 | + * |
|
27 | + * @param mixed $notifiable |
|
28 | + * @return string[] |
|
29 | + */ |
|
30 | + public function via($notifiable) |
|
31 | + { |
|
32 | + return ['mail']; |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Get the mail representation of the notification. |
|
37 | - * |
|
38 | - * @param mixed $notifiable |
|
39 | - * @return \Illuminate\Notifications\Messages\MailMessage |
|
40 | - */ |
|
41 | - public function toMail($notifiable) |
|
42 | - { |
|
43 | - $url = config('user.confrim_email_url') ? config('user.confrim_email_url').'/'.$notifiable->confirmation_code : route('confirm_email_page', $notifiable->confirmation_code); |
|
35 | + /** |
|
36 | + * Get the mail representation of the notification. |
|
37 | + * |
|
38 | + * @param mixed $notifiable |
|
39 | + * @return \Illuminate\Notifications\Messages\MailMessage |
|
40 | + */ |
|
41 | + public function toMail($notifiable) |
|
42 | + { |
|
43 | + $url = config('user.confrim_email_url') ? config('user.confrim_email_url').'/'.$notifiable->confirmation_code : route('confirm_email_page', $notifiable->confirmation_code); |
|
44 | 44 | |
45 | - return (new MailMessage) |
|
46 | - ->subject('Email verification') |
|
47 | - ->line('Email verification') |
|
48 | - ->line('To validate your email click on the button below') |
|
49 | - ->action('Verify your email', $url); |
|
50 | - } |
|
45 | + return (new MailMessage) |
|
46 | + ->subject('Email verification') |
|
47 | + ->line('Email verification') |
|
48 | + ->line('To validate your email click on the button below') |
|
49 | + ->action('Verify your email', $url); |
|
50 | + } |
|
51 | 51 | } |
@@ -7,28 +7,28 @@ |
||
7 | 7 | |
8 | 8 | class NotificationFactory extends Factory |
9 | 9 | { |
10 | - /** |
|
11 | - * The name of the factory's corresponding model. |
|
12 | - * |
|
13 | - * @var string |
|
14 | - */ |
|
15 | - protected $model = Notification::class; |
|
10 | + /** |
|
11 | + * The name of the factory's corresponding model. |
|
12 | + * |
|
13 | + * @var string |
|
14 | + */ |
|
15 | + protected $model = Notification::class; |
|
16 | 16 | |
17 | - /** |
|
18 | - * Define the model's default state. |
|
19 | - * |
|
20 | - * @return array |
|
21 | - */ |
|
22 | - public function definition() |
|
23 | - { |
|
24 | - return [ |
|
25 | - 'type' => '', |
|
26 | - 'notifiable_type' => '', |
|
27 | - 'notifiable_id' => '', |
|
28 | - 'data' => '', |
|
29 | - 'read_at' => null, |
|
30 | - 'created_at' => $this->faker->dateTimeBetween('-1 years', 'now'), |
|
31 | - 'updated_at' => $this->faker->dateTimeBetween('-1 years', 'now') |
|
32 | - ]; |
|
33 | - } |
|
17 | + /** |
|
18 | + * Define the model's default state. |
|
19 | + * |
|
20 | + * @return array |
|
21 | + */ |
|
22 | + public function definition() |
|
23 | + { |
|
24 | + return [ |
|
25 | + 'type' => '', |
|
26 | + 'notifiable_type' => '', |
|
27 | + 'notifiable_id' => '', |
|
28 | + 'data' => '', |
|
29 | + 'read_at' => null, |
|
30 | + 'created_at' => $this->faker->dateTimeBetween('-1 years', 'now'), |
|
31 | + 'updated_at' => $this->faker->dateTimeBetween('-1 years', 'now') |
|
32 | + ]; |
|
33 | + } |
|
34 | 34 | } |
@@ -6,29 +6,29 @@ |
||
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', 'push-notification-devices'); |
|
17 | - $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'push-notification-devices'); |
|
9 | + /** |
|
10 | + * Bootstrap the module services. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function boot() |
|
15 | + { |
|
16 | + $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'push-notification-devices'); |
|
17 | + $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'push-notification-devices'); |
|
18 | 18 | |
19 | - $this->loadMigrationsFrom(module_path('push-notification-devices', 'Database/Migrations', 'app')); |
|
20 | - if (!$this->app->configurationIsCached()) { |
|
21 | - $this->loadConfigsFrom(module_path('push-notification-devices', 'Config', 'app')); |
|
22 | - } |
|
23 | - } |
|
19 | + $this->loadMigrationsFrom(module_path('push-notification-devices', 'Database/Migrations', 'app')); |
|
20 | + if (!$this->app->configurationIsCached()) { |
|
21 | + $this->loadConfigsFrom(module_path('push-notification-devices', 'Config', 'app')); |
|
22 | + } |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * Register the module services. |
|
27 | - * |
|
28 | - * @return void |
|
29 | - */ |
|
30 | - public function register() |
|
31 | - { |
|
32 | - $this->app->register(RouteServiceProvider::class); |
|
33 | - } |
|
25 | + /** |
|
26 | + * Register the module services. |
|
27 | + * |
|
28 | + * @return void |
|
29 | + */ |
|
30 | + public function register() |
|
31 | + { |
|
32 | + $this->app->register(RouteServiceProvider::class); |
|
33 | + } |
|
34 | 34 | } |
@@ -17,7 +17,7 @@ |
||
17 | 17 | $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'push-notification-devices'); |
18 | 18 | |
19 | 19 | $this->loadMigrationsFrom(module_path('push-notification-devices', 'Database/Migrations', 'app')); |
20 | - if (!$this->app->configurationIsCached()) { |
|
20 | + if ( ! $this->app->configurationIsCached()) { |
|
21 | 21 | $this->loadConfigsFrom(module_path('push-notification-devices', 'Config', 'app')); |
22 | 22 | } |
23 | 23 | } |