commit 26acb5468c6867192907ae58fb5ed3ce18461091 Author: Daeng Deni Mardaeni Date: Wed Aug 7 10:09:43 2024 +0700 Initial Commit diff --git a/app/Http/Controllers/.gitkeep b/app/Http/Controllers/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/Http/Controllers/LpjController.php b/app/Http/Controllers/LpjController.php new file mode 100644 index 0000000..e67aeff --- /dev/null +++ b/app/Http/Controllers/LpjController.php @@ -0,0 +1,67 @@ +> + */ + protected $listen = []; + + /** + * Indicates if events should be discovered. + * + * @var bool + */ + protected static $shouldDiscoverEvents = true; + + /** + * Configure the proper event listeners for email verification. + * + * @return void + */ + protected function configureEmailVerification(): void + { + + } +} diff --git a/app/Providers/LpjServiceProvider.php b/app/Providers/LpjServiceProvider.php new file mode 100644 index 0000000..1437380 --- /dev/null +++ b/app/Providers/LpjServiceProvider.php @@ -0,0 +1,120 @@ +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(EventServiceProvider::class); + $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.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides(): array + { + return []; + } + + /** + * @return array + */ + 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/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php new file mode 100644 index 0000000..f15ea30 --- /dev/null +++ b/app/Providers/RouteServiceProvider.php @@ -0,0 +1,49 @@ +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')->group(module_path('Lpj', '/routes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + */ + protected function mapApiRoutes(): void + { + Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Lpj', '/routes/api.php')); + } +} diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..4e34e0f --- /dev/null +++ b/composer.json @@ -0,0 +1,30 @@ +{ + "name": "daengdei/lpj-module", + "description": "", + "authors": [ + { + "name": "Daeng Deni Mardaeni", + "email": "ddeni05@gmail.com" + } + ], + "extra": { + "laravel": { + "providers": [], + "aliases": { + + } + } + }, + "autoload": { + "psr-4": { + "Modules\\Lpj\\": "app/", + "Modules\\Lpj\\Database\\Factories\\": "database/factories/", + "Modules\\Lpj\\Database\\Seeders\\": "database/seeders/" + } + }, + "autoload-dev": { + "psr-4": { + "Modules\\Lpj\\Tests\\": "tests/" + } + } +} diff --git a/config/.gitkeep b/config/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/config/config.php b/config/config.php new file mode 100644 index 0000000..a4b4610 --- /dev/null +++ b/config/config.php @@ -0,0 +1,5 @@ + 'Lpj', +]; diff --git a/database/factories/.gitkeep b/database/factories/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/database/migrations/.gitkeep b/database/migrations/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/database/seeders/.gitkeep b/database/seeders/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/database/seeders/LpjDatabaseSeeder.php b/database/seeders/LpjDatabaseSeeder.php new file mode 100644 index 0000000..eceb570 --- /dev/null +++ b/database/seeders/LpjDatabaseSeeder.php @@ -0,0 +1,16 @@ +call([]); + } +} diff --git a/module.json b/module.json new file mode 100644 index 0000000..bf90fea --- /dev/null +++ b/module.json @@ -0,0 +1,17 @@ +{ + "name": "Lpj", + "alias": "lpj", + "database": "", + "description": "", + "keywords": [], + "priority": 0, + "providers": [ + "Modules\\Lpj\\Providers\\LpjServiceProvider" + ], + "files": [], + "menu": { + "main": [], + "master": [], + "system": [] + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..d6fbfc8 --- /dev/null +++ b/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/resources/assets/.gitkeep b/resources/assets/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js new file mode 100644 index 0000000..e69de29 diff --git a/resources/assets/sass/app.scss b/resources/assets/sass/app.scss new file mode 100644 index 0000000..e69de29 diff --git a/resources/views/.gitkeep b/resources/views/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/resources/views/index.blade.php b/resources/views/index.blade.php new file mode 100644 index 0000000..94ab522 --- /dev/null +++ b/resources/views/index.blade.php @@ -0,0 +1,7 @@ +@extends('lpj::layouts.master') + +@section('content') +

Hello World

+ +

Module: {!! config('lpj.name') !!}

+@endsection diff --git a/resources/views/layouts/master.blade.php b/resources/views/layouts/master.blade.php new file mode 100644 index 0000000..1056eb8 --- /dev/null +++ b/resources/views/layouts/master.blade.php @@ -0,0 +1,29 @@ + + + + + + + + + + Lpj Module - {{ config('app.name', 'Laravel') }} + + + + + + + + + + {{-- Vite CSS --}} + {{-- {{ module_vite('build-lpj', 'resources/assets/sass/app.scss') }} --}} + + + + @yield('content') + + {{-- Vite JS --}} + {{-- {{ module_vite('build-lpj', 'resources/assets/js/app.js') }} --}} + diff --git a/routes/.gitkeep b/routes/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/routes/api.php b/routes/api.php new file mode 100644 index 0000000..d9920ab --- /dev/null +++ b/routes/api.php @@ -0,0 +1,19 @@ +prefix('v1')->group(function () { + Route::apiResource('lpj', LpjController::class)->names('lpj'); +}); diff --git a/routes/web.php b/routes/web.php new file mode 100644 index 0000000..2a2283b --- /dev/null +++ b/routes/web.php @@ -0,0 +1,19 @@ +names('lpj'); +}); diff --git a/tests/Feature/.gitkeep b/tests/Feature/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/Unit/.gitkeep b/tests/Unit/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/vite.config.js b/vite.config.js new file mode 100644 index 0000000..37ef3ba --- /dev/null +++ b/vite.config.js @@ -0,0 +1,26 @@ +import { defineConfig } from 'vite'; +import laravel from 'laravel-vite-plugin'; + +export default defineConfig({ + build: { + outDir: '../../public/build-lpj', + emptyOutDir: true, + manifest: true, + }, + plugins: [ + laravel({ + publicDirectory: '../../public', + buildDirectory: 'build-lpj', + input: [ + __dirname + '/resources/assets/sass/app.scss', + __dirname + '/resources/assets/js/app.js' + ], + refresh: true, + }), + ], +}); + +//export const paths = [ +// 'Modules/Lpj/resources/assets/sass/app.scss', +// 'Modules/Lpj/resources/assets/js/app.js', +//]; \ No newline at end of file