Compare commits
2 Commits
0b6df835fc
...
133e16b610
Author | SHA1 | Date |
---|---|---|
|
133e16b610 | 3 weeks ago |
|
43b15ed9ad | 3 weeks ago |
102 changed files with 2432 additions and 2 deletions
@ -0,0 +1,56 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace Modules\Api\Http\Controllers; |
||||||
|
|
||||||
|
use App\Http\Controllers\Controller; |
||||||
|
use Illuminate\Http\Request; |
||||||
|
|
||||||
|
class ApiController extends Controller |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Display a listing of the resource. |
||||||
|
*/ |
||||||
|
public function index() |
||||||
|
{ |
||||||
|
return view('api::index'); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Show the form for creating a new resource. |
||||||
|
*/ |
||||||
|
public function create() |
||||||
|
{ |
||||||
|
return view('api::create'); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Store a newly created resource in storage. |
||||||
|
*/ |
||||||
|
public function store(Request $request) {} |
||||||
|
|
||||||
|
/** |
||||||
|
* Show the specified resource. |
||||||
|
*/ |
||||||
|
public function show($id) |
||||||
|
{ |
||||||
|
return view('api::show'); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Show the form for editing the specified resource. |
||||||
|
*/ |
||||||
|
public function edit($id) |
||||||
|
{ |
||||||
|
return view('api::edit'); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Update the specified resource in storage. |
||||||
|
*/ |
||||||
|
public function update(Request $request, $id) {} |
||||||
|
|
||||||
|
/** |
||||||
|
* Remove the specified resource from storage. |
||||||
|
*/ |
||||||
|
public function destroy($id) {} |
||||||
|
} |
@ -0,0 +1,154 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace Modules\Api\Providers; |
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Blade; |
||||||
|
use Illuminate\Support\ServiceProvider; |
||||||
|
use Nwidart\Modules\Traits\PathNamespace; |
||||||
|
use RecursiveDirectoryIterator; |
||||||
|
use RecursiveIteratorIterator; |
||||||
|
|
||||||
|
class ApiServiceProvider extends ServiceProvider |
||||||
|
{ |
||||||
|
use PathNamespace; |
||||||
|
|
||||||
|
protected string $name = 'Api'; |
||||||
|
|
||||||
|
protected string $nameLower = 'api'; |
||||||
|
|
||||||
|
/** |
||||||
|
* 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; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,27 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace Modules\Api\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 {} |
||||||
|
} |
@ -0,0 +1,50 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace Modules\Api\Providers; |
||||||
|
|
||||||
|
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; |
||||||
|
use Illuminate\Support\Facades\Route; |
||||||
|
|
||||||
|
class RouteServiceProvider extends ServiceProvider |
||||||
|
{ |
||||||
|
protected string $name = 'Api'; |
||||||
|
|
||||||
|
/** |
||||||
|
* 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(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 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')); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,30 @@ |
|||||||
|
{ |
||||||
|
"name": "nwidart/api", |
||||||
|
"description": "", |
||||||
|
"authors": [ |
||||||
|
{ |
||||||
|
"name": "Nicolas Widart", |
||||||
|
"email": "n.widart@gmail.com" |
||||||
|
} |
||||||
|
], |
||||||
|
"extra": { |
||||||
|
"laravel": { |
||||||
|
"providers": [], |
||||||
|
"aliases": { |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
}, |
||||||
|
"autoload": { |
||||||
|
"psr-4": { |
||||||
|
"Modules\\Api\\": "app/", |
||||||
|
"Modules\\Api\\Database\\Factories\\": "database/factories/", |
||||||
|
"Modules\\Api\\Database\\Seeders\\": "database/seeders/" |
||||||
|
} |
||||||
|
}, |
||||||
|
"autoload-dev": { |
||||||
|
"psr-4": { |
||||||
|
"Modules\\Api\\Tests\\": "tests/" |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,5 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
return [ |
||||||
|
'name' => 'Api', |
||||||
|
]; |
@ -0,0 +1,16 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace Modules\Api\Database\Seeders; |
||||||
|
|
||||||
|
use Illuminate\Database\Seeder; |
||||||
|
|
||||||
|
class ApiDatabaseSeeder extends Seeder |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Run the database seeds. |
||||||
|
*/ |
||||||
|
public function run(): void |
||||||
|
{ |
||||||
|
// $this->call([]); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,16 @@ |
|||||||
|
{ |
||||||
|
"name": "modules/api", |
||||||
|
"description": "", |
||||||
|
"type": "module", |
||||||
|
"autoload": { |
||||||
|
"psr-4": { |
||||||
|
"Modules\\Api\\": "app/" |
||||||
|
} |
||||||
|
}, |
||||||
|
"extra": { |
||||||
|
"laravel": { |
||||||
|
"providers": [] |
||||||
|
} |
||||||
|
}, |
||||||
|
"require": {} |
||||||
|
} |
@ -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" |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,29 @@ |
|||||||
|
<!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>Api 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-api', 'resources/assets/sass/app.scss') }} --}} |
||||||
|
</head> |
||||||
|
|
||||||
|
<body> |
||||||
|
{{ $slot }} |
||||||
|
|
||||||
|
{{-- Vite JS --}} |
||||||
|
{{-- {{ module_vite('build-api', 'resources/assets/js/app.js') }} --}} |
||||||
|
</body> |
@ -0,0 +1,5 @@ |
|||||||
|
<x-api::layouts.master> |
||||||
|
<h1>Hello World</h1> |
||||||
|
|
||||||
|
<p>Module: {!! config('api.name') !!}</p> |
||||||
|
</x-api::layouts.master> |
@ -0,0 +1,8 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Route; |
||||||
|
use Modules\Api\Http\Controllers\ApiController; |
||||||
|
|
||||||
|
Route::middleware(['auth:sanctum'])->prefix('v1')->group(function () { |
||||||
|
Route::apiResource('apis', ApiController::class)->names('api'); |
||||||
|
}); |
@ -0,0 +1,8 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Route; |
||||||
|
use Modules\Api\Http\Controllers\ApiController; |
||||||
|
|
||||||
|
Route::middleware(['auth', 'verified'])->group(function () { |
||||||
|
Route::resource('apis', ApiController::class)->names('api'); |
||||||
|
}); |
@ -0,0 +1,57 @@ |
|||||||
|
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-api', |
||||||
|
emptyOutDir: true, |
||||||
|
manifest: true, |
||||||
|
}, |
||||||
|
plugins: [ |
||||||
|
laravel({ |
||||||
|
publicDirectory: '../../public', |
||||||
|
buildDirectory: 'build-api', |
||||||
|
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/Api/'+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/Api/resources/assets/sass/app.scss',
|
||||||
|
// 'Modules/Api/resources/assets/js/app.js',
|
||||||
|
//];
|
@ -0,0 +1,298 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
use Nwidart\Modules\Activators\FileActivator; |
||||||
|
use Nwidart\Modules\Providers\ConsoleServiceProvider; |
||||||
|
|
||||||
|
return [ |
||||||
|
|
||||||
|
/* |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| Module Namespace |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| |
||||||
|
| Default module namespace. |
||||||
|
| |
||||||
|
*/ |
||||||
|
'namespace' => 'Modules', |
||||||
|
|
||||||
|
/* |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| Module Stubs |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| |
||||||
|
| Default module stubs. |
||||||
|
| |
||||||
|
*/ |
||||||
|
'stubs' => [ |
||||||
|
'enabled' => false, |
||||||
|
'path' => base_path('vendor/nwidart/laravel-modules/src/Commands/stubs'), |
||||||
|
'files' => [ |
||||||
|
'routes/web' => 'routes/web.php', |
||||||
|
'routes/api' => 'routes/api.php', |
||||||
|
'views/index' => 'resources/views/index.blade.php', |
||||||
|
'views/master' => 'resources/views/components/layouts/master.blade.php', |
||||||
|
'scaffold/config' => 'config/config.php', |
||||||
|
'composer' => 'composer.json', |
||||||
|
'assets/js/app' => 'resources/assets/js/app.js', |
||||||
|
'assets/sass/app' => 'resources/assets/sass/app.scss', |
||||||
|
'vite' => 'vite.config.js', |
||||||
|
'package' => 'package.json', |
||||||
|
], |
||||||
|
'replacements' => [ |
||||||
|
/** |
||||||
|
* Define custom replacements for each section. |
||||||
|
* You can specify a closure for dynamic values. |
||||||
|
* |
||||||
|
* Example: |
||||||
|
* |
||||||
|
* 'composer' => [ |
||||||
|
* 'CUSTOM_KEY' => fn (\Nwidart\Modules\Generators\ModuleGenerator $generator) => $generator->getModule()->getLowerName() . '-module', |
||||||
|
* 'CUSTOM_KEY2' => fn () => 'custom text', |
||||||
|
* 'LOWER_NAME', |
||||||
|
* 'STUDLY_NAME', |
||||||
|
* // ... |
||||||
|
* ], |
||||||
|
* |
||||||
|
* Note: Keys should be in UPPERCASE. |
||||||
|
*/ |
||||||
|
'routes/web' => ['LOWER_NAME', 'STUDLY_NAME', 'PLURAL_LOWER_NAME', 'KEBAB_NAME', 'MODULE_NAMESPACE', 'CONTROLLER_NAMESPACE'], |
||||||
|
'routes/api' => ['LOWER_NAME', 'STUDLY_NAME', 'PLURAL_LOWER_NAME', 'KEBAB_NAME', 'MODULE_NAMESPACE', 'CONTROLLER_NAMESPACE'], |
||||||
|
'vite' => ['LOWER_NAME', 'STUDLY_NAME', 'KEBAB_NAME'], |
||||||
|
'json' => ['LOWER_NAME', 'STUDLY_NAME', 'KEBAB_NAME', 'MODULE_NAMESPACE', 'PROVIDER_NAMESPACE'], |
||||||
|
'views/index' => ['LOWER_NAME'], |
||||||
|
'views/master' => ['LOWER_NAME', 'STUDLY_NAME', 'KEBAB_NAME'], |
||||||
|
'scaffold/config' => ['STUDLY_NAME'], |
||||||
|
'composer' => [ |
||||||
|
'LOWER_NAME', |
||||||
|
'STUDLY_NAME', |
||||||
|
'VENDOR', |
||||||
|
'AUTHOR_NAME', |
||||||
|
'AUTHOR_EMAIL', |
||||||
|
'MODULE_NAMESPACE', |
||||||
|
'PROVIDER_NAMESPACE', |
||||||
|
'APP_FOLDER_NAME', |
||||||
|
], |
||||||
|
], |
||||||
|
'gitkeep' => true, |
||||||
|
], |
||||||
|
'paths' => [ |
||||||
|
/* |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| Modules path |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| |
||||||
|
| This path is used to save the generated module. |
||||||
|
| This path will also be added automatically to the list of scanned folders. |
||||||
|
| |
||||||
|
*/ |
||||||
|
'modules' => base_path('Modules'), |
||||||
|
|
||||||
|
/* |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| Modules assets path |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| |
||||||
|
| Here you may update the modules' assets path. |
||||||
|
| |
||||||
|
*/ |
||||||
|
'assets' => public_path('modules'), |
||||||
|
|
||||||
|
/* |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| The migrations' path |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| |
||||||
|
| Where you run the 'module:publish-migration' command, where do you publish the |
||||||
|
| the migration files? |
||||||
|
| |
||||||
|
*/ |
||||||
|
'migration' => base_path('database/migrations'), |
||||||
|
|
||||||
|
/* |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| The app path |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| |
||||||
|
| app folder name |
||||||
|
| for example can change it to 'src' or 'App' |
||||||
|
*/ |
||||||
|
'app_folder' => 'app/', |
||||||
|
|
||||||
|
/* |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| Generator path |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| Customise the paths where the folders will be generated. |
||||||
|
| Setting the generate key to false will not generate that folder |
||||||
|
*/ |
||||||
|
'generator' => [ |
||||||
|
// app/ |
||||||
|
'actions' => ['path' => 'app/Actions', 'generate' => false], |
||||||
|
'casts' => ['path' => 'app/Casts', 'generate' => false], |
||||||
|
'channels' => ['path' => 'app/Broadcasting', 'generate' => false], |
||||||
|
'class' => ['path' => 'app/Classes', 'generate' => false], |
||||||
|
'command' => ['path' => 'app/Console', 'generate' => false], |
||||||
|
'component-class' => ['path' => 'app/View/Components', 'generate' => false], |
||||||
|
'emails' => ['path' => 'app/Emails', 'generate' => false], |
||||||
|
'event' => ['path' => 'app/Events', 'generate' => false], |
||||||
|
'enums' => ['path' => 'app/Enums', 'generate' => false], |
||||||
|
'exceptions' => ['path' => 'app/Exceptions', 'generate' => false], |
||||||
|
'jobs' => ['path' => 'app/Jobs', 'generate' => false], |
||||||
|
'helpers' => ['path' => 'app/Helpers', 'generate' => false], |
||||||
|
'interfaces' => ['path' => 'app/Interfaces', 'generate' => false], |
||||||
|
'listener' => ['path' => 'app/Listeners', 'generate' => false], |
||||||
|
'model' => ['path' => 'app/Models', 'generate' => false], |
||||||
|
'notifications' => ['path' => 'app/Notifications', 'generate' => false], |
||||||
|
'observer' => ['path' => 'app/Observers', 'generate' => false], |
||||||
|
'policies' => ['path' => 'app/Policies', 'generate' => false], |
||||||
|
'provider' => ['path' => 'app/Providers', 'generate' => true], |
||||||
|
'repository' => ['path' => 'app/Repositories', 'generate' => false], |
||||||
|
'resource' => ['path' => 'app/Transformers', 'generate' => false], |
||||||
|
'route-provider' => ['path' => 'app/Providers', 'generate' => true], |
||||||
|
'rules' => ['path' => 'app/Rules', 'generate' => false], |
||||||
|
'services' => ['path' => 'app/Services', 'generate' => false], |
||||||
|
'scopes' => ['path' => 'app/Models/Scopes', 'generate' => false], |
||||||
|
'traits' => ['path' => 'app/Traits', 'generate' => false], |
||||||
|
|
||||||
|
// app/Http/ |
||||||
|
'controller' => ['path' => 'app/Http/Controllers', 'generate' => true], |
||||||
|
'filter' => ['path' => 'app/Http/Middleware', 'generate' => false], |
||||||
|
'request' => ['path' => 'app/Http/Requests', 'generate' => false], |
||||||
|
|
||||||
|
// config/ |
||||||
|
'config' => ['path' => 'config', 'generate' => true], |
||||||
|
|
||||||
|
// database/ |
||||||
|
'factory' => ['path' => 'database/factories', 'generate' => true], |
||||||
|
'migration' => ['path' => 'database/migrations', 'generate' => true], |
||||||
|
'seeder' => ['path' => 'database/seeders', 'generate' => true], |
||||||
|
|
||||||
|
// lang/ |
||||||
|
'lang' => ['path' => 'lang', 'generate' => false], |
||||||
|
|
||||||
|
// resource/ |
||||||
|
'assets' => ['path' => 'resources/assets', 'generate' => true], |
||||||
|
'component-view' => ['path' => 'resources/views/components', 'generate' => false], |
||||||
|
'views' => ['path' => 'resources/views', 'generate' => true], |
||||||
|
|
||||||
|
// routes/ |
||||||
|
'routes' => ['path' => 'routes', 'generate' => true], |
||||||
|
|
||||||
|
// tests/ |
||||||
|
'test-feature' => ['path' => 'tests/Feature', 'generate' => true], |
||||||
|
'test-unit' => ['path' => 'tests/Unit', 'generate' => true], |
||||||
|
], |
||||||
|
], |
||||||
|
|
||||||
|
/* |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| Auto Discover of Modules |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| |
||||||
|
| Here you configure auto discover of module |
||||||
|
| This is useful for simplify module providers. |
||||||
|
| |
||||||
|
*/ |
||||||
|
'auto-discover' => [ |
||||||
|
/* |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| Migrations |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| |
||||||
|
| This option for register migration automatically. |
||||||
|
| |
||||||
|
*/ |
||||||
|
'migrations' => true, |
||||||
|
|
||||||
|
/* |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| Translations |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| |
||||||
|
| This option for register lang file automatically. |
||||||
|
| |
||||||
|
*/ |
||||||
|
'translations' => false, |
||||||
|
|
||||||
|
], |
||||||
|
|
||||||
|
/* |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| Package commands |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| |
||||||
|
| Here you can define which commands will be visible and used in your |
||||||
|
| application. You can add your own commands to merge section. |
||||||
|
| |
||||||
|
*/ |
||||||
|
'commands' => ConsoleServiceProvider::defaultCommands() |
||||||
|
->merge([ |
||||||
|
// New commands go here |
||||||
|
])->toArray(), |
||||||
|
|
||||||
|
/* |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| Scan Path |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| |
||||||
|
| Here you define which folder will be scanned. By default will scan vendor |
||||||
|
| directory. This is useful if you host the package in packagist website. |
||||||
|
| |
||||||
|
*/ |
||||||
|
'scan' => [ |
||||||
|
'enabled' => false, |
||||||
|
'paths' => [ |
||||||
|
base_path('vendor/*/*'), |
||||||
|
], |
||||||
|
], |
||||||
|
|
||||||
|
/* |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| Composer File Template |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| |
||||||
|
| Here is the config for the composer.json file, generated by this package |
||||||
|
| |
||||||
|
*/ |
||||||
|
'composer' => [ |
||||||
|
'vendor' => env('MODULE_VENDOR', 'nwidart'), |
||||||
|
'author' => [ |
||||||
|
'name' => env('MODULE_AUTHOR_NAME', 'Nicolas Widart'), |
||||||
|
'email' => env('MODULE_AUTHOR_EMAIL', 'n.widart@gmail.com'), |
||||||
|
], |
||||||
|
'composer-output' => false, |
||||||
|
], |
||||||
|
|
||||||
|
/* |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| Choose what laravel-modules will register as custom namespaces. |
||||||
|
| Setting one to false will require you to register that part |
||||||
|
| in your own Service Provider class. |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
*/ |
||||||
|
'register' => [ |
||||||
|
'translations' => true, |
||||||
|
/** |
||||||
|
* load files on boot or register method |
||||||
|
*/ |
||||||
|
'files' => 'register', |
||||||
|
], |
||||||
|
|
||||||
|
/* |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| Activators |
||||||
|
|-------------------------------------------------------------------------- |
||||||
|
| |
||||||
|
| You can define new types of activators here, file, database, etc. The only |
||||||
|
| required parameter is 'class'. |
||||||
|
| The file activator will store the activation status in storage/installed_modules |
||||||
|
*/ |
||||||
|
'activators' => [ |
||||||
|
'file' => [ |
||||||
|
'class' => FileActivator::class, |
||||||
|
'statuses-file' => base_path('modules_statuses.json'), |
||||||
|
], |
||||||
|
], |
||||||
|
|
||||||
|
'activator' => 'file', |
||||||
|
]; |
@ -0,0 +1,3 @@ |
|||||||
|
{ |
||||||
|
"Api": true |
||||||
|
} |
@ -0,0 +1,8 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $CLASS_NAMESPACE$; |
||||||
|
|
||||||
|
class $CLASS$ |
||||||
|
{ |
||||||
|
public function __invoke() {} |
||||||
|
} |
@ -0,0 +1,8 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $CLASS_NAMESPACE$; |
||||||
|
|
||||||
|
class $CLASS$ |
||||||
|
{ |
||||||
|
public function handle() {} |
||||||
|
} |
@ -0,0 +1,25 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $CLASS_NAMESPACE$; |
||||||
|
|
||||||
|
use Illuminate\Contracts\Database\Eloquent\CastsAttributes; |
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
|
||||||
|
class $CLASS$ implements CastsAttributes |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Cast the given value. |
||||||
|
*/ |
||||||
|
public function get(Model $model, string $key, mixed $value, array $attributes): mixed |
||||||
|
{ |
||||||
|
return $value; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Prepare the given value for storage. |
||||||
|
*/ |
||||||
|
public function set(Model $model, string $key, mixed $value, array $attributes): mixed |
||||||
|
{ |
||||||
|
return $value; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,16 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
class $CLASS$ |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Create a new channel instance. |
||||||
|
*/ |
||||||
|
public function __construct() {} |
||||||
|
|
||||||
|
/** |
||||||
|
* Authenticate the user's access to the channel. |
||||||
|
*/ |
||||||
|
public function join(Operator $user): array|bool {} |
||||||
|
} |
@ -0,0 +1,8 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
class $CLASS$ |
||||||
|
{ |
||||||
|
public function __invoke() {} |
||||||
|
} |
@ -0,0 +1,8 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
class $CLASS$ |
||||||
|
{ |
||||||
|
public function __construct() {} |
||||||
|
} |
@ -0,0 +1,53 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
use Illuminate\Console\Command; |
||||||
|
use Symfony\Component\Console\Input\InputOption; |
||||||
|
use Symfony\Component\Console\Input\InputArgument; |
||||||
|
|
||||||
|
class $CLASS$ extends Command |
||||||
|
{ |
||||||
|
/** |
||||||
|
* The name and signature of the console command. |
||||||
|
*/ |
||||||
|
protected $signature = '$COMMAND_NAME$'; |
||||||
|
|
||||||
|
/** |
||||||
|
* The console command description. |
||||||
|
*/ |
||||||
|
protected $description = 'Command description.'; |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a new command instance. |
||||||
|
*/ |
||||||
|
public function __construct() |
||||||
|
{ |
||||||
|
parent::__construct(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Execute the console command. |
||||||
|
*/ |
||||||
|
public function handle() {} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the console command arguments. |
||||||
|
*/ |
||||||
|
protected function getArguments(): array |
||||||
|
{ |
||||||
|
return [ |
||||||
|
['example', InputArgument::REQUIRED, 'An example argument.'], |
||||||
|
]; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the console command options. |
||||||
|
*/ |
||||||
|
protected function getOptions(): array |
||||||
|
{ |
||||||
|
return [ |
||||||
|
['example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null], |
||||||
|
]; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,22 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
use Illuminate\View\Component; |
||||||
|
use Illuminate\View\View; |
||||||
|
|
||||||
|
class $CLASS$ extends Component |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Create a new component instance. |
||||||
|
*/ |
||||||
|
public function __construct() {} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the view/contents that represent the component. |
||||||
|
*/ |
||||||
|
public function render(): View|string |
||||||
|
{ |
||||||
|
return view('$LOWER_NAME$::$COMPONENT_NAME$'); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,3 @@ |
|||||||
|
<div> |
||||||
|
<!-- $QUOTE$ --> |
||||||
|
</div> |
@ -0,0 +1,30 @@ |
|||||||
|
{ |
||||||
|
"name": "$VENDOR$/$LOWER_NAME$", |
||||||
|
"description": "", |
||||||
|
"authors": [ |
||||||
|
{ |
||||||
|
"name": "$AUTHOR_NAME$", |
||||||
|
"email": "$AUTHOR_EMAIL$" |
||||||
|
} |
||||||
|
], |
||||||
|
"extra": { |
||||||
|
"laravel": { |
||||||
|
"providers": [], |
||||||
|
"aliases": { |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
}, |
||||||
|
"autoload": { |
||||||
|
"psr-4": { |
||||||
|
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\": "$APP_FOLDER_NAME$", |
||||||
|
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Database\\Factories\\": "database/factories/", |
||||||
|
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Database\\Seeders\\": "database/seeders/" |
||||||
|
} |
||||||
|
}, |
||||||
|
"autoload-dev": { |
||||||
|
"psr-4": { |
||||||
|
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Tests\\": "tests/" |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,59 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $CLASS_NAMESPACE$; |
||||||
|
|
||||||
|
use App\Http\Controllers\Controller; |
||||||
|
use Illuminate\Http\Request; |
||||||
|
|
||||||
|
class $CLASS$ extends Controller |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Display a listing of the resource. |
||||||
|
*/ |
||||||
|
public function index() |
||||||
|
{ |
||||||
|
// |
||||||
|
|
||||||
|
return response()->json([]); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Store a newly created resource in storage. |
||||||
|
*/ |
||||||
|
public function store(Request $request) |
||||||
|
{ |
||||||
|
// |
||||||
|
|
||||||
|
return response()->json([]); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Show the specified resource. |
||||||
|
*/ |
||||||
|
public function show($id) |
||||||
|
{ |
||||||
|
// |
||||||
|
|
||||||
|
return response()->json([]); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Update the specified resource in storage. |
||||||
|
*/ |
||||||
|
public function update(Request $request, $id) |
||||||
|
{ |
||||||
|
// |
||||||
|
|
||||||
|
return response()->json([]); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Remove the specified resource from storage. |
||||||
|
*/ |
||||||
|
public function destroy($id) |
||||||
|
{ |
||||||
|
// |
||||||
|
|
||||||
|
return response()->json([]); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,7 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $CLASS_NAMESPACE$; |
||||||
|
|
||||||
|
use Illuminate\Routing\Controller; |
||||||
|
|
||||||
|
class $CLASS$ extends Controller {} |
@ -0,0 +1,17 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $CLASS_NAMESPACE$; |
||||||
|
|
||||||
|
use App\Http\Controllers\Controller; |
||||||
|
use Illuminate\Http\Request; |
||||||
|
|
||||||
|
class $CLASS$ extends Controller |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Handle the incoming request. |
||||||
|
*/ |
||||||
|
public function __invoke(Request $request) |
||||||
|
{ |
||||||
|
return response()->json([]); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,56 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $CLASS_NAMESPACE$; |
||||||
|
|
||||||
|
use App\Http\Controllers\Controller; |
||||||
|
use Illuminate\Http\Request; |
||||||
|
|
||||||
|
class $CLASS$ extends Controller |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Display a listing of the resource. |
||||||
|
*/ |
||||||
|
public function index() |
||||||
|
{ |
||||||
|
return view('$LOWER_NAME$::index'); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Show the form for creating a new resource. |
||||||
|
*/ |
||||||
|
public function create() |
||||||
|
{ |
||||||
|
return view('$LOWER_NAME$::create'); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Store a newly created resource in storage. |
||||||
|
*/ |
||||||
|
public function store(Request $request) {} |
||||||
|
|
||||||
|
/** |
||||||
|
* Show the specified resource. |
||||||
|
*/ |
||||||
|
public function show($id) |
||||||
|
{ |
||||||
|
return view('$LOWER_NAME$::show'); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Show the form for editing the specified resource. |
||||||
|
*/ |
||||||
|
public function edit($id) |
||||||
|
{ |
||||||
|
return view('$LOWER_NAME$::edit'); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Update the specified resource in storage. |
||||||
|
*/ |
||||||
|
public function update(Request $request, $id) {} |
||||||
|
|
||||||
|
/** |
||||||
|
* Remove the specified resource from storage. |
||||||
|
*/ |
||||||
|
public function destroy($id) {} |
||||||
|
} |
@ -0,0 +1,5 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $CLASS_NAMESPACE$; |
||||||
|
|
||||||
|
enum $CLASS$ {} |
@ -0,0 +1,27 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; |
||||||
|
|
||||||
|
class $CLASS$ 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 {} |
||||||
|
} |
@ -0,0 +1,31 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
use Illuminate\Broadcasting\Channel; |
||||||
|
use Illuminate\Broadcasting\InteractsWithSockets; |
||||||
|
use Illuminate\Broadcasting\PresenceChannel; |
||||||
|
use Illuminate\Broadcasting\PrivateChannel; |
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast; |
||||||
|
use Illuminate\Foundation\Events\Dispatchable; |
||||||
|
use Illuminate\Queue\SerializesModels; |
||||||
|
|
||||||
|
class $CLASS$ |
||||||
|
{ |
||||||
|
use Dispatchable, InteractsWithSockets, SerializesModels; |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a new event instance. |
||||||
|
*/ |
||||||
|
public function __construct() {} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the channels the event should be broadcast on. |
||||||
|
*/ |
||||||
|
public function broadcastOn(): array |
||||||
|
{ |
||||||
|
return [ |
||||||
|
new PrivateChannel('channel-name'), |
||||||
|
]; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,20 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $CLASS_NAMESPACE$; |
||||||
|
|
||||||
|
use Exception; |
||||||
|
use Illuminate\Http\Request; |
||||||
|
use Illuminate\Http\Response; |
||||||
|
|
||||||
|
class $CLASS$ extends Exception |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Report the exception. |
||||||
|
*/ |
||||||
|
public function report(): void {} |
||||||
|
|
||||||
|
/** |
||||||
|
* Render the exception as an HTTP response. |
||||||
|
*/ |
||||||
|
public function render(Request $request): Response {} |
||||||
|
} |
@ -0,0 +1,15 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $CLASS_NAMESPACE$; |
||||||
|
|
||||||
|
use Exception; |
||||||
|
use Illuminate\Http\Request; |
||||||
|
use Illuminate\Http\Response; |
||||||
|
|
||||||
|
class $CLASS$ extends Exception |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Render the exception as an HTTP response. |
||||||
|
*/ |
||||||
|
public function render(Request $request): Response {} |
||||||
|
} |
@ -0,0 +1,13 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $CLASS_NAMESPACE$; |
||||||
|
|
||||||
|
use Exception; |
||||||
|
|
||||||
|
class $CLASS$ extends Exception |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Report the exception. |
||||||
|
*/ |
||||||
|
public function report(): void {} |
||||||
|
} |
@ -0,0 +1,7 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $CLASS_NAMESPACE$; |
||||||
|
|
||||||
|
use Exception; |
||||||
|
|
||||||
|
class $CLASS$ extends Exception {} |
@ -0,0 +1,22 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory; |
||||||
|
|
||||||
|
class $NAME$Factory extends Factory |
||||||
|
{ |
||||||
|
/** |
||||||
|
* The name of the factory's corresponding model. |
||||||
|
*/ |
||||||
|
protected $model = \$MODEL_NAMESPACE$\$NAME$::class; |
||||||
|
|
||||||
|
/** |
||||||
|
* Define the model's default state. |
||||||
|
*/ |
||||||
|
public function definition(): array |
||||||
|
{ |
||||||
|
return []; |
||||||
|
} |
||||||
|
} |
||||||
|
|
@ -0,0 +1,8 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $CLASS_NAMESPACE$; |
||||||
|
|
||||||
|
class $CLASS$ |
||||||
|
{ |
||||||
|
public function __invoke() {} |
||||||
|
} |
@ -0,0 +1,8 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $CLASS_NAMESPACE$; |
||||||
|
|
||||||
|
class $CLASS$ |
||||||
|
{ |
||||||
|
public function handle() {} |
||||||
|
} |
@ -0,0 +1,5 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $CLASS_NAMESPACE$; |
||||||
|
|
||||||
|
interface $CLASS$ {} |
@ -0,0 +1,24 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable; |
||||||
|
use Illuminate\Queue\SerializesModels; |
||||||
|
use Illuminate\Queue\InteractsWithQueue; |
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue; |
||||||
|
use Illuminate\Foundation\Bus\Dispatchable; |
||||||
|
|
||||||
|
class $CLASS$ implements ShouldQueue |
||||||
|
{ |
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a new job instance. |
||||||
|
*/ |
||||||
|
public function __construct() {} |
||||||
|
|
||||||
|
/** |
||||||
|
* Execute the job. |
||||||
|
*/ |
||||||
|
public function handle(): void {} |
||||||
|
} |
@ -0,0 +1,21 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable; |
||||||
|
use Illuminate\Foundation\Bus\Dispatchable; |
||||||
|
|
||||||
|
class $CLASS$ implements ShouldQueue |
||||||
|
{ |
||||||
|
use Dispatchable, Queueable; |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a new job instance. |
||||||
|
*/ |
||||||
|
public function __construct() {} |
||||||
|
|
||||||
|
/** |
||||||
|
* Execute the job. |
||||||
|
*/ |
||||||
|
public function handle(): void {} |
||||||
|
} |
@ -0,0 +1,11 @@ |
|||||||
|
{ |
||||||
|
"name": "$STUDLY_NAME$", |
||||||
|
"alias": "$LOWER_NAME$", |
||||||
|
"description": "", |
||||||
|
"keywords": [], |
||||||
|
"priority": 0, |
||||||
|
"providers": [ |
||||||
|
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\$PROVIDER_NAMESPACE$\\$STUDLY_NAME$ServiceProvider" |
||||||
|
], |
||||||
|
"files": [] |
||||||
|
} |
@ -0,0 +1,19 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
use Illuminate\Queue\InteractsWithQueue; |
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue; |
||||||
|
|
||||||
|
class $CLASS$ |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Create the event listener. |
||||||
|
*/ |
||||||
|
public function __construct() {} |
||||||
|
|
||||||
|
/** |
||||||
|
* Handle the event. |
||||||
|
*/ |
||||||
|
public function handle($event): void {} |
||||||
|
} |
@ -0,0 +1,21 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
use Illuminate\Queue\InteractsWithQueue; |
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue; |
||||||
|
|
||||||
|
class $CLASS$ implements ShouldQueue |
||||||
|
{ |
||||||
|
use InteractsWithQueue; |
||||||
|
|
||||||
|
/** |
||||||
|
* Create the event listener |
||||||
|
*/ |
||||||
|
public function __construct() {} |
||||||
|
|
||||||
|
/** |
||||||
|
* Handle the event. |
||||||
|
*/ |
||||||
|
public function handle($event): void {} |
||||||
|
} |
@ -0,0 +1,22 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
use $EVENTNAME$; |
||||||
|
use Illuminate\Queue\InteractsWithQueue; |
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue; |
||||||
|
|
||||||
|
class $CLASS$ implements ShouldQueue |
||||||
|
{ |
||||||
|
use InteractsWithQueue; |
||||||
|
|
||||||
|
/** |
||||||
|
* Create the event listener. |
||||||
|
*/ |
||||||
|
public function __construct() {} |
||||||
|
|
||||||
|
/** |
||||||
|
* Handle the event. |
||||||
|
*/ |
||||||
|
public function handle($SHORTEVENTNAME$ $event): void {} |
||||||
|
} |
@ -0,0 +1,20 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
use $EVENTNAME$; |
||||||
|
use Illuminate\Queue\InteractsWithQueue; |
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue; |
||||||
|
|
||||||
|
class $CLASS$ |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Create the event listener. |
||||||
|
*/ |
||||||
|
public function __construct() {} |
||||||
|
|
||||||
|
/** |
||||||
|
* Handle the event. |
||||||
|
*/ |
||||||
|
public function handle($SHORTEVENTNAME$ $event): void {} |
||||||
|
} |
@ -0,0 +1,26 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable; |
||||||
|
use Illuminate\Mail\Mailable; |
||||||
|
use Illuminate\Queue\SerializesModels; |
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue; |
||||||
|
|
||||||
|
class $CLASS$ extends Mailable |
||||||
|
{ |
||||||
|
use Queueable, SerializesModels; |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a new message instance. |
||||||
|
*/ |
||||||
|
public function __construct() {} |
||||||
|
|
||||||
|
/** |
||||||
|
* Build the message. |
||||||
|
*/ |
||||||
|
public function build(): self |
||||||
|
{ |
||||||
|
return $this->view('view.name'); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,17 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
use Closure; |
||||||
|
use Illuminate\Http\Request; |
||||||
|
|
||||||
|
class $CLASS$ |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Handle an incoming request. |
||||||
|
*/ |
||||||
|
public function handle(Request $request, Closure $next) |
||||||
|
{ |
||||||
|
return $next($request); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,28 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration; |
||||||
|
use Illuminate\Database\Schema\Blueprint; |
||||||
|
use Illuminate\Support\Facades\Schema; |
||||||
|
|
||||||
|
return new class extends Migration |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Run the migrations. |
||||||
|
*/ |
||||||
|
public function up(): void |
||||||
|
{ |
||||||
|
Schema::table('$TABLE$', function (Blueprint $table) { |
||||||
|
$FIELDS_UP$ |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Reverse the migrations. |
||||||
|
*/ |
||||||
|
public function down(): void |
||||||
|
{ |
||||||
|
Schema::table('$TABLE$', function (Blueprint $table) { |
||||||
|
$FIELDS_DOWN$ |
||||||
|
}); |
||||||
|
} |
||||||
|
}; |
@ -0,0 +1,28 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration; |
||||||
|
use Illuminate\Database\Schema\Blueprint; |
||||||
|
use Illuminate\Support\Facades\Schema; |
||||||
|
|
||||||
|
return new class extends Migration |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Run the migrations. |
||||||
|
*/ |
||||||
|
public function up(): void |
||||||
|
{ |
||||||
|
Schema::create('$TABLE$', function (Blueprint $table) { |
||||||
|
$table->id(); |
||||||
|
$FIELDS$ |
||||||
|
$table->timestamps(); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Reverse the migrations. |
||||||
|
*/ |
||||||
|
public function down(): void |
||||||
|
{ |
||||||
|
Schema::dropIfExists('$TABLE$'); |
||||||
|
} |
||||||
|
}; |
@ -0,0 +1,28 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration; |
||||||
|
use Illuminate\Database\Schema\Blueprint; |
||||||
|
use Illuminate\Support\Facades\Schema; |
||||||
|
|
||||||
|
return new class extends Migration |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Run the migrations. |
||||||
|
*/ |
||||||
|
public function up(): void |
||||||
|
{ |
||||||
|
Schema::table('$TABLE$', function (Blueprint $table) { |
||||||
|
$FIELDS_UP$ |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Reverse the migrations. |
||||||
|
*/ |
||||||
|
public function down(): void |
||||||
|
{ |
||||||
|
Schema::table('$TABLE$', function (Blueprint $table) { |
||||||
|
$FIELDS_DOWN$ |
||||||
|
}); |
||||||
|
} |
||||||
|
}; |
@ -0,0 +1,28 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration; |
||||||
|
use Illuminate\Database\Schema\Blueprint; |
||||||
|
use Illuminate\Support\Facades\Schema; |
||||||
|
|
||||||
|
return new class extends Migration |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Run the migrations. |
||||||
|
*/ |
||||||
|
public function up(): void |
||||||
|
{ |
||||||
|
Schema::dropIfExists('$TABLE$'); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Reverse the migrations. |
||||||
|
*/ |
||||||
|
public function down(): void |
||||||
|
{ |
||||||
|
Schema::create('$TABLE$', function (Blueprint $table) { |
||||||
|
$table->id(); |
||||||
|
$FIELDS$ |
||||||
|
$table->timestamps(); |
||||||
|
}); |
||||||
|
} |
||||||
|
}; |
@ -0,0 +1,18 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration; |
||||||
|
use Illuminate\Database\Schema\Blueprint; |
||||||
|
use Illuminate\Support\Facades\Schema; |
||||||
|
|
||||||
|
return new class extends Migration |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Run the migrations. |
||||||
|
*/ |
||||||
|
public function up(): void {} |
||||||
|
|
||||||
|
/** |
||||||
|
* Reverse the migrations. |
||||||
|
*/ |
||||||
|
public function down(): void {} |
||||||
|
}; |
@ -0,0 +1,22 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory; |
||||||
|
// use $MODULE_NAMESPACE$\$MODULE$\Database\Factories\$NAME$Factory; |
||||||
|
|
||||||
|
class $CLASS$ extends Model |
||||||
|
{ |
||||||
|
use HasFactory; |
||||||
|
|
||||||
|
/** |
||||||
|
* The attributes that are mass assignable. |
||||||
|
*/ |
||||||
|
protected $fillable = $FILLABLE$; |
||||||
|
|
||||||
|
// protected static function newFactory(): $NAME$Factory |
||||||
|
// { |
||||||
|
// // return $NAME$Factory::new(); |
||||||
|
// } |
||||||
|
} |
@ -0,0 +1,45 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable; |
||||||
|
use Illuminate\Notifications\Notification; |
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue; |
||||||
|
use Illuminate\Notifications\Messages\MailMessage; |
||||||
|
|
||||||
|
class $CLASS$ extends Notification |
||||||
|
{ |
||||||
|
use Queueable; |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a new notification instance. |
||||||
|
*/ |
||||||
|
public function __construct() {} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the notification's delivery channels. |
||||||
|
*/ |
||||||
|
public function via($notifiable): array |
||||||
|
{ |
||||||
|
return ['mail']; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the mail representation of the notification. |
||||||
|
*/ |
||||||
|
public function toMail($notifiable): MailMessage |
||||||
|
{ |
||||||
|
return (new MailMessage) |
||||||
|
->line('The introduction to the notification.') |
||||||
|
->action('Notification Action', 'https://laravel.com') |
||||||
|
->line('Thank you for using our application!'); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the array representation of the notification. |
||||||
|
*/ |
||||||
|
public function toArray($notifiable): array |
||||||
|
{ |
||||||
|
return []; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,33 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
use $MODEL_NAMESPACE$\$NAME$; |
||||||
|
|
||||||
|
class $NAME$Observer |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Handle the $NAME$ "created" event. |
||||||
|
*/ |
||||||
|
public function created($NAME$ $NAME_VARIABLE$): void {} |
||||||
|
|
||||||
|
/** |
||||||
|
* Handle the $NAME$ "updated" event. |
||||||
|
*/ |
||||||
|
public function updated($NAME$ $NAME_VARIABLE$): void {} |
||||||
|
|
||||||
|
/** |
||||||
|
* Handle the $NAME$ "deleted" event. |
||||||
|
*/ |
||||||
|
public function deleted($NAME$ $NAME_VARIABLE$): void {} |
||||||
|
|
||||||
|
/** |
||||||
|
* Handle the $NAME$ "restored" event. |
||||||
|
*/ |
||||||
|
public function restored($NAME$ $NAME_VARIABLE$): void {} |
||||||
|
|
||||||
|
/** |
||||||
|
* Handle the $NAME$ "force deleted" event. |
||||||
|
*/ |
||||||
|
public function forceDeleted($NAME$ $NAME_VARIABLE$): void {} |
||||||
|
} |
@ -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" |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,15 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
use Illuminate\Auth\Access\HandlesAuthorization; |
||||||
|
|
||||||
|
class $CLASS$ |
||||||
|
{ |
||||||
|
use HandlesAuthorization; |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a new policy instance. |
||||||
|
*/ |
||||||
|
public function __construct() {} |
||||||
|
} |
@ -0,0 +1,21 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
use Illuminate\Support\ServiceProvider; |
||||||
|
|
||||||
|
class $CLASS$ extends ServiceProvider |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Register the service provider. |
||||||
|
*/ |
||||||
|
public function register(): void {} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the services provided by the provider. |
||||||
|
*/ |
||||||
|
public function provides(): array |
||||||
|
{ |
||||||
|
return []; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,8 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $CLASS_NAMESPACE$; |
||||||
|
|
||||||
|
class $CLASS$ |
||||||
|
{ |
||||||
|
public function __invoke() {} |
||||||
|
} |
@ -0,0 +1,8 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $CLASS_NAMESPACE$; |
||||||
|
|
||||||
|
class $CLASS$ |
||||||
|
{ |
||||||
|
public function handle() {} |
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest; |
||||||
|
|
||||||
|
class $CLASS$ extends FormRequest |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Get the validation rules that apply to the request. |
||||||
|
*/ |
||||||
|
public function rules(): array |
||||||
|
{ |
||||||
|
return []; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Determine if the user is authorized to make this request. |
||||||
|
*/ |
||||||
|
public function authorize(): bool |
||||||
|
{ |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,17 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
use Illuminate\Http\Request; |
||||||
|
use Illuminate\Http\Resources\Json\ResourceCollection; |
||||||
|
|
||||||
|
class $CLASS$ extends ResourceCollection |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Transform the resource collection into an array. |
||||||
|
*/ |
||||||
|
public function toArray(Request $request): array |
||||||
|
{ |
||||||
|
return parent::toArray($request); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,17 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
use Illuminate\Http\Request; |
||||||
|
use Illuminate\Http\Resources\Json\JsonResource; |
||||||
|
|
||||||
|
class $CLASS$ extends JsonResource |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Transform the resource into an array. |
||||||
|
*/ |
||||||
|
public function toArray(Request $request): array |
||||||
|
{ |
||||||
|
return parent::toArray($request); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,50 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; |
||||||
|
use Illuminate\Support\Facades\Route; |
||||||
|
|
||||||
|
class $CLASS$ extends ServiceProvider |
||||||
|
{ |
||||||
|
protected string $name = '$MODULE$'; |
||||||
|
|
||||||
|
/** |
||||||
|
* 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(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 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, '$WEB_ROUTES_PATH$')); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 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, '$API_ROUTES_PATH$')); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,8 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Route; |
||||||
|
use $MODULE_NAMESPACE$\$STUDLY_NAME$\$CONTROLLER_NAMESPACE$\$STUDLY_NAME$Controller; |
||||||
|
|
||||||
|
Route::middleware(['auth:sanctum'])->prefix('v1')->group(function () { |
||||||
|
Route::apiResource('$PLURAL_LOWER_NAME$', $STUDLY_NAME$Controller::class)->names('$LOWER_NAME$'); |
||||||
|
}); |
@ -0,0 +1,8 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Route; |
||||||
|
use $MODULE_NAMESPACE$\$STUDLY_NAME$\$CONTROLLER_NAMESPACE$\$STUDLY_NAME$Controller; |
||||||
|
|
||||||
|
Route::middleware(['auth', 'verified'])->group(function () { |
||||||
|
Route::resource('$PLURAL_LOWER_NAME$', $STUDLY_NAME$Controller::class)->names('$LOWER_NAME$'); |
||||||
|
}); |
@ -0,0 +1,19 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
use Closure; |
||||||
|
use Illuminate\Contracts\Validation\ValidationRule; |
||||||
|
|
||||||
|
class $CLASS$ implements ValidationRule |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Indicates whether the rule should be implicit. |
||||||
|
*/ |
||||||
|
public bool $implicit = true; |
||||||
|
|
||||||
|
/** |
||||||
|
* Run the validation rule. |
||||||
|
*/ |
||||||
|
public function validate(string $attribute, mixed $value, Closure $fail): void {} |
||||||
|
} |
@ -0,0 +1,14 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
use Closure; |
||||||
|
use Illuminate\Contracts\Validation\ValidationRule; |
||||||
|
|
||||||
|
class $CLASS$ implements ValidationRule |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Run the validation rule. |
||||||
|
*/ |
||||||
|
public function validate(string $attribute, mixed $value, Closure $fail): void {} |
||||||
|
} |
@ -0,0 +1,5 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
return [ |
||||||
|
'name' => '$STUDLY_NAME$', |
||||||
|
]; |
@ -0,0 +1,154 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Blade; |
||||||
|
use Illuminate\Support\ServiceProvider; |
||||||
|
use Nwidart\Modules\Traits\PathNamespace; |
||||||
|
use RecursiveDirectoryIterator; |
||||||
|
use RecursiveIteratorIterator; |
||||||
|
|
||||||
|
class $CLASS$ extends ServiceProvider |
||||||
|
{ |
||||||
|
use PathNamespace; |
||||||
|
|
||||||
|
protected string $name = '$MODULE$'; |
||||||
|
|
||||||
|
protected string $nameLower = '$LOWER_NAME$'; |
||||||
|
|
||||||
|
/** |
||||||
|
* Boot the application events. |
||||||
|
*/ |
||||||
|
public function boot(): void |
||||||
|
{ |
||||||
|
$this->registerCommands(); |
||||||
|
$this->registerCommandSchedules(); |
||||||
|
$this->registerTranslations(); |
||||||
|
$this->registerConfig(); |
||||||
|
$this->registerViews(); |
||||||
|
$this->loadMigrationsFrom(module_path($this->name, '$MIGRATIONS_PATH$')); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 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, '$PATH_LANG$'), $this->nameLower); |
||||||
|
$this->loadJsonTranslationsFrom(module_path($this->name, '$PATH_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, '$PATH_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; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,15 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $CLASS_NAMESPACE$; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder; |
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
use Illuminate\Database\Eloquent\Scope; |
||||||
|
|
||||||
|
class $CLASS$ implements Scope |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Apply the scope to a given Eloquent query builder. |
||||||
|
*/ |
||||||
|
public function apply(Builder $builder, Model $model): void {} |
||||||
|
} |
@ -0,0 +1,16 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
use Illuminate\Database\Seeder; |
||||||
|
|
||||||
|
class $NAME$ extends Seeder |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Run the database seeds. |
||||||
|
*/ |
||||||
|
public function run(): void |
||||||
|
{ |
||||||
|
// $this->call([]); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,8 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $CLASS_NAMESPACE$; |
||||||
|
|
||||||
|
class $CLASS$ |
||||||
|
{ |
||||||
|
public function __invoke() {} |
||||||
|
} |
@ -0,0 +1,8 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $CLASS_NAMESPACE$; |
||||||
|
|
||||||
|
class $CLASS$ |
||||||
|
{ |
||||||
|
public function handle() {} |
||||||
|
} |
@ -0,0 +1,18 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
use Tests\TestCase; |
||||||
|
|
||||||
|
class $CLASS$ extends TestCase |
||||||
|
{ |
||||||
|
/** |
||||||
|
* A basic test example. |
||||||
|
*/ |
||||||
|
public function test_the_application_returns_a_successful_response(): void |
||||||
|
{ |
||||||
|
$response = $this->get('/'); |
||||||
|
|
||||||
|
$response->assertStatus(200); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,16 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $NAMESPACE$; |
||||||
|
|
||||||
|
use Tests\TestCase; |
||||||
|
|
||||||
|
class $CLASS$ extends TestCase |
||||||
|
{ |
||||||
|
/** |
||||||
|
* A basic test example. |
||||||
|
*/ |
||||||
|
public function test_that_true_is_true(): void |
||||||
|
{ |
||||||
|
$this->assertTrue(true); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,5 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace $CLASS_NAMESPACE$; |
||||||
|
|
||||||
|
trait $CLASS$ {} |
@ -0,0 +1,3 @@ |
|||||||
|
<div> |
||||||
|
<!-- $QUOTE$ --> |
||||||
|
</div> |
@ -0,0 +1,5 @@ |
|||||||
|
<x-$LOWER_NAME$::layouts.master> |
||||||
|
<h1>Hello World</h1> |
||||||
|
|
||||||
|
<p>Module: {!! config('$LOWER_NAME$.name') !!}</p> |
||||||
|
</x-$LOWER_NAME$::layouts.master> |
@ -0,0 +1,29 @@ |
|||||||
|
<!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>$STUDLY_NAME$ 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-$LOWER_NAME$', 'resources/assets/sass/app.scss') }} --}} |
||||||
|
</head> |
||||||
|
|
||||||
|
<body> |
||||||
|
{{ $slot }} |
||||||
|
|
||||||
|
{{-- Vite JS --}} |
||||||
|
{{-- {{ module_vite('build-$LOWER_NAME$', 'resources/assets/js/app.js') }} --}} |
||||||
|
</body> |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue