DONE: first init

This commit is contained in:
2026-10-26 10:03:02 +08:00
parent a2ee286c1a
commit 8a7907a87c
32 changed files with 553 additions and 51 deletions
@@ -0,0 +1,56 @@
<?php
namespace Modules\Auth\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class AuthController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
return view('auth::index');
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
return view('auth::create');
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request) {}
/**
* Show the specified resource.
*/
public function show($id)
{
return view('auth::show');
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
return view('auth::edit');
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id) {}
/**
* Remove the specified resource from storage.
*/
public function destroy($id) {}
}
View File
@@ -0,0 +1,46 @@
<?php
namespace Modules\Auth\Providers;
use Nwidart\Modules\Support\ModuleServiceProvider;
use Illuminate\Console\Scheduling\Schedule;
class AuthServiceProvider extends ModuleServiceProvider
{
/**
* The name of the module.
*/
protected string $name = 'Auth';
/**
* The lowercase version of the module name.
*/
protected string $nameLower = 'auth';
/**
* Command classes to register.
*
* @var string[]
*/
// protected array $commands = [];
/**
* Provider classes to register.
*
* @var string[]
*/
protected array $providers = [
EventServiceProvider::class,
RouteServiceProvider::class,
];
/**
* Define module schedules.
*
* @param $schedule
*/
// protected function configureSchedules(Schedule $schedule): void
// {
// $schedule->command('inspire')->hourly();
// }
}
@@ -0,0 +1,27 @@
<?php
namespace Modules\Auth\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\Auth\Providers;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider
{
protected string $name = 'Auth';
/**
* 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'));
}
}
+30
View File
@@ -0,0 +1,30 @@
{
"name": "nwidart/auth",
"description": "",
"authors": [
{
"name": "Nicolas Widart",
"email": "n.widart@gmail.com"
}
],
"extra": {
"laravel": {
"providers": [],
"aliases": {
}
}
},
"autoload": {
"psr-4": {
"Modules\\Auth\\": "app/",
"Modules\\Auth\\Database\\Factories\\": "database/factories/",
"Modules\\Auth\\Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Modules\\Auth\\Tests\\": "tests/"
}
}
}
View File
+5
View File
@@ -0,0 +1,5 @@
<?php
return [
'name' => 'Auth',
];
@@ -0,0 +1,16 @@
<?php
namespace Modules\Auth\Database\Seeders;
use Illuminate\Database\Seeder;
class AuthDatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
// $this->call([]);
}
}
+11
View File
@@ -0,0 +1,11 @@
{
"name": "Auth",
"alias": "auth",
"description": "",
"keywords": [],
"priority": 0,
"providers": [
"Modules\\Auth\\Providers\\AuthServiceProvider"
],
"files": []
}
+15
View File
@@ -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,30 @@
<!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>Auth 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-auth', 'resources/assets/sass/app.scss') }} --}}
</head>
<body>
{{ $slot }}
{{-- Vite JS --}}
{{-- {{ module_vite('build-auth', 'resources/assets/js/app.js') }} --}}
</body>
</html>
@@ -0,0 +1,5 @@
<x-auth::layouts.master>
<h1>Hello World</h1>
<p>Module: {!! config('auth.name') !!}</p>
</x-auth::layouts.master>
View File
+8
View File
@@ -0,0 +1,8 @@
<?php
use Illuminate\Support\Facades\Route;
use Modules\Auth\Http\Controllers\AuthController;
Route::middleware(['auth:sanctum'])->prefix('v1')->group(function () {
Route::apiResource('auths', AuthController::class)->names('auth');
});
+8
View File
@@ -0,0 +1,8 @@
<?php
use Illuminate\Support\Facades\Route;
use Modules\Auth\Http\Controllers\AuthController;
Route::middleware(['auth', 'verified'])->group(function () {
Route::resource('auths', AuthController::class)->names('auth');
});
View File
View File
+41
View File
@@ -0,0 +1,41 @@
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
// Uncomment the import for your frontend framework:
// import vue from '@vitejs/plugin-vue';
// import react from '@vitejs/plugin-react';
// import { svelte } from '@sveltejs/vite-plugin-svelte';
export default defineConfig({
build: {
outDir: '../../public/build-auth',
emptyOutDir: true,
manifest: true,
},
plugins: [
laravel({
publicDirectory: '../../public',
buildDirectory: 'build-auth',
input: [
__dirname + '/resources/assets/sass/app.scss',
__dirname + '/resources/assets/js/app.js'
],
refresh: true,
}),
// Uncomment the plugin for your frontend framework:
// vue({
// template: {
// transformAssetUrls: {
// base: null,
// includeAbsolute: false,
// },
// },
// }),
// react(),
// svelte(),
],
resolve: {
alias: {
'@': __dirname + '/resources/js',
},
},
});