@@ -70,12 +70,12 @@ discard block |
||
70 | 70 | $this->registerValidationRules(); |
71 | 71 | $this->registerAssets(); |
72 | 72 | |
73 | - $this->app->singleton( SecurityStrategy::class, function() |
|
73 | + $this->app->singleton(SecurityStrategy::class, function() |
|
74 | 74 | { |
75 | - return $this->app->make( SessionSecurityService::class ); |
|
75 | + return $this->app->make(SessionSecurityService::class); |
|
76 | 76 | } ); |
77 | 77 | |
78 | - $this->loadTranslationsFrom( __DIR__ . '/resources/lang', 'arbory' ); |
|
78 | + $this->loadTranslationsFrom(__DIR__ . '/resources/lang', 'arbory'); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -83,15 +83,15 @@ discard block |
||
83 | 83 | */ |
84 | 84 | private function registerServiceProviders() |
85 | 85 | { |
86 | - $this->app->register( ArboryTranslationServiceProvider::class ); |
|
87 | - $this->app->register( TranslatableServiceProvider::class ); |
|
88 | - $this->app->register( ArboryFileServiceProvider::class ); |
|
89 | - $this->app->register( ArboryAuthServiceProvider::class ); |
|
90 | - $this->app->register( GlideImageServiceProvider::class ); |
|
91 | - $this->app->register( AssetServiceProvider::class ); |
|
92 | - $this->app->register( SettingsServiceProvider::class ); |
|
93 | - $this->app->register( ExcelServiceProvider::class ); |
|
94 | - $this->app->register( FileManagerServiceProvider::class ); |
|
86 | + $this->app->register(ArboryTranslationServiceProvider::class); |
|
87 | + $this->app->register(TranslatableServiceProvider::class); |
|
88 | + $this->app->register(ArboryFileServiceProvider::class); |
|
89 | + $this->app->register(ArboryAuthServiceProvider::class); |
|
90 | + $this->app->register(GlideImageServiceProvider::class); |
|
91 | + $this->app->register(AssetServiceProvider::class); |
|
92 | + $this->app->register(SettingsServiceProvider::class); |
|
93 | + $this->app->register(ExcelServiceProvider::class); |
|
94 | + $this->app->register(FileManagerServiceProvider::class); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -101,11 +101,11 @@ discard block |
||
101 | 101 | { |
102 | 102 | $aliasLoader = AliasLoader::getInstance(); |
103 | 103 | // $aliasLoader->alias( 'TranslationCache', \Waavi\Translation\Facades\TranslationCache::class ); |
104 | - $aliasLoader->alias( 'Activation', \Cartalyst\Sentinel\Laravel\Facades\Activation::class ); |
|
105 | - $aliasLoader->alias( 'Reminder', \Cartalyst\Sentinel\Laravel\Facades\Reminder::class ); |
|
106 | - $aliasLoader->alias( 'Sentinel', \Cartalyst\Sentinel\Laravel\Facades\Sentinel::class ); |
|
107 | - $aliasLoader->alias( 'GlideImage', \Roboc\Glide\Support\Facades\GlideImage::class ); |
|
108 | - $aliasLoader->alias( 'Excel', \Maatwebsite\Excel\Facades\Excel::class ); |
|
104 | + $aliasLoader->alias('Activation', \Cartalyst\Sentinel\Laravel\Facades\Activation::class); |
|
105 | + $aliasLoader->alias('Reminder', \Cartalyst\Sentinel\Laravel\Facades\Reminder::class); |
|
106 | + $aliasLoader->alias('Sentinel', \Cartalyst\Sentinel\Laravel\Facades\Sentinel::class); |
|
107 | + $aliasLoader->alias('GlideImage', \Roboc\Glide\Support\Facades\GlideImage::class); |
|
108 | + $aliasLoader->alias('Excel', \Maatwebsite\Excel\Facades\Excel::class); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -115,26 +115,26 @@ discard block |
||
115 | 115 | { |
116 | 116 | $configFilename = __DIR__ . '/../../config/arbory.php'; |
117 | 117 | |
118 | - $this->mergeConfigFrom( $configFilename, 'arbory' ); |
|
118 | + $this->mergeConfigFrom($configFilename, 'arbory'); |
|
119 | 119 | |
120 | - $this->publishes( [ |
|
121 | - $configFilename => config_path( 'arbory.php' ) |
|
122 | - ], 'config' ); |
|
120 | + $this->publishes([ |
|
121 | + $configFilename => config_path('arbory.php') |
|
122 | + ], 'config'); |
|
123 | 123 | |
124 | - $this->publishes( [ |
|
125 | - __DIR__ . '/../../stubs/settings.stub' => config_path( 'settings.php' ) |
|
126 | - ], 'config' ); |
|
124 | + $this->publishes([ |
|
125 | + __DIR__ . '/../../stubs/settings.stub' => config_path('settings.php') |
|
126 | + ], 'config'); |
|
127 | 127 | |
128 | - $this->publishes( [ |
|
129 | - __DIR__ . '/../../stubs/admin_routes.stub' => base_path( '/routes/admin.php' ) |
|
130 | - ], 'config' ); |
|
128 | + $this->publishes([ |
|
129 | + __DIR__ . '/../../stubs/admin_routes.stub' => base_path('/routes/admin.php') |
|
130 | + ], 'config'); |
|
131 | 131 | |
132 | 132 | $this->publishes([ |
133 | 133 | __DIR__ . '/../../resources/lang/' => base_path('resources/lang/vendor/arbory') |
134 | 134 | ], 'lang'); |
135 | 135 | |
136 | - $this->loadMigrationsFrom( __DIR__ . '/../../database/migrations' ); |
|
137 | - $this->loadViewsFrom( __DIR__ . '/../../resources/views', 'arbory' ); |
|
136 | + $this->loadMigrationsFrom(__DIR__ . '/../../database/migrations'); |
|
137 | + $this->loadViewsFrom(__DIR__ . '/../../resources/views', 'arbory'); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | */ |
148 | 148 | $router = $this->app[ 'router' ]; |
149 | 149 | |
150 | - $router->middlewareGroup( 'admin', [ |
|
150 | + $router->middlewareGroup('admin', [ |
|
151 | 151 | \App\Http\Middleware\EncryptCookies::class, |
152 | 152 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, |
153 | 153 | \Illuminate\Session\Middleware\StartSession::class, |
@@ -155,19 +155,19 @@ discard block |
||
155 | 155 | \App\Http\Middleware\VerifyCsrfToken::class, |
156 | 156 | \Illuminate\Routing\Middleware\SubstituteBindings::class, |
157 | 157 | ArboryAdminHasAllowedIpMiddleware::class |
158 | - ] ); |
|
158 | + ]); |
|
159 | 159 | |
160 | - $router->aliasMiddleware( 'arbory.admin_auth', ArboryAdminAuthMiddleware::class ); |
|
161 | - $router->aliasMiddleware( 'arbory.admin_module_access', ArboryAdminModuleAccessMiddleware::class ); |
|
162 | - $router->aliasMiddleware( 'arbory.admin_quest', ArboryAdminGuestMiddleware::class ); |
|
163 | - $router->aliasMiddleware( 'arbory.admin_in_role', ArboryAdminInRoleMiddleware::class ); |
|
164 | - $router->aliasMiddleware( 'arbory.admin_has_access', ArboryAdminHasAccessMiddleware::class ); |
|
165 | - $router->aliasMiddleware( 'arbory.route_redirect', ArboryRouteRedirectMiddleware::class ); |
|
166 | - $router->aliasMiddleware( 'arbory.admin_has_allowed_ip', ArboryAdminHasAllowedIpMiddleware::class ); |
|
160 | + $router->aliasMiddleware('arbory.admin_auth', ArboryAdminAuthMiddleware::class); |
|
161 | + $router->aliasMiddleware('arbory.admin_module_access', ArboryAdminModuleAccessMiddleware::class); |
|
162 | + $router->aliasMiddleware('arbory.admin_quest', ArboryAdminGuestMiddleware::class); |
|
163 | + $router->aliasMiddleware('arbory.admin_in_role', ArboryAdminInRoleMiddleware::class); |
|
164 | + $router->aliasMiddleware('arbory.admin_has_access', ArboryAdminHasAccessMiddleware::class); |
|
165 | + $router->aliasMiddleware('arbory.route_redirect', ArboryRouteRedirectMiddleware::class); |
|
166 | + $router->aliasMiddleware('arbory.admin_has_allowed_ip', ArboryAdminHasAllowedIpMiddleware::class); |
|
167 | 167 | |
168 | - $this->app->booted( function( $app ) |
|
168 | + $this->app->booted(function($app) |
|
169 | 169 | { |
170 | - $app[ Kernel::class ]->prependMiddleware( ArboryRouteRedirectMiddleware::class ); |
|
170 | + $app[ Kernel::class ]->prependMiddleware(ArboryRouteRedirectMiddleware::class); |
|
171 | 171 | } ); |
172 | 172 | |
173 | 173 | $this->registerAdminRoutes(); |
@@ -176,12 +176,12 @@ discard block |
||
176 | 176 | |
177 | 177 | private function registerAdminRoutes() |
178 | 178 | { |
179 | - $this->app['router']->group( [ |
|
179 | + $this->app[ 'router' ]->group([ |
|
180 | 180 | 'as' => 'admin.', |
181 | 181 | 'middleware' => 'admin', |
182 | 182 | 'namespace' => '\Arbory\Base\Http\Controllers', |
183 | - 'prefix' => config( 'arbory.uri' ) |
|
184 | - ], function () |
|
183 | + 'prefix' => config('arbory.uri') |
|
184 | + ], function() |
|
185 | 185 | { |
186 | 186 | include __DIR__ . '/../../routes/admin.php'; |
187 | 187 | } ); |
@@ -189,19 +189,19 @@ discard block |
||
189 | 189 | |
190 | 190 | private function registerAppRoutes() |
191 | 191 | { |
192 | - $adminRoutes = base_path( 'routes/admin.php' ); |
|
192 | + $adminRoutes = base_path('routes/admin.php'); |
|
193 | 193 | |
194 | - if( !File::exists( $adminRoutes ) ) |
|
194 | + if (!File::exists($adminRoutes)) |
|
195 | 195 | { |
196 | 196 | return; |
197 | 197 | } |
198 | 198 | |
199 | - $this->app['router']->group( [ |
|
199 | + $this->app[ 'router' ]->group([ |
|
200 | 200 | 'as' => 'admin.', |
201 | 201 | 'middleware' => [ 'admin', 'arbory.admin_auth', 'arbory.admin_module_access' ], |
202 | 202 | 'namespace' => '', |
203 | - 'prefix' => config( 'arbory.uri' ) |
|
204 | - ],function () use ($adminRoutes) |
|
203 | + 'prefix' => config('arbory.uri') |
|
204 | + ], function() use ($adminRoutes) |
|
205 | 205 | { |
206 | 206 | include $adminRoutes; |
207 | 207 | } ); |
@@ -219,9 +219,9 @@ discard block |
||
219 | 219 | 'arbory.generate' => GenerateCommand::class |
220 | 220 | ]; |
221 | 221 | |
222 | - foreach( $commands as $containerKey => $commandClass ) |
|
222 | + foreach ($commands as $containerKey => $commandClass) |
|
223 | 223 | { |
224 | - $this->registerCommand( $containerKey, $commandClass ); |
|
224 | + $this->registerCommand($containerKey, $commandClass); |
|
225 | 225 | } |
226 | 226 | } |
227 | 227 | |
@@ -230,14 +230,14 @@ discard block |
||
230 | 230 | * @param string $commandClass |
231 | 231 | * @return void |
232 | 232 | */ |
233 | - private function registerCommand( string $containerKey, string $commandClass ) |
|
233 | + private function registerCommand(string $containerKey, string $commandClass) |
|
234 | 234 | { |
235 | - $this->app->singleton( $containerKey, function () use ( $commandClass ) |
|
235 | + $this->app->singleton($containerKey, function() use ($commandClass) |
|
236 | 236 | { |
237 | - return $this->app->make( $commandClass ); |
|
237 | + return $this->app->make($commandClass); |
|
238 | 238 | } ); |
239 | 239 | |
240 | - $this->commands( $containerKey ); |
|
240 | + $this->commands($containerKey); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | /** |
@@ -245,18 +245,18 @@ discard block |
||
245 | 245 | */ |
246 | 246 | private function registerModuleRegistry() |
247 | 247 | { |
248 | - $this->app->singleton( 'arbory', function () |
|
248 | + $this->app->singleton('arbory', function() |
|
249 | 249 | { |
250 | 250 | return new Admin( |
251 | - $this->app['sentinel'], |
|
251 | + $this->app[ 'sentinel' ], |
|
252 | 252 | new Menu(), |
253 | 253 | new AssetPipeline() |
254 | 254 | ); |
255 | 255 | } ); |
256 | 256 | |
257 | - $this->app->singleton( Admin::class, function () |
|
257 | + $this->app->singleton(Admin::class, function() |
|
258 | 258 | { |
259 | - return $this->app['arbory']; |
|
259 | + return $this->app[ 'arbory' ]; |
|
260 | 260 | } ); |
261 | 261 | } |
262 | 262 | |
@@ -265,20 +265,20 @@ discard block |
||
265 | 265 | */ |
266 | 266 | private function registerFields() |
267 | 267 | { |
268 | - $this->app->singleton( FieldTypeRegistry::class, function ( Application $app ) |
|
268 | + $this->app->singleton(FieldTypeRegistry::class, function(Application $app) |
|
269 | 269 | { |
270 | 270 | $fieldTypeRegistry = new FieldTypeRegistry(); |
271 | 271 | |
272 | - $fieldTypeRegistry->registerByType( 'integer', Hidden::class, 'int' ); |
|
273 | - $fieldTypeRegistry->registerByType( 'string', Text::class, 'string' ); |
|
274 | - $fieldTypeRegistry->registerByType( 'text', Textarea::class, 'string' ); |
|
275 | - $fieldTypeRegistry->registerByType( 'longtext', Richtext::class, 'string' ); |
|
276 | - $fieldTypeRegistry->registerByType( 'datetime', DateTime::class, 'string' ); |
|
277 | - $fieldTypeRegistry->registerByType( 'boolean', Checkbox::class, 'bool' ); |
|
272 | + $fieldTypeRegistry->registerByType('integer', Hidden::class, 'int'); |
|
273 | + $fieldTypeRegistry->registerByType('string', Text::class, 'string'); |
|
274 | + $fieldTypeRegistry->registerByType('text', Textarea::class, 'string'); |
|
275 | + $fieldTypeRegistry->registerByType('longtext', Richtext::class, 'string'); |
|
276 | + $fieldTypeRegistry->registerByType('datetime', DateTime::class, 'string'); |
|
277 | + $fieldTypeRegistry->registerByType('boolean', Checkbox::class, 'bool'); |
|
278 | 278 | |
279 | - $fieldTypeRegistry->registerByRelation( 'file', ArboryFile::class ); |
|
280 | - $fieldTypeRegistry->registerByRelation( 'image', ArboryImage::class ); |
|
281 | - $fieldTypeRegistry->registerByRelation( 'link', Link::class ); |
|
279 | + $fieldTypeRegistry->registerByRelation('file', ArboryFile::class); |
|
280 | + $fieldTypeRegistry->registerByRelation('image', ArboryImage::class); |
|
281 | + $fieldTypeRegistry->registerByRelation('link', Link::class); |
|
282 | 282 | |
283 | 283 | return $fieldTypeRegistry; |
284 | 284 | } ); |
@@ -289,13 +289,13 @@ discard block |
||
289 | 289 | */ |
290 | 290 | private function registerGeneratorStubs() |
291 | 291 | { |
292 | - $this->app->singleton( StubRegistry::class, function( Application $app ) |
|
292 | + $this->app->singleton(StubRegistry::class, function(Application $app) |
|
293 | 293 | { |
294 | 294 | $stubRegistry = new StubRegistry(); |
295 | 295 | |
296 | 296 | $stubRegistry->registerStubs( |
297 | 297 | $app[ Filesystem::class ], |
298 | - base_path( 'vendor/arbory/arbory/stubs' ) |
|
298 | + base_path('vendor/arbory/arbory/stubs') |
|
299 | 299 | ); |
300 | 300 | |
301 | 301 | return $stubRegistry; |
@@ -307,8 +307,8 @@ discard block |
||
307 | 307 | */ |
308 | 308 | private function registerLocales() |
309 | 309 | { |
310 | - config()->set( 'translator.locales', config( 'arbory.locales' ) ); |
|
311 | - config()->set( 'translatable.locales', config( 'arbory.locales' ) ); |
|
310 | + config()->set('translator.locales', config('arbory.locales')); |
|
311 | + config()->set('translatable.locales', config('arbory.locales')); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | /** |
@@ -324,44 +324,44 @@ discard block |
||
324 | 324 | */ |
325 | 325 | private function registerValidationRules() |
326 | 326 | { |
327 | - $isDestroyed = function( Request $request, $attribute ) |
|
327 | + $isDestroyed = function(Request $request, $attribute) |
|
328 | 328 | { |
329 | - $fieldSet = $request->request->get( 'fields' ); |
|
330 | - $fields = $fieldSet->findFieldsByInputName( $attribute ); |
|
331 | - $fields = array_reverse( $fields ); |
|
329 | + $fieldSet = $request->request->get('fields'); |
|
330 | + $fields = $fieldSet->findFieldsByInputName($attribute); |
|
331 | + $fields = array_reverse($fields); |
|
332 | 332 | |
333 | - foreach( $fields as $fieldName => $field ) |
|
333 | + foreach ($fields as $fieldName => $field) |
|
334 | 334 | { |
335 | - if( $field instanceof HasMany ) |
|
335 | + if ($field instanceof HasMany) |
|
336 | 336 | { |
337 | - $attributeParts = explode( '.', $attribute ); |
|
338 | - $toManyIndex = array_search( $fieldName, $attributeParts, true ); |
|
339 | - $attributeParent = array_slice( $attributeParts, 0, $toManyIndex + 2 ); |
|
340 | - $attributeParent = implode( '.', $attributeParent ); |
|
337 | + $attributeParts = explode('.', $attribute); |
|
338 | + $toManyIndex = array_search($fieldName, $attributeParts, true); |
|
339 | + $attributeParent = array_slice($attributeParts, 0, $toManyIndex + 2); |
|
340 | + $attributeParent = implode('.', $attributeParent); |
|
341 | 341 | |
342 | - $isDestroyed = array_get( $request->input( $attributeParent ), '_destroy' ); |
|
342 | + $isDestroyed = array_get($request->input($attributeParent), '_destroy'); |
|
343 | 343 | |
344 | - return filter_var( $isDestroyed, FILTER_VALIDATE_BOOLEAN ); |
|
344 | + return filter_var($isDestroyed, FILTER_VALIDATE_BOOLEAN); |
|
345 | 345 | } |
346 | 346 | } |
347 | 347 | |
348 | 348 | return false; |
349 | 349 | }; |
350 | 350 | |
351 | - \Validator::extendImplicit( 'arbory_file_required', function( $attribute ) use ( $isDestroyed ) |
|
351 | + \Validator::extendImplicit('arbory_file_required', function($attribute) use ($isDestroyed) |
|
352 | 352 | { |
353 | 353 | /** @var FieldSet $fields */ |
354 | 354 | $request = \request(); |
355 | - $fields = $request->request->get( 'fields' ); |
|
356 | - $field = $fields->findFieldByInputName( $attribute ); |
|
357 | - $file = $request->file( $attribute ); |
|
355 | + $fields = $request->request->get('fields'); |
|
356 | + $field = $fields->findFieldByInputName($attribute); |
|
357 | + $file = $request->file($attribute); |
|
358 | 358 | |
359 | - if( $isDestroyed( $request, $attribute ) ) |
|
359 | + if ($isDestroyed($request, $attribute)) |
|
360 | 360 | { |
361 | 361 | return true; |
362 | 362 | } |
363 | 363 | |
364 | - if( !$field ) |
|
364 | + if (!$field) |
|
365 | 365 | { |
366 | 366 | return (bool) $file; |
367 | 367 | } |
@@ -369,28 +369,28 @@ discard block |
||
369 | 369 | return $field->getValue() || $file; |
370 | 370 | } ); |
371 | 371 | |
372 | - \Validator::extendImplicit( 'arbory_require_one_localized', function( $attribute, $value ) use ( $isDestroyed ) |
|
372 | + \Validator::extendImplicit('arbory_require_one_localized', function($attribute, $value) use ($isDestroyed) |
|
373 | 373 | { |
374 | 374 | /** @var FieldSet $fieldSet */ |
375 | 375 | $request = \request(); |
376 | - $fieldSet = $request->request->get( 'fields' ); |
|
377 | - $fields = $fieldSet->findFieldsByInputName( $attribute ); |
|
376 | + $fieldSet = $request->request->get('fields'); |
|
377 | + $fields = $fieldSet->findFieldsByInputName($attribute); |
|
378 | 378 | $translatable = null; |
379 | 379 | |
380 | - if( $isDestroyed( $request, $attribute ) ) |
|
380 | + if ($isDestroyed($request, $attribute)) |
|
381 | 381 | { |
382 | 382 | return true; |
383 | 383 | } |
384 | 384 | |
385 | - foreach( array_reverse( $fields ) as $index => $field ) |
|
385 | + foreach (array_reverse($fields) as $index => $field) |
|
386 | 386 | { |
387 | - if ( $field instanceof Translatable ) |
|
387 | + if ($field instanceof Translatable) |
|
388 | 388 | { |
389 | 389 | $translatable = $field; |
390 | 390 | } |
391 | 391 | } |
392 | 392 | |
393 | - if ( !$translatable || $value ) |
|
393 | + if (!$translatable || $value) |
|
394 | 394 | { |
395 | 395 | return (bool) $value; |
396 | 396 | } |
@@ -398,22 +398,22 @@ discard block |
||
398 | 398 | $attributeLocale = null; |
399 | 399 | $checkLocales = $translatable->getLocales(); |
400 | 400 | |
401 | - foreach( $checkLocales as $index => $checkLocale ) |
|
401 | + foreach ($checkLocales as $index => $checkLocale) |
|
402 | 402 | { |
403 | - if( str_contains( $attribute, $checkLocale ) ) |
|
403 | + if (str_contains($attribute, $checkLocale)) |
|
404 | 404 | { |
405 | 405 | $attributeLocale = $checkLocale; |
406 | - unset( $checkLocales[ $index ] ); |
|
406 | + unset($checkLocales[ $index ]); |
|
407 | 407 | break; |
408 | 408 | } |
409 | 409 | } |
410 | 410 | |
411 | - foreach( $checkLocales as $index => $checkLocale ) |
|
411 | + foreach ($checkLocales as $index => $checkLocale) |
|
412 | 412 | { |
413 | - $checkByAttribute = str_replace( $attributeLocale, $checkLocale, $attribute ); |
|
414 | - $field = $fieldSet->findFieldByInputName( $checkByAttribute ); |
|
413 | + $checkByAttribute = str_replace($attributeLocale, $checkLocale, $attribute); |
|
414 | + $field = $fieldSet->findFieldByInputName($checkByAttribute); |
|
415 | 415 | |
416 | - if( $request->input( $checkByAttribute ) || ( $field->getValue() && $request->input( $checkByAttribute ) !== null ) ) |
|
416 | + if ($request->input($checkByAttribute) || ($field->getValue() && $request->input($checkByAttribute) !== null)) |
|
417 | 417 | { |
418 | 418 | return true; |
419 | 419 | } |
@@ -428,9 +428,9 @@ discard block |
||
428 | 428 | */ |
429 | 429 | private function registerAssets() |
430 | 430 | { |
431 | - \App::booted( function() |
|
431 | + \App::booted(function() |
|
432 | 432 | { |
433 | - \Admin::assets()->js( '/js/admin.js' ); |
|
433 | + \Admin::assets()->js('/js/admin.js'); |
|
434 | 434 | } ); |
435 | 435 | } |
436 | 436 |