| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | namespace Cortex\Pages\Providers; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Cortex\Pages\Models\Page; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Illuminate\Routing\Router; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Illuminate\Support\ServiceProvider; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Rinvex\Support\Traits\ConsoleTools; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use Cortex\Pages\Console\Commands\SeedCommand; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use Cortex\Pages\Console\Commands\InstallCommand; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use Cortex\Pages\Console\Commands\MigrateCommand; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Cortex\Pages\Console\Commands\PublishCommand; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use Cortex\Pages\Console\Commands\RollbackCommand; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use Illuminate\Database\Eloquent\Relations\Relation; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | class PagesServiceProvider extends ServiceProvider | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     use ConsoleTools; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |      * The commands to be registered. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     protected $commands = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |         SeedCommand::class => 'command.cortex.pages.seed', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |         InstallCommand::class => 'command.cortex.pages.install', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         MigrateCommand::class => 'command.cortex.pages.migrate', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         PublishCommand::class => 'command.cortex.pages.publish', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         RollbackCommand::class => 'command.cortex.pages.rollback', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |      * Register any application services. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |      * This service provider is a great spot to register your various container | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |      * bindings with the application. As you can see, we are registering our | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |      * "Registrar" implementation here. You can add your own bindings too! | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     public function register(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         $this->mergeConfigFrom(realpath(__DIR__.'/../../config/config.php'), 'cortex.pages'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         // Bind eloquent models to IoC container | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         $this->app['config']['rinvex.pages.models.page'] === Page::class | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         || $this->app->alias('rinvex.pages.page', Page::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         // Register console commands | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         ! $this->app->runningInConsole() || $this->registerCommands(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      * Bootstrap any application services. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      * @return void | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 60 |  |  |      */ | 
            
                                                        
            
                                    
            
            
                | 61 |  |  |     public function boot(Router $router): void | 
            
                                                        
            
                                    
            
            
                | 62 |  |  |     { | 
            
                                                        
            
                                    
            
            
                | 63 |  |  |         // Bind route models and constrains | 
            
                                                        
            
                                    
            
            
                | 64 |  |  |         $router->pattern('page', '[a-zA-Z0-9-]+'); | 
            
                                                        
            
                                    
            
            
                | 65 |  |  |         $router->model('page', config('rinvex.pages.models.page')); | 
            
                                                        
            
                                    
            
            
                | 66 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 67 |  |  |         // Map relations | 
            
                                                        
            
                                    
            
            
                | 68 |  |  |         Relation::morphMap([ | 
            
                                                        
            
                                    
            
            
                | 69 |  |  |             'page' => config('rinvex.pages.models.page'), | 
            
                                                        
            
                                    
            
            
                | 70 |  |  |         ]); | 
            
                                                        
            
                                    
            
            
                | 71 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 72 |  |  |         // Load resources | 
            
                                                        
            
                                    
            
            
                | 73 |  |  |         require __DIR__.'/../../routes/breadcrumbs/adminarea.php'; | 
            
                                                        
            
                                    
            
            
                | 74 |  |  |         require __DIR__.'/../../routes/breadcrumbs/managerarea.php'; | 
            
                                                        
            
                                    
            
            
                | 75 |  |  |         $this->loadRoutesFrom(__DIR__.'/../../routes/web/adminarea.php'); | 
            
                                                        
            
                                    
            
            
                | 76 |  |  |         $this->loadRoutesFrom(__DIR__.'/../../routes/web/frontarea.php'); | 
            
                                                        
            
                                    
            
            
                | 77 |  |  |         $this->loadRoutesFrom(__DIR__.'/../../routes/web/managerarea.php'); | 
            
                                                        
            
                                    
            
            
                | 78 |  |  |         $this->loadViewsFrom(__DIR__.'/../../resources/views', 'cortex/pages'); | 
            
                                                        
            
                                    
            
            
                | 79 |  |  |         $this->loadTranslationsFrom(__DIR__.'/../../resources/lang', 'cortex/pages'); | 
            
                                                        
            
                                    
            
            
                | 80 |  |  |         $this->app->runningInConsole() || $this->app->afterResolving('blade.compiler', function () { | 
            
                                                        
            
                                    
            
            
                | 81 |  |  |             require __DIR__.'/../../routes/menus/adminarea.php'; | 
            
                                                        
            
                                    
            
            
                | 82 |  |  |         }); | 
            
                                                        
            
                                    
            
            
                | 83 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 84 |  |  |         // Publish Resources | 
            
                                                        
            
                                    
            
            
                | 85 |  |  |         ! $this->app->runningInConsole() || $this->publishesLang('cortex/pages'); | 
            
                                                        
            
                                    
            
            
                | 86 |  |  |         ! $this->app->runningInConsole() || $this->publishesViews('cortex/pages'); | 
            
                                                        
            
                                    
            
            
                | 87 |  |  |         ! $this->app->runningInConsole() || $this->publishesConfig('cortex/pages'); | 
            
                                                        
            
                                    
            
            
                | 88 |  |  |         ! $this->app->runningInConsole() || $this->publishesMigrations('cortex/pages'); | 
            
                                                        
            
                                    
            
            
                | 89 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 90 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 91 |  |  |  |