diff --git a/Modules/Taxi/App/Providers/RouteServiceProvider.php b/Modules/Taxi/App/Providers/RouteServiceProvider.php new file mode 100644 index 0000000..c7c67d1 --- /dev/null +++ b/Modules/Taxi/App/Providers/RouteServiceProvider.php @@ -0,0 +1,68 @@ +mapApiRoutes(); + + $this->mapWebRoutes(); + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + */ + protected function mapWebRoutes(): void + { + Route::middleware('web') + ->namespace($this->moduleNamespace) + ->group(module_path('Taxi', '/routes/web.php')); + + Route::prefix('taxi') + ->middleware('web') + ->group(base_path('Modules/Taxi/routes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + */ + protected function mapApiRoutes(): void + { + Route::prefix('api') + ->middleware('api') + ->namespace($this->moduleNamespace) + ->group(module_path('Taxi', '/routes/api.php')); + + Route::prefix('taxi') + ->middleware('api') + ->group(base_path('Modules/Taxi/routes/api.php')); + } +} diff --git a/Modules/Taxi/App/Providers/TaxiServiceProvider.php b/Modules/Taxi/App/Providers/TaxiServiceProvider.php new file mode 100644 index 0000000..d132fc9 --- /dev/null +++ b/Modules/Taxi/App/Providers/TaxiServiceProvider.php @@ -0,0 +1,115 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->moduleName, 'Database/migrations')); + } + + /** + * Register the service provider. + */ + public function register(): void + { + $this->app->register(RouteServiceProvider::class); + } + + /** + * Register commands in the format of Command::class + */ + protected function registerCommands(): void + { + // $this->commands([]); + } + + /** + * Register command Schedules. + */ + protected function registerCommandSchedules(): void + { + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); + $sourcePath = module_path($this->moduleName, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.config('modules.paths.generator.component-class.path')); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); + } + + /** + * Get the services provided by the provider. + */ + public function provides(): array + { + return []; + } + + private function getPublishableViewPaths(): array + { + $paths = []; + foreach (config('view.paths') as $path) { + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; + } + } + + return $paths; + } +} diff --git a/Modules/Taxi/Database/Seeders/TaxiDatabaseSeeder.php b/Modules/Taxi/Database/Seeders/TaxiDatabaseSeeder.php new file mode 100644 index 0000000..f9befc7 --- /dev/null +++ b/Modules/Taxi/Database/Seeders/TaxiDatabaseSeeder.php @@ -0,0 +1,16 @@ +call([]); + } +} diff --git a/Modules/Taxi/composer.json b/Modules/Taxi/composer.json new file mode 100644 index 0000000..e0cdee0 --- /dev/null +++ b/Modules/Taxi/composer.json @@ -0,0 +1,31 @@ +{ + "name": "nwidart/taxi", + "description": "", + "authors": [ + { + "name": "Nicolas Widart", + "email": "n.widart@gmail.com" + } + ], + "extra": { + "laravel": { + "providers": [], + "aliases": { + + } + } + }, + "autoload": { + "psr-4": { + "Modules\\Taxi\\": "", + "Modules\\Taxi\\App\\": "app/", + "Modules\\Taxi\\Database\\Factories\\": "database/factories/", + "Modules\\Taxi\\Database\\Seeders\\": "database/seeders/" + } + }, + "autoload-dev": { + "psr-4": { + "Modules\\Taxi\\Tests\\": "tests/" + } + } +} diff --git a/Modules/Taxi/module.json b/Modules/Taxi/module.json new file mode 100644 index 0000000..5ab013b --- /dev/null +++ b/Modules/Taxi/module.json @@ -0,0 +1,14 @@ +{ + "name": "Taxi", + "alias": "taxi", + "description": "", + "keywords": [], + "priority": 0, + "providers": [ + "Modules\\Taxi\\App\\Providers\\TaxiServiceProvider", + "Modules\\Taxi\\App\\Providers\\TaxiOrderProvider", + "Modules\\Taxi\\App\\Providers\\TaxiMailerProvider", + "Modules\\Taxi\\App\\Providers\\TaxiScheduleProvider" + ], + "files": [] +} \ No newline at end of file diff --git a/Modules/Taxi/package.json b/Modules/Taxi/package.json new file mode 100644 index 0000000..d6fbfc8 --- /dev/null +++ b/Modules/Taxi/package.json @@ -0,0 +1,15 @@ +{ + "private": true, + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build" + }, + "devDependencies": { + "axios": "^1.1.2", + "laravel-vite-plugin": "^0.7.5", + "sass": "^1.69.5", + "postcss": "^8.3.7", + "vite": "^4.0.0" + } +} diff --git a/Modules/Taxi/vite.config.js b/Modules/Taxi/vite.config.js new file mode 100644 index 0000000..6bf4fc3 --- /dev/null +++ b/Modules/Taxi/vite.config.js @@ -0,0 +1,26 @@ +import { defineConfig } from 'vite'; +import laravel from 'laravel-vite-plugin'; + +export default defineConfig({ + build: { + outDir: '../../public/build-taxi', + emptyOutDir: true, + manifest: true, + }, + plugins: [ + laravel({ + publicDirectory: '../../public', + buildDirectory: 'build-taxi', + input: [ + __dirname + '/resources/assets/sass/app.scss', + __dirname + '/resources/assets/js/app.js' + ], + refresh: true, + }), + ], +}); + +//export const paths = [ +// 'Modules/$STUDLY_NAME$/resources/assets/sass/app.scss', +// 'Modules/$STUDLY_NAME$/resources/assets/js/app.js', +//]; \ No newline at end of file