update
This commit is contained in:
@@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Modules\Demo\Http\Controllers\Admin;
|
|
||||||
|
|
||||||
class Index {
|
|
||||||
|
|
||||||
public function index(){}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Modules\Demo\Http\Controllers\Api;
|
|
||||||
|
|
||||||
class Index {
|
|
||||||
|
|
||||||
public function index(){}
|
|
||||||
}
|
|
||||||
@@ -1,154 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Modules\Demo\Providers;
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Blade;
|
|
||||||
use Illuminate\Support\ServiceProvider;
|
|
||||||
use Nwidart\Modules\Traits\PathNamespace;
|
|
||||||
use RecursiveDirectoryIterator;
|
|
||||||
use RecursiveIteratorIterator;
|
|
||||||
|
|
||||||
class DemoServiceProvider extends ServiceProvider
|
|
||||||
{
|
|
||||||
use PathNamespace;
|
|
||||||
|
|
||||||
protected string $name = 'Demo';
|
|
||||||
|
|
||||||
protected string $nameLower = 'demo';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Boot the application events.
|
|
||||||
*/
|
|
||||||
public function boot(): void
|
|
||||||
{
|
|
||||||
$this->registerCommands();
|
|
||||||
$this->registerCommandSchedules();
|
|
||||||
$this->registerTranslations();
|
|
||||||
$this->registerConfig();
|
|
||||||
$this->registerViews();
|
|
||||||
$this->loadMigrationsFrom(module_path($this->name, '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->nameLower);
|
|
||||||
|
|
||||||
if (is_dir($langPath)) {
|
|
||||||
$this->loadTranslationsFrom($langPath, $this->nameLower);
|
|
||||||
$this->loadJsonTranslationsFrom($langPath);
|
|
||||||
} else {
|
|
||||||
$this->loadTranslationsFrom(module_path($this->name, 'lang'), $this->nameLower);
|
|
||||||
$this->loadJsonTranslationsFrom(module_path($this->name, 'lang'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register config.
|
|
||||||
*/
|
|
||||||
protected function registerConfig(): void
|
|
||||||
{
|
|
||||||
$configPath = module_path($this->name, config('modules.paths.generator.config.path'));
|
|
||||||
|
|
||||||
if (is_dir($configPath)) {
|
|
||||||
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($configPath));
|
|
||||||
|
|
||||||
foreach ($iterator as $file) {
|
|
||||||
if ($file->isFile() && $file->getExtension() === 'php') {
|
|
||||||
$config = str_replace($configPath.DIRECTORY_SEPARATOR, '', $file->getPathname());
|
|
||||||
$config_key = str_replace([DIRECTORY_SEPARATOR, '.php'], ['.', ''], $config);
|
|
||||||
$segments = explode('.', $this->nameLower.'.'.$config_key);
|
|
||||||
|
|
||||||
// Remove duplicated adjacent segments
|
|
||||||
$normalized = [];
|
|
||||||
foreach ($segments as $segment) {
|
|
||||||
if (end($normalized) !== $segment) {
|
|
||||||
$normalized[] = $segment;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$key = ($config === 'config.php') ? $this->nameLower : implode('.', $normalized);
|
|
||||||
|
|
||||||
$this->publishes([$file->getPathname() => config_path($config)], 'config');
|
|
||||||
$this->merge_config_from($file->getPathname(), $key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Merge config from the given path recursively.
|
|
||||||
*/
|
|
||||||
protected function merge_config_from(string $path, string $key): void
|
|
||||||
{
|
|
||||||
$existing = config($key, []);
|
|
||||||
$module_config = require $path;
|
|
||||||
|
|
||||||
config([$key => array_replace_recursive($existing, $module_config)]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register views.
|
|
||||||
*/
|
|
||||||
public function registerViews(): void
|
|
||||||
{
|
|
||||||
$viewPath = resource_path('views/modules/'.$this->nameLower);
|
|
||||||
$sourcePath = module_path($this->name, 'resources/views');
|
|
||||||
|
|
||||||
$this->publishes([$sourcePath => $viewPath], ['views', $this->nameLower.'-module-views']);
|
|
||||||
|
|
||||||
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->nameLower);
|
|
||||||
|
|
||||||
Blade::componentNamespace(config('modules.namespace').'\\' . $this->name . '\\View\\Components', $this->nameLower);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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->nameLower)) {
|
|
||||||
$paths[] = $path.'/modules/'.$this->nameLower;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $paths;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Modules\Demo\Providers;
|
|
||||||
|
|
||||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
|
||||||
|
|
||||||
class EventServiceProvider extends ServiceProvider
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The event handler mappings for the application.
|
|
||||||
*
|
|
||||||
* @var array<string, array<int, string>>
|
|
||||||
*/
|
|
||||||
protected $listen = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates if events should be discovered.
|
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
protected static $shouldDiscoverEvents = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configure the proper event listeners for email verification.
|
|
||||||
*/
|
|
||||||
protected function configureEmailVerification(): void {}
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Modules\Demo\Providers;
|
|
||||||
|
|
||||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
|
||||||
use Illuminate\Support\Facades\Route;
|
|
||||||
|
|
||||||
class RouteServiceProvider extends ServiceProvider
|
|
||||||
{
|
|
||||||
protected string $name = 'Demo';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called before routes are registered.
|
|
||||||
*
|
|
||||||
* Register any model bindings or pattern based filters.
|
|
||||||
*/
|
|
||||||
public function boot(): void
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the routes for the application.
|
|
||||||
*/
|
|
||||||
public function map(): void
|
|
||||||
{
|
|
||||||
$this->mapApiRoutes();
|
|
||||||
$this->mapWebRoutes();
|
|
||||||
$this->mapAdminRoutes();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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($this->name, '/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($this->name, '/routes/api.php'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the "api" routes for the application.
|
|
||||||
*
|
|
||||||
* These routes are typically stateless.
|
|
||||||
*/
|
|
||||||
protected function mapAdminRoutes(): void
|
|
||||||
{
|
|
||||||
Route::middleware('admin')->prefix('admin')->name('admin.')->group(module_path($this->name, '/routes/admin.php'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "nwidart/demo",
|
|
||||||
"description": "",
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Nicolas Widart",
|
|
||||||
"email": "n.widart@gmail.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"extra": {
|
|
||||||
"laravel": {
|
|
||||||
"providers": [],
|
|
||||||
"aliases": {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Modules\\Demo\\": "app/",
|
|
||||||
"Modules\\Demo\\Database\\Factories\\": "database/factories/",
|
|
||||||
"Modules\\Demo\\Database\\Seeders\\": "database/seeders/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload-dev": {
|
|
||||||
"psr-4": {
|
|
||||||
"Modules\\Demo\\Tests\\": "tests/"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
'name' => 'Demo',
|
|
||||||
];
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Modules\Demo\Database\Seeders;
|
|
||||||
|
|
||||||
use Illuminate\Database\Seeder;
|
|
||||||
|
|
||||||
class DemoDatabaseSeeder extends Seeder
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the database seeds.
|
|
||||||
*/
|
|
||||||
public function run(): void
|
|
||||||
{
|
|
||||||
// $this->call([]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "Demo",
|
|
||||||
"alias": "demo",
|
|
||||||
"description": "",
|
|
||||||
"keywords": [],
|
|
||||||
"priority": 0,
|
|
||||||
"providers": [
|
|
||||||
"Modules\\Demo\\Providers\\DemoServiceProvider"
|
|
||||||
],
|
|
||||||
"files": []
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
||||||
|
|
||||||
<title>Demo Module - {{ config('app.name', 'Laravel') }}</title>
|
|
||||||
|
|
||||||
<meta name="description" content="{{ $description ?? '' }}">
|
|
||||||
<meta name="keywords" content="{{ $keywords ?? '' }}">
|
|
||||||
<meta name="author" content="{{ $author ?? '' }}">
|
|
||||||
|
|
||||||
<!-- Fonts -->
|
|
||||||
<link rel="preconnect" href="https://fonts.bunny.net">
|
|
||||||
<link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />
|
|
||||||
|
|
||||||
{{-- Vite CSS --}}
|
|
||||||
{{-- {{ module_vite('build-demo', 'resources/assets/sass/app.scss') }} --}}
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
{{ $slot }}
|
|
||||||
|
|
||||||
{{-- Vite JS --}}
|
|
||||||
{{-- {{ module_vite('build-demo', 'resources/assets/js/app.js') }} --}}
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<x-demo::layouts.master>
|
|
||||||
<h1>Hello World</h1>
|
|
||||||
|
|
||||||
<p>Module: {!! config('demo.name') !!}</p>
|
|
||||||
</x-demo::layouts.master>
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Route;
|
|
||||||
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Route;
|
|
||||||
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Route;
|
|
||||||
use Modules\Demo\Http\Controllers\DemoController;
|
|
||||||
|
|
||||||
Route::middleware(['auth', 'verified'])->group(function () {
|
|
||||||
Route::resource('demos', DemoController::class)->names('demo');
|
|
||||||
});
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
import { defineConfig } from 'vite';
|
|
||||||
import laravel from 'laravel-vite-plugin';
|
|
||||||
import { readdirSync, statSync } from 'fs';
|
|
||||||
import { join,relative,dirname } from 'path';
|
|
||||||
import { fileURLToPath } from 'url';
|
|
||||||
|
|
||||||
export default defineConfig({
|
|
||||||
build: {
|
|
||||||
outDir: '../../public/build-demo',
|
|
||||||
emptyOutDir: true,
|
|
||||||
manifest: true,
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
laravel({
|
|
||||||
publicDirectory: '../../public',
|
|
||||||
buildDirectory: 'build-demo',
|
|
||||||
input: [
|
|
||||||
__dirname + '/resources/assets/sass/app.scss',
|
|
||||||
__dirname + '/resources/assets/js/app.js'
|
|
||||||
],
|
|
||||||
refresh: true,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
});
|
|
||||||
// Scen all resources for assets file. Return array
|
|
||||||
//function getFilePaths(dir) {
|
|
||||||
// const filePaths = [];
|
|
||||||
//
|
|
||||||
// function walkDirectory(currentPath) {
|
|
||||||
// const files = readdirSync(currentPath);
|
|
||||||
// for (const file of files) {
|
|
||||||
// const filePath = join(currentPath, file);
|
|
||||||
// const stats = statSync(filePath);
|
|
||||||
// if (stats.isFile() && !file.startsWith('.')) {
|
|
||||||
// const relativePath = 'Modules/Demo/'+relative(__dirname, filePath);
|
|
||||||
// filePaths.push(relativePath);
|
|
||||||
// } else if (stats.isDirectory()) {
|
|
||||||
// walkDirectory(filePath);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// walkDirectory(dir);
|
|
||||||
// return filePaths;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//const __filename = fileURLToPath(import.meta.url);
|
|
||||||
//const __dirname = dirname(__filename);
|
|
||||||
|
|
||||||
//const assetsDir = join(__dirname, 'resources/assets');
|
|
||||||
//export const paths = getFilePaths(assetsDir);
|
|
||||||
|
|
||||||
|
|
||||||
//export const paths = [
|
|
||||||
// 'Modules/Demo/resources/assets/sass/app.scss',
|
|
||||||
// 'Modules/Demo/resources/assets/js/app.js',
|
|
||||||
//];
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Modules\Demo\Http\Controllers\Admin;
|
|
||||||
|
|
||||||
class Index {
|
|
||||||
|
|
||||||
public function index(){}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Modules\Demo\Http\Controllers\Api;
|
|
||||||
|
|
||||||
class Index {
|
|
||||||
|
|
||||||
public function index(){}
|
|
||||||
}
|
|
||||||
@@ -1,154 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Modules\Demo\Providers;
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Blade;
|
|
||||||
use Illuminate\Support\ServiceProvider;
|
|
||||||
use Nwidart\Modules\Traits\PathNamespace;
|
|
||||||
use RecursiveDirectoryIterator;
|
|
||||||
use RecursiveIteratorIterator;
|
|
||||||
|
|
||||||
class DemoServiceProvider extends ServiceProvider
|
|
||||||
{
|
|
||||||
use PathNamespace;
|
|
||||||
|
|
||||||
protected string $name = 'Demo';
|
|
||||||
|
|
||||||
protected string $nameLower = 'demo';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Boot the application events.
|
|
||||||
*/
|
|
||||||
public function boot(): void
|
|
||||||
{
|
|
||||||
$this->registerCommands();
|
|
||||||
$this->registerCommandSchedules();
|
|
||||||
$this->registerTranslations();
|
|
||||||
$this->registerConfig();
|
|
||||||
$this->registerViews();
|
|
||||||
$this->loadMigrationsFrom(module_path($this->name, '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->nameLower);
|
|
||||||
|
|
||||||
if (is_dir($langPath)) {
|
|
||||||
$this->loadTranslationsFrom($langPath, $this->nameLower);
|
|
||||||
$this->loadJsonTranslationsFrom($langPath);
|
|
||||||
} else {
|
|
||||||
$this->loadTranslationsFrom(module_path($this->name, 'lang'), $this->nameLower);
|
|
||||||
$this->loadJsonTranslationsFrom(module_path($this->name, 'lang'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register config.
|
|
||||||
*/
|
|
||||||
protected function registerConfig(): void
|
|
||||||
{
|
|
||||||
$configPath = module_path($this->name, config('modules.paths.generator.config.path'));
|
|
||||||
|
|
||||||
if (is_dir($configPath)) {
|
|
||||||
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($configPath));
|
|
||||||
|
|
||||||
foreach ($iterator as $file) {
|
|
||||||
if ($file->isFile() && $file->getExtension() === 'php') {
|
|
||||||
$config = str_replace($configPath.DIRECTORY_SEPARATOR, '', $file->getPathname());
|
|
||||||
$config_key = str_replace([DIRECTORY_SEPARATOR, '.php'], ['.', ''], $config);
|
|
||||||
$segments = explode('.', $this->nameLower.'.'.$config_key);
|
|
||||||
|
|
||||||
// Remove duplicated adjacent segments
|
|
||||||
$normalized = [];
|
|
||||||
foreach ($segments as $segment) {
|
|
||||||
if (end($normalized) !== $segment) {
|
|
||||||
$normalized[] = $segment;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$key = ($config === 'config.php') ? $this->nameLower : implode('.', $normalized);
|
|
||||||
|
|
||||||
$this->publishes([$file->getPathname() => config_path($config)], 'config');
|
|
||||||
$this->merge_config_from($file->getPathname(), $key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Merge config from the given path recursively.
|
|
||||||
*/
|
|
||||||
protected function merge_config_from(string $path, string $key): void
|
|
||||||
{
|
|
||||||
$existing = config($key, []);
|
|
||||||
$module_config = require $path;
|
|
||||||
|
|
||||||
config([$key => array_replace_recursive($existing, $module_config)]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register views.
|
|
||||||
*/
|
|
||||||
public function registerViews(): void
|
|
||||||
{
|
|
||||||
$viewPath = resource_path('views/modules/'.$this->nameLower);
|
|
||||||
$sourcePath = module_path($this->name, 'resources/views');
|
|
||||||
|
|
||||||
$this->publishes([$sourcePath => $viewPath], ['views', $this->nameLower.'-module-views']);
|
|
||||||
|
|
||||||
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->nameLower);
|
|
||||||
|
|
||||||
Blade::componentNamespace(config('modules.namespace').'\\' . $this->name . '\\View\\Components', $this->nameLower);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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->nameLower)) {
|
|
||||||
$paths[] = $path.'/modules/'.$this->nameLower;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $paths;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Modules\Demo\Providers;
|
|
||||||
|
|
||||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
|
||||||
|
|
||||||
class EventServiceProvider extends ServiceProvider
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The event handler mappings for the application.
|
|
||||||
*
|
|
||||||
* @var array<string, array<int, string>>
|
|
||||||
*/
|
|
||||||
protected $listen = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates if events should be discovered.
|
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
protected static $shouldDiscoverEvents = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configure the proper event listeners for email verification.
|
|
||||||
*/
|
|
||||||
protected function configureEmailVerification(): void {}
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Modules\Demo\Providers;
|
|
||||||
|
|
||||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
|
||||||
use Illuminate\Support\Facades\Route;
|
|
||||||
|
|
||||||
class RouteServiceProvider extends ServiceProvider
|
|
||||||
{
|
|
||||||
protected string $name = 'Demo';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called before routes are registered.
|
|
||||||
*
|
|
||||||
* Register any model bindings or pattern based filters.
|
|
||||||
*/
|
|
||||||
public function boot(): void
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the routes for the application.
|
|
||||||
*/
|
|
||||||
public function map(): void
|
|
||||||
{
|
|
||||||
$this->mapApiRoutes();
|
|
||||||
$this->mapWebRoutes();
|
|
||||||
$this->mapAdminRoutes();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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($this->name, '/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($this->name, '/routes/api.php'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the "api" routes for the application.
|
|
||||||
*
|
|
||||||
* These routes are typically stateless.
|
|
||||||
*/
|
|
||||||
protected function mapAdminRoutes(): void
|
|
||||||
{
|
|
||||||
Route::middleware('admin')->prefix('admin')->name('admin.')->group(module_path($this->name, '/routes/admin.php'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "nwidart/demo",
|
|
||||||
"description": "",
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Nicolas Widart",
|
|
||||||
"email": "n.widart@gmail.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"extra": {
|
|
||||||
"laravel": {
|
|
||||||
"providers": [],
|
|
||||||
"aliases": {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Modules\\Demo\\": "app/",
|
|
||||||
"Modules\\Demo\\Database\\Factories\\": "database/factories/",
|
|
||||||
"Modules\\Demo\\Database\\Seeders\\": "database/seeders/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload-dev": {
|
|
||||||
"psr-4": {
|
|
||||||
"Modules\\Demo\\Tests\\": "tests/"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
'name' => 'Demo',
|
|
||||||
];
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Modules\Demo\Database\Seeders;
|
|
||||||
|
|
||||||
use Illuminate\Database\Seeder;
|
|
||||||
|
|
||||||
class DemoDatabaseSeeder extends Seeder
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the database seeds.
|
|
||||||
*/
|
|
||||||
public function run(): void
|
|
||||||
{
|
|
||||||
// $this->call([]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "Demo",
|
|
||||||
"alias": "demo",
|
|
||||||
"description": "",
|
|
||||||
"keywords": [],
|
|
||||||
"priority": 0,
|
|
||||||
"providers": [
|
|
||||||
"Modules\\Demo\\Providers\\DemoServiceProvider"
|
|
||||||
],
|
|
||||||
"files": []
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
||||||
|
|
||||||
<title>Demo Module - {{ config('app.name', 'Laravel') }}</title>
|
|
||||||
|
|
||||||
<meta name="description" content="{{ $description ?? '' }}">
|
|
||||||
<meta name="keywords" content="{{ $keywords ?? '' }}">
|
|
||||||
<meta name="author" content="{{ $author ?? '' }}">
|
|
||||||
|
|
||||||
<!-- Fonts -->
|
|
||||||
<link rel="preconnect" href="https://fonts.bunny.net">
|
|
||||||
<link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />
|
|
||||||
|
|
||||||
{{-- Vite CSS --}}
|
|
||||||
{{-- {{ module_vite('build-demo', 'resources/assets/sass/app.scss') }} --}}
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
{{ $slot }}
|
|
||||||
|
|
||||||
{{-- Vite JS --}}
|
|
||||||
{{-- {{ module_vite('build-demo', 'resources/assets/js/app.js') }} --}}
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<x-demo::layouts.master>
|
|
||||||
<h1>Hello World</h1>
|
|
||||||
|
|
||||||
<p>Module: {!! config('demo.name') !!}</p>
|
|
||||||
</x-demo::layouts.master>
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Route;
|
|
||||||
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Route;
|
|
||||||
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Route;
|
|
||||||
use Modules\Demo\Http\Controllers\DemoController;
|
|
||||||
|
|
||||||
Route::middleware(['auth', 'verified'])->group(function () {
|
|
||||||
Route::resource('demos', DemoController::class)->names('demo');
|
|
||||||
});
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
import { defineConfig } from 'vite';
|
|
||||||
import laravel from 'laravel-vite-plugin';
|
|
||||||
import { readdirSync, statSync } from 'fs';
|
|
||||||
import { join,relative,dirname } from 'path';
|
|
||||||
import { fileURLToPath } from 'url';
|
|
||||||
|
|
||||||
export default defineConfig({
|
|
||||||
build: {
|
|
||||||
outDir: '../../public/build-demo',
|
|
||||||
emptyOutDir: true,
|
|
||||||
manifest: true,
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
laravel({
|
|
||||||
publicDirectory: '../../public',
|
|
||||||
buildDirectory: 'build-demo',
|
|
||||||
input: [
|
|
||||||
__dirname + '/resources/assets/sass/app.scss',
|
|
||||||
__dirname + '/resources/assets/js/app.js'
|
|
||||||
],
|
|
||||||
refresh: true,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
});
|
|
||||||
// Scen all resources for assets file. Return array
|
|
||||||
//function getFilePaths(dir) {
|
|
||||||
// const filePaths = [];
|
|
||||||
//
|
|
||||||
// function walkDirectory(currentPath) {
|
|
||||||
// const files = readdirSync(currentPath);
|
|
||||||
// for (const file of files) {
|
|
||||||
// const filePath = join(currentPath, file);
|
|
||||||
// const stats = statSync(filePath);
|
|
||||||
// if (stats.isFile() && !file.startsWith('.')) {
|
|
||||||
// const relativePath = 'Modules/Demo/'+relative(__dirname, filePath);
|
|
||||||
// filePaths.push(relativePath);
|
|
||||||
// } else if (stats.isDirectory()) {
|
|
||||||
// walkDirectory(filePath);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// walkDirectory(dir);
|
|
||||||
// return filePaths;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//const __filename = fileURLToPath(import.meta.url);
|
|
||||||
//const __dirname = dirname(__filename);
|
|
||||||
|
|
||||||
//const assetsDir = join(__dirname, 'resources/assets');
|
|
||||||
//export const paths = getFilePaths(assetsDir);
|
|
||||||
|
|
||||||
|
|
||||||
//export const paths = [
|
|
||||||
// 'Modules/Demo/resources/assets/sass/app.scss',
|
|
||||||
// 'Modules/Demo/resources/assets/js/app.js',
|
|
||||||
//];
|
|
||||||
Reference in New Issue
Block a user