Initial commit with contrats and domaines modules
This commit is contained in:
15
.claude/settings.local.json
Normal file
15
.claude/settings.local.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"permissions": {
|
||||
"allow": [
|
||||
"Read(//c/laragon/www/**)",
|
||||
"Bash(composer create-project:*)",
|
||||
"Bash(cp -r C:/laragon/www/Commandes_tmp/. C:/laragon/www/Commandes/)",
|
||||
"Bash(rm -rf C:/laragon/www/Commandes_tmp)",
|
||||
"Bash(composer require:*)",
|
||||
"Bash(php artisan:*)",
|
||||
"Bash(mysql -u root -e \"CREATE DATABASE IF NOT EXISTS commandes_dsi CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;\")",
|
||||
"Bash(/c/laragon/bin/mysql/mysql-8.4.3-winx64/bin/mysql.exe -u root -e \"CREATE DATABASE IF NOT EXISTS commandes_dsi CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;\")",
|
||||
"Bash(npm run:*)"
|
||||
]
|
||||
}
|
||||
}
|
||||
18
.editorconfig
Normal file
18
.editorconfig
Normal file
@@ -0,0 +1,18 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.{yml,yaml}]
|
||||
indent_size = 2
|
||||
|
||||
[compose.yaml]
|
||||
indent_size = 4
|
||||
65
.env.example
Normal file
65
.env.example
Normal file
@@ -0,0 +1,65 @@
|
||||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
|
||||
APP_LOCALE=en
|
||||
APP_FALLBACK_LOCALE=en
|
||||
APP_FAKER_LOCALE=en_US
|
||||
|
||||
APP_MAINTENANCE_DRIVER=file
|
||||
# APP_MAINTENANCE_STORE=database
|
||||
|
||||
# PHP_CLI_SERVER_WORKERS=4
|
||||
|
||||
BCRYPT_ROUNDS=12
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_STACK=single
|
||||
LOG_DEPRECATIONS_CHANNEL=null
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=sqlite
|
||||
# DB_HOST=127.0.0.1
|
||||
# DB_PORT=3306
|
||||
# DB_DATABASE=laravel
|
||||
# DB_USERNAME=root
|
||||
# DB_PASSWORD=
|
||||
|
||||
SESSION_DRIVER=database
|
||||
SESSION_LIFETIME=120
|
||||
SESSION_ENCRYPT=false
|
||||
SESSION_PATH=/
|
||||
SESSION_DOMAIN=null
|
||||
|
||||
BROADCAST_CONNECTION=log
|
||||
FILESYSTEM_DISK=local
|
||||
QUEUE_CONNECTION=database
|
||||
|
||||
CACHE_STORE=database
|
||||
# CACHE_PREFIX=
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
REDIS_CLIENT=phpredis
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=log
|
||||
MAIL_SCHEME=null
|
||||
MAIL_HOST=127.0.0.1
|
||||
MAIL_PORT=2525
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_FROM_ADDRESS="hello@example.com"
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
VITE_APP_NAME="${APP_NAME}"
|
||||
11
.gitattributes
vendored
Normal file
11
.gitattributes
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
* text=auto eol=lf
|
||||
|
||||
*.blade.php diff=html
|
||||
*.css diff=css
|
||||
*.html diff=html
|
||||
*.md diff=markdown
|
||||
*.php diff=php
|
||||
|
||||
/.github export-ignore
|
||||
CHANGELOG.md export-ignore
|
||||
.styleci.yml export-ignore
|
||||
25
.gitignore
vendored
Normal file
25
.gitignore
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
*.log
|
||||
.DS_Store
|
||||
.env
|
||||
.env.backup
|
||||
.env.production
|
||||
.phpactor.json
|
||||
.phpunit.result.cache
|
||||
/.fleet
|
||||
/.idea
|
||||
/.nova
|
||||
/.phpunit.cache
|
||||
/.vscode
|
||||
/.zed
|
||||
/auth.json
|
||||
/node_modules
|
||||
/public/build
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/storage/pail
|
||||
/vendor
|
||||
_ide_helper.php
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
Thumbs.db
|
||||
58
README.md
Normal file
58
README.md
Normal file
@@ -0,0 +1,58 @@
|
||||
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
|
||||
</p>
|
||||
|
||||
## About Laravel
|
||||
|
||||
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
|
||||
|
||||
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
||||
- [Powerful dependency injection container](https://laravel.com/docs/container).
|
||||
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
|
||||
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
|
||||
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
|
||||
- [Robust background job processing](https://laravel.com/docs/queues).
|
||||
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
||||
|
||||
Laravel is accessible, powerful, and provides tools required for large, robust applications.
|
||||
|
||||
## Learning Laravel
|
||||
|
||||
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
|
||||
|
||||
In addition, [Laracasts](https://laracasts.com) contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
|
||||
|
||||
You can also watch bite-sized lessons with real-world projects on [Laravel Learn](https://laravel.com/learn), where you will be guided through building a Laravel application from scratch while learning PHP fundamentals.
|
||||
|
||||
## Agentic Development
|
||||
|
||||
Laravel's predictable structure and conventions make it ideal for AI coding agents like Claude Code, Cursor, and GitHub Copilot. Install [Laravel Boost](https://laravel.com/docs/ai) to supercharge your AI workflow:
|
||||
|
||||
```bash
|
||||
composer require laravel/boost --dev
|
||||
|
||||
php artisan boost:install
|
||||
```
|
||||
|
||||
Boost provides your agent 15+ tools and skills that help agents build Laravel applications while following best practices.
|
||||
|
||||
## Contributing
|
||||
|
||||
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
|
||||
|
||||
## Security Vulnerabilities
|
||||
|
||||
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
|
||||
|
||||
## License
|
||||
|
||||
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
||||
94
app/Http/Controllers/ArticleController.php
Normal file
94
app/Http/Controllers/ArticleController.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Article;
|
||||
use App\Models\Categorie;
|
||||
use App\Models\Fournisseur;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class ArticleController extends Controller
|
||||
{
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$articles = Article::with(['categorie', 'fournisseur'])
|
||||
->when($request->search, fn ($q) => $q->where(function ($sub) use ($request) {
|
||||
$sub->where('designation', 'like', "%{$request->search}%")
|
||||
->orWhere('reference', 'like', "%{$request->search}%");
|
||||
}))
|
||||
->when($request->categorie_id, fn ($q) => $q->where('categorie_id', $request->categorie_id))
|
||||
->orderBy('designation')
|
||||
->paginate(20)
|
||||
->withQueryString();
|
||||
|
||||
return Inertia::render('Articles/Index', [
|
||||
'articles' => $articles,
|
||||
'categories' => Categorie::active()->orderBy('ordre')->get(),
|
||||
'filters' => $request->only(['search', 'categorie_id']),
|
||||
]);
|
||||
}
|
||||
|
||||
public function create(): Response
|
||||
{
|
||||
return Inertia::render('Articles/Create', [
|
||||
'categories' => Categorie::active()->orderBy('ordre')->get(),
|
||||
'fournisseurs' => Fournisseur::active()->orderBy('nom')->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'reference' => 'nullable|string|max:100',
|
||||
'designation' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'categorie_id' => 'nullable|exists:categories,id',
|
||||
'fournisseur_id' => 'nullable|exists:fournisseurs,id',
|
||||
'prix_unitaire_ht' => 'nullable|numeric|min:0',
|
||||
'unite' => 'nullable|string|max:30',
|
||||
]);
|
||||
|
||||
Article::create($validated);
|
||||
|
||||
return redirect()->route('articles.index')
|
||||
->with('success', 'Article créé avec succès.');
|
||||
}
|
||||
|
||||
public function edit(Article $article): Response
|
||||
{
|
||||
return Inertia::render('Articles/Edit', [
|
||||
'article' => $article,
|
||||
'categories' => Categorie::active()->orderBy('ordre')->get(),
|
||||
'fournisseurs' => Fournisseur::active()->orderBy('nom')->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request, Article $article): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'reference' => 'nullable|string|max:100',
|
||||
'designation' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'categorie_id' => 'nullable|exists:categories,id',
|
||||
'fournisseur_id' => 'nullable|exists:fournisseurs,id',
|
||||
'prix_unitaire_ht' => 'nullable|numeric|min:0',
|
||||
'unite' => 'nullable|string|max:30',
|
||||
'active' => 'boolean',
|
||||
]);
|
||||
|
||||
$article->update($validated);
|
||||
|
||||
return redirect()->route('articles.index')
|
||||
->with('success', 'Article mis à jour.');
|
||||
}
|
||||
|
||||
public function destroy(Article $article): RedirectResponse
|
||||
{
|
||||
$article->update(['active' => false]);
|
||||
|
||||
return back()->with('success', 'Article désactivé.');
|
||||
}
|
||||
}
|
||||
52
app/Http/Controllers/Auth/AuthenticatedSessionController.php
Normal file
52
app/Http/Controllers/Auth/AuthenticatedSessionController.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Auth\LoginRequest;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class AuthenticatedSessionController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the login view.
|
||||
*/
|
||||
public function create(): Response
|
||||
{
|
||||
return Inertia::render('Auth/Login', [
|
||||
'canResetPassword' => Route::has('password.request'),
|
||||
'status' => session('status'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming authentication request.
|
||||
*/
|
||||
public function store(LoginRequest $request): RedirectResponse
|
||||
{
|
||||
$request->authenticate();
|
||||
|
||||
$request->session()->regenerate();
|
||||
|
||||
return redirect()->intended(route('dashboard', absolute: false));
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy an authenticated session.
|
||||
*/
|
||||
public function destroy(Request $request): RedirectResponse
|
||||
{
|
||||
Auth::guard('web')->logout();
|
||||
|
||||
$request->session()->invalidate();
|
||||
|
||||
$request->session()->regenerateToken();
|
||||
|
||||
return redirect('/');
|
||||
}
|
||||
}
|
||||
41
app/Http/Controllers/Auth/ConfirmablePasswordController.php
Normal file
41
app/Http/Controllers/Auth/ConfirmablePasswordController.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class ConfirmablePasswordController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show the confirm password view.
|
||||
*/
|
||||
public function show(): Response
|
||||
{
|
||||
return Inertia::render('Auth/ConfirmPassword');
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm the user's password.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
if (! Auth::guard('web')->validate([
|
||||
'email' => $request->user()->email,
|
||||
'password' => $request->password,
|
||||
])) {
|
||||
throw ValidationException::withMessages([
|
||||
'password' => __('auth.password'),
|
||||
]);
|
||||
}
|
||||
|
||||
$request->session()->put('auth.password_confirmed_at', time());
|
||||
|
||||
return redirect()->intended(route('dashboard', absolute: false));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class EmailVerificationNotificationController extends Controller
|
||||
{
|
||||
/**
|
||||
* Send a new email verification notification.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
if ($request->user()->hasVerifiedEmail()) {
|
||||
return redirect()->intended(route('dashboard', absolute: false));
|
||||
}
|
||||
|
||||
$request->user()->sendEmailVerificationNotification();
|
||||
|
||||
return back()->with('status', 'verification-link-sent');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class EmailVerificationPromptController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the email verification prompt.
|
||||
*/
|
||||
public function __invoke(Request $request): RedirectResponse|Response
|
||||
{
|
||||
return $request->user()->hasVerifiedEmail()
|
||||
? redirect()->intended(route('dashboard', absolute: false))
|
||||
: Inertia::render('Auth/VerifyEmail', ['status' => session('status')]);
|
||||
}
|
||||
}
|
||||
69
app/Http/Controllers/Auth/NewPasswordController.php
Normal file
69
app/Http/Controllers/Auth/NewPasswordController.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Auth\Events\PasswordReset;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\Rules;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class NewPasswordController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the password reset view.
|
||||
*/
|
||||
public function create(Request $request): Response
|
||||
{
|
||||
return Inertia::render('Auth/ResetPassword', [
|
||||
'email' => $request->email,
|
||||
'token' => $request->route('token'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming new password request.
|
||||
*
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$request->validate([
|
||||
'token' => 'required',
|
||||
'email' => 'required|email',
|
||||
'password' => ['required', 'confirmed', Rules\Password::defaults()],
|
||||
]);
|
||||
|
||||
// Here we will attempt to reset the user's password. If it is successful we
|
||||
// will update the password on an actual user model and persist it to the
|
||||
// database. Otherwise we will parse the error and return the response.
|
||||
$status = Password::reset(
|
||||
$request->only('email', 'password', 'password_confirmation', 'token'),
|
||||
function ($user) use ($request) {
|
||||
$user->forceFill([
|
||||
'password' => Hash::make($request->password),
|
||||
'remember_token' => Str::random(60),
|
||||
])->save();
|
||||
|
||||
event(new PasswordReset($user));
|
||||
}
|
||||
);
|
||||
|
||||
// If the password was successfully reset, we will redirect the user back to
|
||||
// the application's home authenticated view. If there is an error we can
|
||||
// redirect them back to where they came from with their error message.
|
||||
if ($status == Password::PASSWORD_RESET) {
|
||||
return redirect()->route('login')->with('status', __($status));
|
||||
}
|
||||
|
||||
throw ValidationException::withMessages([
|
||||
'email' => [trans($status)],
|
||||
]);
|
||||
}
|
||||
}
|
||||
29
app/Http/Controllers/Auth/PasswordController.php
Normal file
29
app/Http/Controllers/Auth/PasswordController.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
|
||||
class PasswordController extends Controller
|
||||
{
|
||||
/**
|
||||
* Update the user's password.
|
||||
*/
|
||||
public function update(Request $request): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'current_password' => ['required', 'current_password'],
|
||||
'password' => ['required', Password::defaults(), 'confirmed'],
|
||||
]);
|
||||
|
||||
$request->user()->update([
|
||||
'password' => Hash::make($validated['password']),
|
||||
]);
|
||||
|
||||
return back();
|
||||
}
|
||||
}
|
||||
51
app/Http/Controllers/Auth/PasswordResetLinkController.php
Normal file
51
app/Http/Controllers/Auth/PasswordResetLinkController.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class PasswordResetLinkController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the password reset link request view.
|
||||
*/
|
||||
public function create(): Response
|
||||
{
|
||||
return Inertia::render('Auth/ForgotPassword', [
|
||||
'status' => session('status'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming password reset link request.
|
||||
*
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$request->validate([
|
||||
'email' => 'required|email',
|
||||
]);
|
||||
|
||||
// We will send the password reset link to this user. Once we have attempted
|
||||
// to send the link, we will examine the response then see the message we
|
||||
// need to show to the user. Finally, we'll send out a proper response.
|
||||
$status = Password::sendResetLink(
|
||||
$request->only('email')
|
||||
);
|
||||
|
||||
if ($status == Password::RESET_LINK_SENT) {
|
||||
return back()->with('status', __($status));
|
||||
}
|
||||
|
||||
throw ValidationException::withMessages([
|
||||
'email' => [trans($status)],
|
||||
]);
|
||||
}
|
||||
}
|
||||
52
app/Http/Controllers/Auth/RegisteredUserController.php
Normal file
52
app/Http/Controllers/Auth/RegisteredUserController.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Validation\Rules;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class RegisteredUserController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the registration view.
|
||||
*/
|
||||
public function create(): Response
|
||||
{
|
||||
return Inertia::render('Auth/Register');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming registration request.
|
||||
*
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|string|lowercase|email|max:255|unique:'.User::class,
|
||||
'password' => ['required', 'confirmed', Rules\Password::defaults()],
|
||||
]);
|
||||
|
||||
$user = User::create([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'password' => Hash::make($request->password),
|
||||
]);
|
||||
|
||||
event(new Registered($user));
|
||||
|
||||
Auth::login($user);
|
||||
|
||||
return redirect(route('dashboard', absolute: false));
|
||||
}
|
||||
}
|
||||
27
app/Http/Controllers/Auth/VerifyEmailController.php
Normal file
27
app/Http/Controllers/Auth/VerifyEmailController.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Auth\Events\Verified;
|
||||
use Illuminate\Foundation\Auth\EmailVerificationRequest;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
||||
class VerifyEmailController extends Controller
|
||||
{
|
||||
/**
|
||||
* Mark the authenticated user's email address as verified.
|
||||
*/
|
||||
public function __invoke(EmailVerificationRequest $request): RedirectResponse
|
||||
{
|
||||
if ($request->user()->hasVerifiedEmail()) {
|
||||
return redirect()->intended(route('dashboard', absolute: false).'?verified=1');
|
||||
}
|
||||
|
||||
if ($request->user()->markEmailAsVerified()) {
|
||||
event(new Verified($request->user()));
|
||||
}
|
||||
|
||||
return redirect()->intended(route('dashboard', absolute: false).'?verified=1');
|
||||
}
|
||||
}
|
||||
63
app/Http/Controllers/CategorieController.php
Normal file
63
app/Http/Controllers/CategorieController.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Categorie;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class CategorieController extends Controller
|
||||
{
|
||||
public function index(): Response
|
||||
{
|
||||
return Inertia::render('Categories/Index', [
|
||||
'categories' => Categorie::withCount('articles')->orderBy('ordre')->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$this->authorize('create', Categorie::class);
|
||||
|
||||
$validated = $request->validate([
|
||||
'nom' => 'required|string|max:100|unique:categories,nom',
|
||||
'description' => 'nullable|string',
|
||||
'couleur' => 'nullable|string|max:7',
|
||||
'icone' => 'nullable|string|max:50',
|
||||
'ordre' => 'nullable|integer|min:0',
|
||||
]);
|
||||
|
||||
Categorie::create($validated);
|
||||
|
||||
return back()->with('success', 'Catégorie créée.');
|
||||
}
|
||||
|
||||
public function update(Request $request, Categorie $categorie): RedirectResponse
|
||||
{
|
||||
$this->authorize('update', Categorie::class);
|
||||
|
||||
$validated = $request->validate([
|
||||
'nom' => 'required|string|max:100|unique:categories,nom,' . $categorie->id,
|
||||
'description' => 'nullable|string',
|
||||
'couleur' => 'nullable|string|max:7',
|
||||
'icone' => 'nullable|string|max:50',
|
||||
'ordre' => 'nullable|integer|min:0',
|
||||
'active' => 'boolean',
|
||||
]);
|
||||
|
||||
$categorie->update($validated);
|
||||
|
||||
return back()->with('success', 'Catégorie mise à jour.');
|
||||
}
|
||||
|
||||
public function destroy(Categorie $categorie): RedirectResponse
|
||||
{
|
||||
$this->authorize('delete', Categorie::class);
|
||||
|
||||
$categorie->update(['active' => false]);
|
||||
|
||||
return back()->with('success', 'Catégorie désactivée.');
|
||||
}
|
||||
}
|
||||
247
app/Http/Controllers/CommandeController.php
Normal file
247
app/Http/Controllers/CommandeController.php
Normal file
@@ -0,0 +1,247 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Article;
|
||||
use App\Models\Categorie;
|
||||
use App\Models\Commande;
|
||||
use App\Models\Fournisseur;
|
||||
use App\Models\Service;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class CommandeController extends Controller
|
||||
{
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$query = Commande::with(['service', 'fournisseur', 'demandeur'])
|
||||
->when($request->service_id, fn ($q) => $q->parService($request->service_id))
|
||||
->when($request->fournisseur_id, fn ($q) => $q->parFournisseur($request->fournisseur_id))
|
||||
->when($request->statut, fn ($q) => $q->parStatut($request->statut))
|
||||
->when($request->priorite, fn ($q) => $q->where('priorite', $request->priorite))
|
||||
->when($request->date_from, fn ($q) => $q->whereDate('date_demande', '>=', $request->date_from))
|
||||
->when($request->date_to, fn ($q) => $q->whereDate('date_demande', '<=', $request->date_to))
|
||||
->when($request->search, function ($q) use ($request) {
|
||||
$q->where(function ($sub) use ($request) {
|
||||
$sub->where('numero_commande', 'like', "%{$request->search}%")
|
||||
->orWhere('objet', 'like', "%{$request->search}%")
|
||||
->orWhereHas('fournisseur', fn ($f) => $f->where('nom', 'like', "%{$request->search}%"));
|
||||
});
|
||||
});
|
||||
|
||||
$commandes = $query->latest()->paginate(20)->withQueryString();
|
||||
|
||||
return Inertia::render('Commandes/Index', [
|
||||
'commandes' => $commandes,
|
||||
'services' => Service::all(),
|
||||
'fournisseurs' => Fournisseur::active()->orderBy('nom')->get(),
|
||||
'filters' => $request->only(['search', 'service_id', 'fournisseur_id', 'statut', 'priorite', 'date_from', 'date_to']),
|
||||
]);
|
||||
}
|
||||
|
||||
public function create(): Response
|
||||
{
|
||||
$this->authorize('create', Commande::class);
|
||||
|
||||
return Inertia::render('Commandes/Create', [
|
||||
'services' => Service::all(),
|
||||
'fournisseurs' => Fournisseur::active()->orderBy('nom')->get(),
|
||||
'categories' => Categorie::active()->orderBy('ordre')->get(),
|
||||
'articles' => Article::active()->with('categorie')->orderBy('designation')->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$this->authorize('create', Commande::class);
|
||||
|
||||
$validated = $request->validate([
|
||||
'service_id' => 'required|exists:services,id',
|
||||
'fournisseur_id' => 'nullable|exists:fournisseurs,id',
|
||||
'objet' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'justification' => 'nullable|string',
|
||||
'priorite' => 'required|in:normale,haute,urgente',
|
||||
'reference_fournisseur' => 'nullable|string|max:100',
|
||||
'imputation_budgetaire' => 'nullable|string|max:100',
|
||||
'date_demande' => 'required|date',
|
||||
'date_souhaitee' => 'nullable|date|after_or_equal:date_demande',
|
||||
'date_livraison_prevue' => 'nullable|date',
|
||||
'notes' => 'nullable|string',
|
||||
'notes_fournisseur' => 'nullable|string',
|
||||
'lignes' => 'array',
|
||||
'lignes.*.designation' => 'required|string|max:255',
|
||||
'lignes.*.reference' => 'nullable|string|max:100',
|
||||
'lignes.*.quantite' => 'required|numeric|min:0.001',
|
||||
'lignes.*.unite' => 'nullable|string|max:30',
|
||||
'lignes.*.prix_unitaire_ht' => 'nullable|numeric|min:0',
|
||||
'lignes.*.taux_tva' => 'nullable|numeric|min:0|max:100',
|
||||
'lignes.*.categorie_id' => 'nullable|exists:categories,id',
|
||||
'lignes.*.article_id' => 'nullable|exists:articles,id',
|
||||
'lignes.*.notes' => 'nullable|string',
|
||||
]);
|
||||
|
||||
DB::transaction(function () use ($validated, $request) {
|
||||
$commande = Commande::create([
|
||||
...$validated,
|
||||
'numero_commande' => Commande::genererNumero(),
|
||||
'user_id' => $request->user()->id,
|
||||
'statut' => 'brouillon',
|
||||
]);
|
||||
|
||||
foreach ($validated['lignes'] ?? [] as $index => $ligne) {
|
||||
$commande->lignes()->create(array_merge($ligne, ['ordre' => $index]));
|
||||
}
|
||||
});
|
||||
|
||||
return redirect()->route('commandes.index')
|
||||
->with('success', 'Commande créée avec succès.');
|
||||
}
|
||||
|
||||
public function show(Commande $commande): Response
|
||||
{
|
||||
$this->authorize('view', $commande);
|
||||
|
||||
$commande->load([
|
||||
'service', 'fournisseur', 'demandeur', 'validateur', 'acheteur',
|
||||
'lignes.categorie',
|
||||
'historique.user',
|
||||
'piecesJointes.user',
|
||||
]);
|
||||
|
||||
$transitionsDisponibles = collect(Commande::STATUT_TRANSITIONS[$commande->statut] ?? [])
|
||||
->filter(fn ($statut) => request()->user()->hasRole('admin') || $this->userCanTransition(request()->user(), $commande, $statut))
|
||||
->values();
|
||||
|
||||
return Inertia::render('Commandes/Show', [
|
||||
'commande' => $commande,
|
||||
'transitionsDisponibles' => $transitionsDisponibles,
|
||||
]);
|
||||
}
|
||||
|
||||
public function edit(Commande $commande): Response
|
||||
{
|
||||
$this->authorize('update', $commande);
|
||||
|
||||
$commande->load('lignes.categorie');
|
||||
|
||||
return Inertia::render('Commandes/Edit', [
|
||||
'commande' => $commande,
|
||||
'services' => Service::all(),
|
||||
'fournisseurs' => Fournisseur::active()->orderBy('nom')->get(),
|
||||
'categories' => Categorie::active()->orderBy('ordre')->get(),
|
||||
'articles' => Article::active()->with('categorie')->orderBy('designation')->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request, Commande $commande): RedirectResponse
|
||||
{
|
||||
$this->authorize('update', $commande);
|
||||
|
||||
$validated = $request->validate([
|
||||
'service_id' => 'required|exists:services,id',
|
||||
'fournisseur_id' => 'nullable|exists:fournisseurs,id',
|
||||
'objet' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'justification' => 'nullable|string',
|
||||
'priorite' => 'required|in:normale,haute,urgente',
|
||||
'reference_fournisseur' => 'nullable|string|max:100',
|
||||
'imputation_budgetaire' => 'nullable|string|max:100',
|
||||
'date_demande' => 'required|date',
|
||||
'date_souhaitee' => 'nullable|date',
|
||||
'date_livraison_prevue' => 'nullable|date',
|
||||
'notes' => 'nullable|string',
|
||||
'notes_fournisseur' => 'nullable|string',
|
||||
'lignes' => 'array',
|
||||
'lignes.*.id' => 'nullable|integer',
|
||||
'lignes.*.designation' => 'required|string|max:255',
|
||||
'lignes.*.reference' => 'nullable|string|max:100',
|
||||
'lignes.*.quantite' => 'required|numeric|min:0.001',
|
||||
'lignes.*.quantite_recue' => 'nullable|numeric|min:0',
|
||||
'lignes.*.unite' => 'nullable|string|max:30',
|
||||
'lignes.*.prix_unitaire_ht' => 'nullable|numeric|min:0',
|
||||
'lignes.*.taux_tva' => 'nullable|numeric|min:0|max:100',
|
||||
'lignes.*.categorie_id' => 'nullable|exists:categories,id',
|
||||
'lignes.*.article_id' => 'nullable|exists:articles,id',
|
||||
'lignes.*.notes' => 'nullable|string',
|
||||
]);
|
||||
|
||||
DB::transaction(function () use ($validated, $commande) {
|
||||
$commande->update($validated);
|
||||
|
||||
$lignesData = $validated['lignes'] ?? [];
|
||||
$lignesIds = collect($lignesData)->pluck('id')->filter()->all();
|
||||
|
||||
// Supprimer les lignes retirées
|
||||
$commande->lignes()->whereNotIn('id', $lignesIds)->delete();
|
||||
|
||||
foreach ($lignesData as $index => $ligneData) {
|
||||
$commande->lignes()->updateOrCreate(
|
||||
['id' => $ligneData['id'] ?? null],
|
||||
array_merge($ligneData, ['ordre' => $index, 'commande_id' => $commande->id])
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
return redirect()->route('commandes.show', $commande)
|
||||
->with('success', 'Commande mise à jour.');
|
||||
}
|
||||
|
||||
public function destroy(Commande $commande): RedirectResponse
|
||||
{
|
||||
$this->authorize('delete', $commande);
|
||||
|
||||
$commande->delete();
|
||||
|
||||
return redirect()->route('commandes.index')
|
||||
->with('success', 'Commande supprimée.');
|
||||
}
|
||||
|
||||
public function transition(Request $request, Commande $commande): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'statut' => 'required|string',
|
||||
'commentaire' => 'nullable|string|max:1000',
|
||||
]);
|
||||
|
||||
$this->authorize('transition', [$commande, $validated['statut']]);
|
||||
|
||||
$ok = $commande->transitionnerVers($validated['statut'], $request->user(), $validated['commentaire'] ?? null);
|
||||
|
||||
if (!$ok) {
|
||||
return back()->with('error', 'Transition non autorisée.');
|
||||
}
|
||||
|
||||
return redirect()->route('commandes.show', $commande)
|
||||
->with('success', 'Statut mis à jour : ' . Commande::STATUTS_LABELS[$validated['statut']]);
|
||||
}
|
||||
|
||||
private function userCanTransition($user, Commande $commande, string $statut): bool
|
||||
{
|
||||
try {
|
||||
$this->authorize('transition', [$commande, $statut]);
|
||||
return true;
|
||||
} catch (\Exception) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function exportPdf(Commande $commande)
|
||||
{
|
||||
$this->authorize('view', $commande);
|
||||
|
||||
$commande->load([
|
||||
'service', 'fournisseur', 'demandeur', 'validateur', 'acheteur',
|
||||
'lignes.categorie',
|
||||
]);
|
||||
|
||||
$pdf = \Barryvdh\DomPDF\Facade\Pdf::loadView('pdf.commande', [
|
||||
'commande' => $commande,
|
||||
]);
|
||||
|
||||
return $pdf->stream('commande-' . $commande->numero_commande . '.pdf');
|
||||
}
|
||||
}
|
||||
161
app/Http/Controllers/ContratController.php
Normal file
161
app/Http/Controllers/ContratController.php
Normal file
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Contrat;
|
||||
use App\Models\Fournisseur;
|
||||
use App\Models\Service;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ContratController extends Controller
|
||||
{
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$this->authorize('viewAny', Contrat::class);
|
||||
|
||||
$query = Contrat::with(['fournisseur', 'service']);
|
||||
|
||||
if (!$request->user()->hasRole('admin')) {
|
||||
$query->where('service_id', $request->user()->service_id);
|
||||
}
|
||||
|
||||
$query->when($request->search, function ($q, $search) {
|
||||
$q->where(function ($sub) use ($search) {
|
||||
$sub->where('titre', 'like', "%{$search}%")
|
||||
->orWhereHas('fournisseur', fn($f) => $f->where('nom', 'like', "%{$search}%"));
|
||||
});
|
||||
})->when($request->service_id, function ($q, $serviceId) use ($request) {
|
||||
if ($request->user()->hasRole('admin')) {
|
||||
$q->where('service_id', $serviceId);
|
||||
}
|
||||
})->when($request->fournisseur_id, function ($q, $fournisseurId) {
|
||||
$q->where('fournisseur_id', $fournisseurId);
|
||||
})->when($request->statut, function ($q, $statut) {
|
||||
$q->where('statut', $statut);
|
||||
});
|
||||
|
||||
$contrats = $query->orderBy('date_echeance', 'asc')->paginate(20)->withQueryString();
|
||||
|
||||
// Calculate estProcheEcheance for the frontend
|
||||
$contrats->getCollection()->transform(function ($contrat) {
|
||||
$contrat->append(['est_proche_echeance', 'est_en_retard']);
|
||||
return $contrat;
|
||||
});
|
||||
|
||||
return Inertia::render('Contrats/Index', [
|
||||
'contrats' => $contrats,
|
||||
'services' => $request->user()->hasRole('admin') ? Service::all() : Service::where('id', $request->user()->service_id)->get(),
|
||||
'fournisseurs' => Fournisseur::active()->orderBy('nom')->get(),
|
||||
'filters' => $request->only(['search', 'service_id', 'fournisseur_id', 'statut']),
|
||||
'statuts' => Contrat::STATUTS_LABELS,
|
||||
]);
|
||||
}
|
||||
|
||||
public function create(Request $request): Response
|
||||
{
|
||||
$this->authorize('create', Contrat::class);
|
||||
|
||||
return Inertia::render('Contrats/Create', [
|
||||
'services' => $request->user()->hasRole('admin') ? Service::all() : Service::where('id', $request->user()->service_id)->get(),
|
||||
'fournisseurs' => Fournisseur::active()->orderBy('nom')->get(),
|
||||
'statuts' => Contrat::STATUTS_LABELS,
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$this->authorize('create', Contrat::class);
|
||||
|
||||
$rules = [
|
||||
'titre' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'fournisseur_id' => 'required|exists:fournisseurs,id',
|
||||
'date_debut' => 'nullable|date',
|
||||
'date_echeance' => 'required|date',
|
||||
'statut' => 'required|in:actif,a_renouveler,expire,resilie',
|
||||
'montant' => 'nullable|numeric|min:0',
|
||||
'preavis_jours' => 'nullable|integer|min:0',
|
||||
];
|
||||
|
||||
// Only admins can select other services, otherwise we force the user's service
|
||||
if ($request->user()->hasRole('admin')) {
|
||||
$rules['service_id'] = 'required|exists:services,id';
|
||||
}
|
||||
|
||||
$validated = $request->validate($rules);
|
||||
|
||||
if (!$request->user()->hasRole('admin')) {
|
||||
$validated['service_id'] = $request->user()->service_id;
|
||||
}
|
||||
|
||||
$contrat = Contrat::create($validated);
|
||||
|
||||
return redirect()->route('contrats.index')
|
||||
->with('success', 'Contrat créé avec succès.');
|
||||
}
|
||||
|
||||
public function show(Contrat $contrat): Response
|
||||
{
|
||||
$this->authorize('view', $contrat);
|
||||
|
||||
$contrat->load(['fournisseur', 'service', 'piecesJointes.user']);
|
||||
$contrat->append(['est_proche_echeance', 'est_en_retard']);
|
||||
|
||||
return Inertia::render('Contrats/Show', [
|
||||
'contrat' => $contrat,
|
||||
]);
|
||||
}
|
||||
|
||||
public function edit(Contrat $contrat, Request $request): Response
|
||||
{
|
||||
$this->authorize('update', $contrat);
|
||||
|
||||
return Inertia::render('Contrats/Edit', [
|
||||
'contrat' => $contrat,
|
||||
'services' => $request->user()->hasRole('admin') ? Service::all() : Service::where('id', $request->user()->service_id)->get(),
|
||||
'fournisseurs' => Fournisseur::active()->orderBy('nom')->get(),
|
||||
'statuts' => Contrat::STATUTS_LABELS,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request, Contrat $contrat): RedirectResponse
|
||||
{
|
||||
$this->authorize('update', $contrat);
|
||||
|
||||
$rules = [
|
||||
'titre' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'fournisseur_id' => 'required|exists:fournisseurs,id',
|
||||
'date_debut' => 'nullable|date',
|
||||
'date_echeance' => 'required|date',
|
||||
'statut' => 'required|in:actif,a_renouveler,expire,resilie',
|
||||
'montant' => 'nullable|numeric|min:0',
|
||||
'preavis_jours' => 'nullable|integer|min:0',
|
||||
];
|
||||
|
||||
if ($request->user()->hasRole('admin')) {
|
||||
$rules['service_id'] = 'required|exists:services,id';
|
||||
}
|
||||
|
||||
$validated = $request->validate($rules);
|
||||
|
||||
$contrat->update($validated);
|
||||
|
||||
return redirect()->route('contrats.show', $contrat)
|
||||
->with('success', 'Contrat mis à jour.');
|
||||
}
|
||||
|
||||
public function destroy(Contrat $contrat): RedirectResponse
|
||||
{
|
||||
$this->authorize('delete', $contrat);
|
||||
|
||||
$contrat->delete();
|
||||
|
||||
return redirect()->route('contrats.index')
|
||||
->with('success', 'Contrat supprimé.');
|
||||
}
|
||||
}
|
||||
8
app/Http/Controllers/Controller.php
Normal file
8
app/Http/Controllers/Controller.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
abstract class Controller
|
||||
{
|
||||
use \Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
}
|
||||
103
app/Http/Controllers/DashboardController.php
Normal file
103
app/Http/Controllers/DashboardController.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Commande;
|
||||
use App\Models\Service;
|
||||
use App\Models\Contrat;
|
||||
use App\Models\Domaine;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$user = $request->user();
|
||||
$stats = [
|
||||
'total' => Commande::count(),
|
||||
'en_cours' => Commande::enCours()->count(),
|
||||
'en_retard' => Commande::enRetard()->count(),
|
||||
'brouillons' => Commande::parStatut('brouillon')->count(),
|
||||
'en_attente_validation' => Commande::parStatut('en_attente_validation')->count(),
|
||||
'validees' => Commande::parStatut('validee')->count(),
|
||||
'commandees' => Commande::parStatut('commandee')->count(),
|
||||
'partiellement_recues' => Commande::parStatut('partiellement_recue')->count(),
|
||||
'recues_complete' => Commande::parStatut('recue_complete')->count(),
|
||||
];
|
||||
|
||||
$commandesRecentes = Commande::with(['service', 'fournisseur', 'demandeur'])
|
||||
->latest()
|
||||
->limit(8)
|
||||
->get();
|
||||
|
||||
$commandesEnRetard = Commande::enRetard()
|
||||
->with(['service', 'fournisseur', 'demandeur'])
|
||||
->orderBy('date_souhaitee')
|
||||
->limit(10)
|
||||
->get();
|
||||
|
||||
$commandesUrgentes = Commande::urgentes()
|
||||
->enCours()
|
||||
->with(['service', 'fournisseur', 'demandeur'])
|
||||
->latest()
|
||||
->limit(5)
|
||||
->get();
|
||||
|
||||
$statsParStatut = Commande::select('statut', DB::raw('count(*) as total'))
|
||||
->groupBy('statut')
|
||||
->get()
|
||||
->keyBy('statut');
|
||||
|
||||
$statsParService = Service::withCount([
|
||||
'commandes',
|
||||
'commandes as commandes_en_cours_count' => fn ($q) => $q->enCours(),
|
||||
])->get();
|
||||
|
||||
$montantParMois = Commande::select(
|
||||
DB::raw('YEAR(date_demande) as annee'),
|
||||
DB::raw('MONTH(date_demande) as mois'),
|
||||
DB::raw('SUM(montant_ttc) as total_ttc'),
|
||||
DB::raw('COUNT(*) as nb_commandes')
|
||||
)
|
||||
->whereYear('date_demande', now()->year)
|
||||
->whereNotIn('statut', ['annulee'])
|
||||
->groupBy('annee', 'mois')
|
||||
->orderBy('mois')
|
||||
->get();
|
||||
|
||||
// Stats Contrats
|
||||
$contratsQuery = Contrat::query();
|
||||
if (!$user->hasRole('admin')) {
|
||||
$contratsQuery->where('service_id', $user->service_id);
|
||||
}
|
||||
$tousContrats = $contratsQuery->get();
|
||||
$statsContrats = [
|
||||
'total' => $tousContrats->count(),
|
||||
'proches' => $tousContrats->filter(fn($c) => $c->est_proche_echeance && !$c->est_en_retard)->count(),
|
||||
'en_retard' => $tousContrats->filter(fn($c) => $c->est_en_retard)->count(),
|
||||
];
|
||||
|
||||
// Stats Domaines (Visibles par tous)
|
||||
$tousDomaines = Domaine::all();
|
||||
$statsDomaines = [
|
||||
'total' => $tousDomaines->count(),
|
||||
'proches' => $tousDomaines->filter(fn($d) => $d->est_proche_echeance && !$d->est_en_retard)->count(),
|
||||
'en_retard' => $tousDomaines->filter(fn($d) => $d->est_en_retard)->count(),
|
||||
];
|
||||
|
||||
return Inertia::render('Dashboard/Index', compact(
|
||||
'stats',
|
||||
'commandesRecentes',
|
||||
'commandesEnRetard',
|
||||
'commandesUrgentes',
|
||||
'statsParStatut',
|
||||
'statsParService',
|
||||
'montantParMois',
|
||||
'statsContrats',
|
||||
'statsDomaines',
|
||||
));
|
||||
}
|
||||
}
|
||||
148
app/Http/Controllers/DomaineController.php
Normal file
148
app/Http/Controllers/DomaineController.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Domaine;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
use Iodev\Whois\Factory as WhoisFactory;
|
||||
use Iodev\Whois\Exceptions\ConnectionException;
|
||||
use Iodev\Whois\Exceptions\ServerMismatchException;
|
||||
use Iodev\Whois\Exceptions\WhoisException;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class DomaineController extends Controller
|
||||
{
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$this->authorize('viewAny', Domaine::class);
|
||||
|
||||
$query = Domaine::query();
|
||||
|
||||
$query->when($request->search, function ($q, $search) {
|
||||
$q->where('nom', 'like', "%{$search}%")
|
||||
->orWhere('prestataire', 'like', "%{$search}%")
|
||||
->orWhere('hebergeur', 'like', "%{$search}%");
|
||||
});
|
||||
|
||||
$domaines = $query->orderBy('date_echeance', 'asc')->paginate(20)->withQueryString();
|
||||
|
||||
$domaines->getCollection()->transform(function ($domaine) {
|
||||
$domaine->append(['est_proche_echeance', 'est_en_retard']);
|
||||
return $domaine;
|
||||
});
|
||||
|
||||
return Inertia::render('Domaines/Index', [
|
||||
'domaines' => $domaines,
|
||||
'filters' => $request->only(['search']),
|
||||
]);
|
||||
}
|
||||
|
||||
public function create(): Response
|
||||
{
|
||||
$this->authorize('create', Domaine::class);
|
||||
|
||||
return Inertia::render('Domaines/Create');
|
||||
}
|
||||
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$this->authorize('create', Domaine::class);
|
||||
|
||||
$validated = $request->validate([
|
||||
'nom' => 'required|string|max:255|unique:domaines,nom',
|
||||
'date_echeance' => 'nullable|date',
|
||||
'prestataire' => 'nullable|string',
|
||||
'hebergeur' => 'nullable|string|max:255',
|
||||
]);
|
||||
|
||||
$domaine = Domaine::create($validated);
|
||||
|
||||
// Si la date d'échéance n'est pas fournie, on tente de la récupérer via WHOIS
|
||||
if (empty($validated['date_echeance'])) {
|
||||
$this->syncWhoisDate($domaine);
|
||||
}
|
||||
|
||||
return redirect()->route('domaines.index')
|
||||
->with('success', 'Domaine créé avec succès.');
|
||||
}
|
||||
|
||||
public function edit(Domaine $domaine): Response
|
||||
{
|
||||
$this->authorize('update', $domaine);
|
||||
|
||||
return Inertia::render('Domaines/Edit', [
|
||||
'domaine' => $domaine,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request, Domaine $domaine): RedirectResponse
|
||||
{
|
||||
$this->authorize('update', $domaine);
|
||||
|
||||
$validated = $request->validate([
|
||||
'nom' => 'required|string|max:255|unique:domaines,nom,' . $domaine->id,
|
||||
'date_echeance' => 'nullable|date',
|
||||
'prestataire' => 'nullable|string',
|
||||
'hebergeur' => 'nullable|string|max:255',
|
||||
]);
|
||||
|
||||
$domaine->update($validated);
|
||||
|
||||
return redirect()->route('domaines.index')
|
||||
->with('success', 'Domaine mis à jour.');
|
||||
}
|
||||
|
||||
public function destroy(Domaine $domaine): RedirectResponse
|
||||
{
|
||||
$this->authorize('delete', $domaine);
|
||||
|
||||
$domaine->delete();
|
||||
|
||||
return redirect()->route('domaines.index')
|
||||
->with('success', 'Domaine supprimé.');
|
||||
}
|
||||
|
||||
public function syncWhois(Domaine $domaine): RedirectResponse
|
||||
{
|
||||
$this->authorize('update', $domaine);
|
||||
|
||||
if ($this->syncWhoisDate($domaine)) {
|
||||
return back()->with('success', 'Date d\'échéance synchronisée avec le Whois depuis le port 43.');
|
||||
}
|
||||
|
||||
return back()->with('error', 'Impossible de récupérer la date d\'échéance pour ce domaine (Whois indisponible ou format inconnu).');
|
||||
}
|
||||
|
||||
private function syncWhoisDate(Domaine $domaine): bool
|
||||
{
|
||||
try {
|
||||
$whois = WhoisFactory::get()->createWhois();
|
||||
$info = $whois->loadDomainInfo($domaine->nom);
|
||||
|
||||
if ($info && $info->expirationDate) {
|
||||
// expirationDate is a unix timestamp integer in the package
|
||||
$domaine->update([
|
||||
'date_echeance' => Carbon::createFromTimestamp($info->expirationDate)->format('Y-m-d')
|
||||
]);
|
||||
return true;
|
||||
}
|
||||
} catch (ConnectionException $e) {
|
||||
// Port 43 bloqué ou timeout
|
||||
return false;
|
||||
} catch (ServerMismatchException $e) {
|
||||
// Serveur Whois inconnu
|
||||
return false;
|
||||
} catch (WhoisException $e) {
|
||||
// Autre erreur Whois
|
||||
return false;
|
||||
} catch (\Exception $e) {
|
||||
// Erreur inattendue
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
116
app/Http/Controllers/FournisseurController.php
Normal file
116
app/Http/Controllers/FournisseurController.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Fournisseur;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class FournisseurController extends Controller
|
||||
{
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$this->authorize('viewAny', Fournisseur::class);
|
||||
|
||||
$query = Fournisseur::withCount('commandes')
|
||||
->when($request->search, fn ($q) => $q->where(function ($sub) use ($request) {
|
||||
$sub->where('nom', 'like', "%{$request->search}%")
|
||||
->orWhere('ville', 'like', "%{$request->search}%")
|
||||
->orWhere('email', 'like', "%{$request->search}%");
|
||||
}))
|
||||
->when($request->has('active') && $request->active !== '', fn ($q) => $q->where('active', $request->active));
|
||||
|
||||
$fournisseurs = $query->orderBy('nom')->paginate(20)->withQueryString();
|
||||
|
||||
return Inertia::render('Fournisseurs/Index', [
|
||||
'fournisseurs' => $fournisseurs,
|
||||
'filters' => $request->only(['search', 'active']),
|
||||
]);
|
||||
}
|
||||
|
||||
public function create(): Response
|
||||
{
|
||||
$this->authorize('create', Fournisseur::class);
|
||||
|
||||
return Inertia::render('Fournisseurs/Create');
|
||||
}
|
||||
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$this->authorize('create', Fournisseur::class);
|
||||
|
||||
$validated = $this->validateFournisseur($request);
|
||||
Fournisseur::create($validated);
|
||||
|
||||
return redirect()->route('fournisseurs.index')
|
||||
->with('success', 'Fournisseur créé avec succès.');
|
||||
}
|
||||
|
||||
public function show(Fournisseur $fournisseur): Response
|
||||
{
|
||||
$this->authorize('view', $fournisseur);
|
||||
|
||||
$fournisseur->load(['commandes' => fn ($q) => $q->with('service', 'demandeur')->latest()->limit(10)]);
|
||||
|
||||
return Inertia::render('Fournisseurs/Show', compact('fournisseur'));
|
||||
}
|
||||
|
||||
public function edit(Fournisseur $fournisseur): Response
|
||||
{
|
||||
$this->authorize('update', $fournisseur);
|
||||
|
||||
return Inertia::render('Fournisseurs/Edit', compact('fournisseur'));
|
||||
}
|
||||
|
||||
public function update(Request $request, Fournisseur $fournisseur): RedirectResponse
|
||||
{
|
||||
$this->authorize('update', $fournisseur);
|
||||
|
||||
$validated = $this->validateFournisseur($request);
|
||||
$fournisseur->update($validated);
|
||||
|
||||
return redirect()->route('fournisseurs.show', $fournisseur)
|
||||
->with('success', 'Fournisseur mis à jour.');
|
||||
}
|
||||
|
||||
public function destroy(Fournisseur $fournisseur): RedirectResponse
|
||||
{
|
||||
$this->authorize('delete', $fournisseur);
|
||||
|
||||
$fournisseur->delete();
|
||||
|
||||
return redirect()->route('fournisseurs.index')
|
||||
->with('success', 'Fournisseur supprimé.');
|
||||
}
|
||||
|
||||
public function toggleActive(Fournisseur $fournisseur): RedirectResponse
|
||||
{
|
||||
$this->authorize('update', $fournisseur);
|
||||
|
||||
$fournisseur->update(['active' => !$fournisseur->active]);
|
||||
|
||||
return back()->with('success', 'Statut du fournisseur mis à jour.');
|
||||
}
|
||||
|
||||
private function validateFournisseur(Request $request): array
|
||||
{
|
||||
return $request->validate([
|
||||
'nom' => 'required|string|max:255',
|
||||
'raison_sociale' => 'nullable|string|max:255',
|
||||
'siret' => 'nullable|string|max:14',
|
||||
'adresse' => 'nullable|string',
|
||||
'code_postal' => 'nullable|string|max:10',
|
||||
'ville' => 'nullable|string|max:100',
|
||||
'telephone' => 'nullable|string|max:20',
|
||||
'email' => 'nullable|email|max:255',
|
||||
'contact_commercial' => 'nullable|string|max:255',
|
||||
'email_commercial' => 'nullable|email|max:255',
|
||||
'telephone_commercial' => 'nullable|string|max:20',
|
||||
'site_web' => 'nullable|url|max:255',
|
||||
'notes' => 'nullable|string',
|
||||
'active' => 'boolean',
|
||||
]);
|
||||
}
|
||||
}
|
||||
115
app/Http/Controllers/PieceJointeController.php
Normal file
115
app/Http/Controllers/PieceJointeController.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Commande;
|
||||
use App\Models\PieceJointe;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
class PieceJointeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Upload une pièce jointe sur une commande.
|
||||
*/
|
||||
public function store(Request $request, Commande $commande): RedirectResponse
|
||||
{
|
||||
$request->validate([
|
||||
'type' => 'required|in:devis,bon_commande,bon_livraison,facture,autre',
|
||||
'fichier' => [
|
||||
'required',
|
||||
'file',
|
||||
'max:20480', // 20 Mo max
|
||||
'mimes:pdf,jpg,jpeg,png,gif,webp,doc,docx,xls,xlsx,odt,ods,csv,zip',
|
||||
],
|
||||
'description' => 'nullable|string|max:500',
|
||||
], [
|
||||
'fichier.mimes' => 'Types autorisés : PDF, images, Word, Excel, OpenDocument, CSV, ZIP.',
|
||||
'fichier.max' => 'La pièce jointe ne peut pas dépasser 20 Mo.',
|
||||
]);
|
||||
|
||||
$fichier = $request->file('fichier');
|
||||
$chemin = $fichier->store(
|
||||
'commandes/' . $commande->id,
|
||||
'private'
|
||||
);
|
||||
|
||||
$commande->piecesJointes()->create([
|
||||
'user_id' => $request->user()->id,
|
||||
'type' => $request->type,
|
||||
'nom_original' => $fichier->getClientOriginalName(),
|
||||
'chemin' => $chemin,
|
||||
'mime_type' => $fichier->getMimeType(),
|
||||
'taille' => $fichier->getSize(),
|
||||
'description' => $request->description,
|
||||
]);
|
||||
|
||||
return back()->with('success', 'Pièce jointe ajoutée avec succès.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload une pièce jointe sur un contrat.
|
||||
*/
|
||||
public function storeContrat(Request $request, \App\Models\Contrat $contrat): RedirectResponse
|
||||
{
|
||||
$request->validate([
|
||||
'type' => 'required|in:contrat,avenant,autre',
|
||||
'fichier' => [
|
||||
'required',
|
||||
'file',
|
||||
'max:20480', // 20 Mo max
|
||||
'mimes:pdf,jpg,jpeg,png,gif,webp,doc,docx,xls,xlsx,odt,ods,csv,zip',
|
||||
],
|
||||
'description' => 'nullable|string|max:500',
|
||||
], [
|
||||
'fichier.mimes' => 'Types autorisés : PDF, images, Word, Excel, OpenDocument, CSV, ZIP.',
|
||||
'fichier.max' => 'La pièce jointe ne peut pas dépasser 20 Mo.',
|
||||
]);
|
||||
|
||||
$fichier = $request->file('fichier');
|
||||
$chemin = $fichier->store(
|
||||
'contrats/' . $contrat->id,
|
||||
'private'
|
||||
);
|
||||
|
||||
$contrat->piecesJointes()->create([
|
||||
'user_id' => $request->user()->id,
|
||||
'type' => $request->type,
|
||||
'nom_original' => $fichier->getClientOriginalName(),
|
||||
'chemin' => $chemin,
|
||||
'mime_type' => $fichier->getMimeType(),
|
||||
'taille' => $fichier->getSize(),
|
||||
'description' => $request->description,
|
||||
]);
|
||||
|
||||
return back()->with('success', 'Pièce jointe ajoutée avec succès au contrat.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Télécharger une pièce jointe (accès sécurisé, sans URL publique).
|
||||
*/
|
||||
public function download(PieceJointe $pieceJointe): StreamedResponse
|
||||
{
|
||||
// Vérifier que l'utilisateur est authentifié (middleware auth déjà sur le groupe)
|
||||
abort_unless(Storage::disk('private')->exists($pieceJointe->chemin), 404);
|
||||
|
||||
return Storage::disk('private')->download(
|
||||
$pieceJointe->chemin,
|
||||
$pieceJointe->nom_original
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Supprimer une pièce jointe.
|
||||
*/
|
||||
public function destroy(PieceJointe $pieceJointe): RedirectResponse
|
||||
{
|
||||
$this->authorize('delete', $pieceJointe);
|
||||
|
||||
$pieceJointe->supprimer();
|
||||
|
||||
return back()->with('success', 'Pièce jointe supprimée.');
|
||||
}
|
||||
}
|
||||
63
app/Http/Controllers/ProfileController.php
Normal file
63
app/Http/Controllers/ProfileController.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\ProfileUpdateRequest;
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class ProfileController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the user's profile form.
|
||||
*/
|
||||
public function edit(Request $request): Response
|
||||
{
|
||||
return Inertia::render('Profile/Edit', [
|
||||
'mustVerifyEmail' => $request->user() instanceof MustVerifyEmail,
|
||||
'status' => session('status'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the user's profile information.
|
||||
*/
|
||||
public function update(ProfileUpdateRequest $request): RedirectResponse
|
||||
{
|
||||
$request->user()->fill($request->validated());
|
||||
|
||||
if ($request->user()->isDirty('email')) {
|
||||
$request->user()->email_verified_at = null;
|
||||
}
|
||||
|
||||
$request->user()->save();
|
||||
|
||||
return Redirect::route('profile.edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the user's account.
|
||||
*/
|
||||
public function destroy(Request $request): RedirectResponse
|
||||
{
|
||||
$request->validate([
|
||||
'password' => ['required', 'current_password'],
|
||||
]);
|
||||
|
||||
$user = $request->user();
|
||||
|
||||
Auth::logout();
|
||||
|
||||
$user->delete();
|
||||
|
||||
$request->session()->invalidate();
|
||||
$request->session()->regenerateToken();
|
||||
|
||||
return Redirect::to('/');
|
||||
}
|
||||
}
|
||||
58
app/Http/Controllers/ServiceController.php
Normal file
58
app/Http/Controllers/ServiceController.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Service;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class ServiceController extends Controller
|
||||
{
|
||||
public function index(): Response
|
||||
{
|
||||
return Inertia::render('Services/Index', [
|
||||
'services' => Service::withCount('users', 'commandes')->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'nom' => 'required|string|max:100|unique:services,nom',
|
||||
'description' => 'nullable|string',
|
||||
'couleur' => 'nullable|string|max:7',
|
||||
'icone' => 'nullable|string|max:50',
|
||||
]);
|
||||
|
||||
Service::create($validated);
|
||||
|
||||
return back()->with('success', 'Service créé.');
|
||||
}
|
||||
|
||||
public function update(Request $request, Service $service): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'nom' => 'required|string|max:100|unique:services,nom,' . $service->id,
|
||||
'description' => 'nullable|string',
|
||||
'couleur' => 'nullable|string|max:7',
|
||||
'icone' => 'nullable|string|max:50',
|
||||
]);
|
||||
|
||||
$service->update($validated);
|
||||
|
||||
return back()->with('success', 'Service mis à jour.');
|
||||
}
|
||||
|
||||
public function destroy(Service $service): RedirectResponse
|
||||
{
|
||||
if ($service->users()->exists() || $service->commandes()->exists()) {
|
||||
return back()->with('error', 'Impossible de supprimer un service ayant des utilisateurs ou des commandes.');
|
||||
}
|
||||
|
||||
$service->delete();
|
||||
|
||||
return back()->with('success', 'Service supprimé.');
|
||||
}
|
||||
}
|
||||
73
app/Http/Controllers/UserController.php
Normal file
73
app/Http/Controllers/UserController.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Service;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
public function index(): Response
|
||||
{
|
||||
$this->authorize('viewAny', User::class);
|
||||
|
||||
return Inertia::render('Users/Index', [
|
||||
'users' => User::with('service', 'roles')->orderBy('name')->paginate(20),
|
||||
'services' => Service::all(),
|
||||
'roles' => Role::all(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function edit(User $user): Response
|
||||
{
|
||||
$this->authorize('update', $user);
|
||||
|
||||
return Inertia::render('Users/Edit', [
|
||||
'user' => $user->load('service', 'roles'),
|
||||
'services' => Service::all(),
|
||||
'roles' => Role::all(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request, User $user): RedirectResponse
|
||||
{
|
||||
$this->authorize('update', $user);
|
||||
|
||||
$validated = $request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|email|unique:users,email,' . $user->id,
|
||||
'service_id' => 'nullable|exists:services,id',
|
||||
'telephone' => 'nullable|string|max:20',
|
||||
'role' => 'required|string|exists:roles,name',
|
||||
'password' => 'nullable|string|min:8|confirmed',
|
||||
]);
|
||||
|
||||
$user->update([
|
||||
'name' => $validated['name'],
|
||||
'email' => $validated['email'],
|
||||
'service_id' => $validated['service_id'],
|
||||
'telephone' => $validated['telephone'],
|
||||
...(isset($validated['password']) ? ['password' => Hash::make($validated['password'])] : []),
|
||||
]);
|
||||
|
||||
$user->syncRoles([$validated['role']]);
|
||||
|
||||
return redirect()->route('users.index')
|
||||
->with('success', 'Utilisateur mis à jour.');
|
||||
}
|
||||
|
||||
public function toggleActive(User $user): RedirectResponse
|
||||
{
|
||||
$this->authorize('update', $user);
|
||||
|
||||
$user->update(['active' => !$user->active]);
|
||||
|
||||
return back()->with('success', 'Statut de l\'utilisateur mis à jour.');
|
||||
}
|
||||
}
|
||||
36
app/Http/Middleware/HandleInertiaRequests.php
Normal file
36
app/Http/Middleware/HandleInertiaRequests.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Models\Commande;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Middleware;
|
||||
|
||||
class HandleInertiaRequests extends Middleware
|
||||
{
|
||||
protected $rootView = 'app';
|
||||
|
||||
public function version(Request $request): ?string
|
||||
{
|
||||
return parent::version($request);
|
||||
}
|
||||
|
||||
public function share(Request $request): array
|
||||
{
|
||||
return [
|
||||
...parent::share($request),
|
||||
'auth' => [
|
||||
'user' => $request->user()?->load('service', 'roles'),
|
||||
],
|
||||
'flash' => [
|
||||
'success' => fn () => $request->session()->get('success'),
|
||||
'error' => fn () => $request->session()->get('error'),
|
||||
],
|
||||
'config' => [
|
||||
'statuts' => Commande::STATUTS_LABELS,
|
||||
'priorites' => Commande::PRIORITES_LABELS,
|
||||
'statuts_couleurs' => Commande::STATUTS_COULEURS,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
86
app/Http/Requests/Auth/LoginRequest.php
Normal file
86
app/Http/Requests/Auth/LoginRequest.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Auth;
|
||||
|
||||
use Illuminate\Auth\Events\Lockout;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class LoginRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'email' => ['required', 'string', 'email'],
|
||||
'password' => ['required', 'string'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to authenticate the request's credentials.
|
||||
*
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function authenticate(): void
|
||||
{
|
||||
$this->ensureIsNotRateLimited();
|
||||
|
||||
if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) {
|
||||
RateLimiter::hit($this->throttleKey());
|
||||
|
||||
throw ValidationException::withMessages([
|
||||
'email' => trans('auth.failed'),
|
||||
]);
|
||||
}
|
||||
|
||||
RateLimiter::clear($this->throttleKey());
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure the login request is not rate limited.
|
||||
*
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function ensureIsNotRateLimited(): void
|
||||
{
|
||||
if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) {
|
||||
return;
|
||||
}
|
||||
|
||||
event(new Lockout($this));
|
||||
|
||||
$seconds = RateLimiter::availableIn($this->throttleKey());
|
||||
|
||||
throw ValidationException::withMessages([
|
||||
'email' => trans('auth.throttle', [
|
||||
'seconds' => $seconds,
|
||||
'minutes' => ceil($seconds / 60),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the rate limiting throttle key for the request.
|
||||
*/
|
||||
public function throttleKey(): string
|
||||
{
|
||||
return Str::transliterate(Str::lower($this->string('email')).'|'.$this->ip());
|
||||
}
|
||||
}
|
||||
31
app/Http/Requests/ProfileUpdateRequest.php
Normal file
31
app/Http/Requests/ProfileUpdateRequest.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class ProfileUpdateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => [
|
||||
'required',
|
||||
'string',
|
||||
'lowercase',
|
||||
'email',
|
||||
'max:255',
|
||||
Rule::unique(User::class)->ignore($this->user()->id),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
35
app/Models/Article.php
Normal file
35
app/Models/Article.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class Article extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'reference', 'designation', 'description',
|
||||
'categorie_id', 'fournisseur_id', 'prix_unitaire_ht', 'unite', 'active',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'prix_unitaire_ht' => 'decimal:2',
|
||||
'active' => 'boolean',
|
||||
];
|
||||
|
||||
public function categorie(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Categorie::class);
|
||||
}
|
||||
|
||||
public function fournisseur(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Fournisseur::class);
|
||||
}
|
||||
|
||||
public function scopeActive(Builder $query): Builder
|
||||
{
|
||||
return $query->where('active', true);
|
||||
}
|
||||
}
|
||||
32
app/Models/Categorie.php
Normal file
32
app/Models/Categorie.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class Categorie extends Model
|
||||
{
|
||||
protected $fillable = ['nom', 'description', 'couleur', 'icone', 'ordre', 'active'];
|
||||
|
||||
protected $casts = [
|
||||
'active' => 'boolean',
|
||||
'ordre' => 'integer',
|
||||
];
|
||||
|
||||
public function articles(): HasMany
|
||||
{
|
||||
return $this->hasMany(Article::class);
|
||||
}
|
||||
|
||||
public function lignesCommande(): HasMany
|
||||
{
|
||||
return $this->hasMany(LigneCommande::class);
|
||||
}
|
||||
|
||||
public function scopeActive(Builder $query): Builder
|
||||
{
|
||||
return $query->where('active', true);
|
||||
}
|
||||
}
|
||||
267
app/Models/Commande.php
Normal file
267
app/Models/Commande.php
Normal file
@@ -0,0 +1,267 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class Commande extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'numero_commande', 'service_id', 'fournisseur_id', 'user_id',
|
||||
'validateur_id', 'acheteur_id', 'objet', 'description', 'justification',
|
||||
'statut', 'priorite', 'reference_fournisseur', 'imputation_budgetaire',
|
||||
'montant_ht', 'montant_ttc',
|
||||
'date_demande', 'date_souhaitee', 'date_validation', 'date_commande',
|
||||
'date_livraison_prevue', 'date_reception', 'date_reception_complete', 'date_cloture',
|
||||
'notes', 'notes_fournisseur',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'montant_ht' => 'decimal:2',
|
||||
'montant_ttc' => 'decimal:2',
|
||||
'date_demande' => 'date',
|
||||
'date_souhaitee' => 'date',
|
||||
'date_validation' => 'datetime',
|
||||
'date_commande' => 'datetime',
|
||||
'date_livraison_prevue' => 'date',
|
||||
'date_reception' => 'datetime',
|
||||
'date_reception_complete' => 'datetime',
|
||||
'date_cloture' => 'datetime',
|
||||
];
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Constantes
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
const STATUTS_LABELS = [
|
||||
'brouillon' => 'Brouillon',
|
||||
'en_attente_validation' => 'En attente de validation',
|
||||
'validee' => 'Validée',
|
||||
'commandee' => 'Commandée',
|
||||
'partiellement_recue' => 'Partiellement reçue',
|
||||
'recue_complete' => 'Reçue complète',
|
||||
'cloturee' => 'Clôturée',
|
||||
'annulee' => 'Annulée',
|
||||
];
|
||||
|
||||
const STATUTS_COULEURS = [
|
||||
'brouillon' => 'gray',
|
||||
'en_attente_validation' => 'yellow',
|
||||
'validee' => 'blue',
|
||||
'commandee' => 'indigo',
|
||||
'partiellement_recue' => 'orange',
|
||||
'recue_complete' => 'green',
|
||||
'cloturee' => 'slate',
|
||||
'annulee' => 'red',
|
||||
];
|
||||
|
||||
const PRIORITES_LABELS = [
|
||||
'normale' => 'Normale',
|
||||
'haute' => 'Haute',
|
||||
'urgente' => 'Urgente',
|
||||
];
|
||||
|
||||
const STATUT_TRANSITIONS = [
|
||||
'brouillon' => ['en_attente_validation', 'annulee'],
|
||||
'en_attente_validation' => ['validee', 'brouillon', 'annulee'],
|
||||
'validee' => ['commandee', 'annulee'],
|
||||
'commandee' => ['partiellement_recue', 'recue_complete', 'annulee'],
|
||||
'partiellement_recue' => ['recue_complete', 'annulee'],
|
||||
'recue_complete' => ['cloturee'],
|
||||
'cloturee' => [],
|
||||
'annulee' => [],
|
||||
];
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Relations
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
public function service(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Service::class);
|
||||
}
|
||||
|
||||
public function fournisseur(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Fournisseur::class);
|
||||
}
|
||||
|
||||
public function demandeur(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
}
|
||||
|
||||
public function validateur(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'validateur_id');
|
||||
}
|
||||
|
||||
public function acheteur(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'acheteur_id');
|
||||
}
|
||||
|
||||
public function lignes(): HasMany
|
||||
{
|
||||
return $this->hasMany(LigneCommande::class)->orderBy('ordre');
|
||||
}
|
||||
|
||||
public function historique(): HasMany
|
||||
{
|
||||
return $this->hasMany(HistoriqueCommande::class)->orderBy('created_at', 'desc');
|
||||
}
|
||||
|
||||
public function piecesJointes(): HasMany
|
||||
{
|
||||
return $this->hasMany(PieceJointe::class)->orderBy('created_at', 'desc');
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Scopes
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
public function scopeEnCours(Builder $query): Builder
|
||||
{
|
||||
return $query->whereNotIn('statut', ['cloturee', 'annulee']);
|
||||
}
|
||||
|
||||
public function scopeEnRetard(Builder $query): Builder
|
||||
{
|
||||
return $query->enCours()->whereNotNull('date_souhaitee')->where('date_souhaitee', '<', now()->toDateString());
|
||||
}
|
||||
|
||||
public function scopeUrgentes(Builder $query): Builder
|
||||
{
|
||||
return $query->where('priorite', 'urgente');
|
||||
}
|
||||
|
||||
public function scopeParService(Builder $query, int $serviceId): Builder
|
||||
{
|
||||
return $query->where('service_id', $serviceId);
|
||||
}
|
||||
|
||||
public function scopeParStatut(Builder $query, string $statut): Builder
|
||||
{
|
||||
return $query->where('statut', $statut);
|
||||
}
|
||||
|
||||
public function scopeParFournisseur(Builder $query, int $fournisseurId): Builder
|
||||
{
|
||||
return $query->where('fournisseur_id', $fournisseurId);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Accesseurs
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
public function getStatutLabelAttribute(): string
|
||||
{
|
||||
return self::STATUTS_LABELS[$this->statut] ?? $this->statut;
|
||||
}
|
||||
|
||||
public function getStatutCouleurAttribute(): string
|
||||
{
|
||||
return self::STATUTS_COULEURS[$this->statut] ?? 'gray';
|
||||
}
|
||||
|
||||
public function getEstEnRetardAttribute(): bool
|
||||
{
|
||||
return !in_array($this->statut, ['cloturee', 'annulee'])
|
||||
&& $this->date_souhaitee !== null
|
||||
&& $this->date_souhaitee->isPast();
|
||||
}
|
||||
|
||||
public function getTauxReceptionAttribute(): float
|
||||
{
|
||||
$total = $this->lignes->sum(fn ($l) => (float) $l->quantite);
|
||||
if ($total <= 0) {
|
||||
return 0.0;
|
||||
}
|
||||
$recu = $this->lignes->sum(fn ($l) => (float) $l->quantite_recue);
|
||||
|
||||
return round(min($recu / $total * 100, 100), 1);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Numérotation automatique
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
public static function genererNumero(): string
|
||||
{
|
||||
$annee = now()->year;
|
||||
$derniere = static::withTrashed()
|
||||
->where('numero_commande', 'like', "CMD-IT-{$annee}-%")
|
||||
->orderByDesc('id')
|
||||
->value('numero_commande');
|
||||
|
||||
$sequence = 1;
|
||||
if ($derniere) {
|
||||
$sequence = (int) substr($derniere, strrpos($derniere, '-') + 1) + 1;
|
||||
}
|
||||
|
||||
return sprintf('CMD-IT-%d-%04d', $annee, $sequence);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Moteur de transitions
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
public function peutTransitionnerVers(string $statut): bool
|
||||
{
|
||||
return in_array($statut, self::STATUT_TRANSITIONS[$this->statut] ?? []);
|
||||
}
|
||||
|
||||
public function transitionnerVers(string $statut, User $user, ?string $commentaire = null): bool
|
||||
{
|
||||
if (!$this->peutTransitionnerVers($statut)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$ancienStatut = $this->statut;
|
||||
$this->statut = $statut;
|
||||
|
||||
// Mettre à jour les dates et les acteurs selon le nouveau statut
|
||||
match ($statut) {
|
||||
'validee' => $this->fill(['date_validation' => now(), 'validateur_id' => $user->id]),
|
||||
'commandee' => $this->fill(['date_commande' => now(), 'acheteur_id' => $user->id]),
|
||||
'partiellement_recue' => $this->fill(['date_reception' => $this->date_reception ?? now()]),
|
||||
'recue_complete' => $this->fill(['date_reception_complete' => now(), 'date_reception' => $this->date_reception ?? now()]),
|
||||
'cloturee' => $this->fill(['date_cloture' => now()]),
|
||||
default => null,
|
||||
};
|
||||
|
||||
$this->save();
|
||||
|
||||
HistoriqueCommande::create([
|
||||
'commande_id' => $this->id,
|
||||
'user_id' => $user->id,
|
||||
'ancien_statut' => $ancienStatut,
|
||||
'nouveau_statut' => $statut,
|
||||
'commentaire' => $commentaire,
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Recalcul des montants (appelé depuis LigneCommande)
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
public function recalculerMontants(): void
|
||||
{
|
||||
$this->lignes()->get()->tap(function ($lignes) {
|
||||
$ht = $lignes->sum(fn ($l) => (float) $l->montant_ht);
|
||||
$ttc = $lignes->sum(fn ($l) => (float) $l->montant_ttc);
|
||||
$this->withoutEvents(function () use ($ht, $ttc) {
|
||||
$this->update(['montant_ht' => $ht, 'montant_ttc' => $ttc]);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
75
app/Models/Contrat.php
Normal file
75
app/Models/Contrat.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Contrat extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'titre',
|
||||
'description',
|
||||
'fournisseur_id',
|
||||
'service_id',
|
||||
'date_debut',
|
||||
'date_echeance',
|
||||
'statut',
|
||||
'montant',
|
||||
'preavis_jours',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'date_debut' => 'date',
|
||||
'date_echeance' => 'date',
|
||||
'montant' => 'decimal:2',
|
||||
];
|
||||
|
||||
const STATUTS_LABELS = [
|
||||
'actif' => 'Actif',
|
||||
'a_renouveler' => 'À renouveler',
|
||||
'expire' => 'Expiré',
|
||||
'resilie' => 'Résilié',
|
||||
];
|
||||
|
||||
public function fournisseur(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Fournisseur::class);
|
||||
}
|
||||
|
||||
public function service(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Service::class);
|
||||
}
|
||||
|
||||
public function piecesJointes(): HasMany
|
||||
{
|
||||
return $this->hasMany(PieceJointe::class)->orderByDesc('created_at');
|
||||
}
|
||||
|
||||
// Un contrat est considéré "proche d'expiration" si l'échéance est dans moins de 30 jours (ou selon son préavis)
|
||||
public function getEstProcheEcheanceAttribute(): bool
|
||||
{
|
||||
if (!$this->date_echeance || in_array($this->statut, ['resilie', 'expire'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$joursAvantAlerte = $this->preavis_jours > 0 ? $this->preavis_jours + 15 : 30;
|
||||
|
||||
return Carbon::now()->diffInDays($this->date_echeance, false) <= $joursAvantAlerte;
|
||||
}
|
||||
|
||||
public function getEstEnRetardAttribute(): bool
|
||||
{
|
||||
if (!$this->date_echeance || $this->statut === 'resilie') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Carbon::now()->isAfter($this->date_echeance);
|
||||
}
|
||||
}
|
||||
42
app/Models/Domaine.php
Normal file
42
app/Models/Domaine.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Domaine extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'nom',
|
||||
'date_echeance',
|
||||
'prestataire',
|
||||
'hebergeur',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'date_echeance' => 'date',
|
||||
];
|
||||
|
||||
// Un domaine est considéré "proche d'expiration" si l'échéance est dans moins de 30 jours
|
||||
public function getEstProcheEcheanceAttribute(): bool
|
||||
{
|
||||
if (!$this->date_echeance) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Carbon::now()->diffInDays($this->date_echeance, false) <= 30;
|
||||
}
|
||||
|
||||
public function getEstEnRetardAttribute(): bool
|
||||
{
|
||||
if (!$this->date_echeance) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Carbon::now()->isAfter($this->date_echeance);
|
||||
}
|
||||
}
|
||||
35
app/Models/Fournisseur.php
Normal file
35
app/Models/Fournisseur.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class Fournisseur extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'nom', 'raison_sociale', 'siret', 'adresse', 'code_postal', 'ville',
|
||||
'telephone', 'email', 'contact_commercial', 'email_commercial',
|
||||
'telephone_commercial', 'site_web', 'notes', 'active',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'active' => 'boolean',
|
||||
];
|
||||
|
||||
public function commandes(): HasMany
|
||||
{
|
||||
return $this->hasMany(Commande::class);
|
||||
}
|
||||
|
||||
public function articles(): HasMany
|
||||
{
|
||||
return $this->hasMany(Article::class);
|
||||
}
|
||||
|
||||
public function scopeActive(Builder $query): Builder
|
||||
{
|
||||
return $query->where('active', true);
|
||||
}
|
||||
}
|
||||
27
app/Models/HistoriqueCommande.php
Normal file
27
app/Models/HistoriqueCommande.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class HistoriqueCommande extends Model
|
||||
{
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = ['commande_id', 'user_id', 'ancien_statut', 'nouveau_statut', 'commentaire'];
|
||||
|
||||
protected $casts = [
|
||||
'created_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function commande(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Commande::class);
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
60
app/Models/LigneCommande.php
Normal file
60
app/Models/LigneCommande.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class LigneCommande extends Model
|
||||
{
|
||||
protected $table = 'lignes_commande';
|
||||
|
||||
protected $fillable = [
|
||||
'commande_id', 'article_id', 'categorie_id',
|
||||
'designation', 'reference', 'quantite', 'quantite_recue',
|
||||
'unite', 'prix_unitaire_ht', 'taux_tva',
|
||||
'montant_ht', 'montant_ttc', 'notes', 'ordre',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'quantite' => 'decimal:3',
|
||||
'quantite_recue' => 'decimal:3',
|
||||
'prix_unitaire_ht' => 'decimal:2',
|
||||
'taux_tva' => 'decimal:2',
|
||||
'montant_ht' => 'decimal:2',
|
||||
'montant_ttc' => 'decimal:2',
|
||||
];
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::saving(function (LigneCommande $ligne) {
|
||||
if ($ligne->prix_unitaire_ht !== null && $ligne->quantite !== null) {
|
||||
$ligne->montant_ht = round((float) $ligne->quantite * (float) $ligne->prix_unitaire_ht, 2);
|
||||
$ligne->montant_ttc = round((float) $ligne->montant_ht * (1 + (float) $ligne->taux_tva / 100), 2);
|
||||
}
|
||||
});
|
||||
|
||||
static::saved(function (LigneCommande $ligne) {
|
||||
$ligne->commande?->recalculerMontants();
|
||||
});
|
||||
|
||||
static::deleted(function (LigneCommande $ligne) {
|
||||
$ligne->commande?->recalculerMontants();
|
||||
});
|
||||
}
|
||||
|
||||
public function commande(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Commande::class);
|
||||
}
|
||||
|
||||
public function article(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Article::class);
|
||||
}
|
||||
|
||||
public function categorie(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Categorie::class);
|
||||
}
|
||||
}
|
||||
113
app/Models/PieceJointe.php
Normal file
113
app/Models/PieceJointe.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class PieceJointe extends Model
|
||||
{
|
||||
public $timestamps = false;
|
||||
|
||||
protected $table = 'pieces_jointes';
|
||||
|
||||
protected $fillable = [
|
||||
'commande_id', 'contrat_id', 'user_id', 'type',
|
||||
'nom_original', 'chemin', 'mime_type', 'taille', 'description',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'taille' => 'integer',
|
||||
'created_at' => 'datetime',
|
||||
];
|
||||
|
||||
const TYPES_LABELS = [
|
||||
'devis' => 'Devis',
|
||||
'bon_commande' => 'Bon de commande',
|
||||
'bon_livraison' => 'Bon de livraison',
|
||||
'facture' => 'Facture',
|
||||
'contrat' => 'Contrat',
|
||||
'avenant' => 'Avenant',
|
||||
'autre' => 'Autre',
|
||||
];
|
||||
|
||||
const TYPES_ICONES = [
|
||||
'devis' => '📋',
|
||||
'bon_commande' => '🛒',
|
||||
'bon_livraison' => '📦',
|
||||
'facture' => '🧾',
|
||||
'contrat' => '📄',
|
||||
'avenant' => '📑',
|
||||
'autre' => '📎',
|
||||
];
|
||||
|
||||
const TYPES_COULEURS = [
|
||||
'devis' => 'purple',
|
||||
'bon_commande' => 'blue',
|
||||
'bon_livraison' => 'orange',
|
||||
'facture' => 'green',
|
||||
'contrat' => 'indigo',
|
||||
'avenant' => 'teal',
|
||||
'autre' => 'gray',
|
||||
];
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Relations
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
public function commande(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Commande::class);
|
||||
}
|
||||
|
||||
public function contrat(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Contrat::class);
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Accesseurs
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
public function getTypeLabelAttribute(): string
|
||||
{
|
||||
return self::TYPES_LABELS[$this->type] ?? $this->type;
|
||||
}
|
||||
|
||||
public function getTailleFormatteeAttribute(): string
|
||||
{
|
||||
$taille = $this->taille;
|
||||
if ($taille < 1024) {
|
||||
return $taille . ' o';
|
||||
} elseif ($taille < 1024 * 1024) {
|
||||
return round($taille / 1024, 1) . ' Ko';
|
||||
}
|
||||
return round($taille / (1024 * 1024), 1) . ' Mo';
|
||||
}
|
||||
|
||||
public function getEstImageAttribute(): bool
|
||||
{
|
||||
return str_starts_with($this->mime_type, 'image/');
|
||||
}
|
||||
|
||||
public function getEstPdfAttribute(): bool
|
||||
{
|
||||
return $this->mime_type === 'application/pdf';
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Méthodes
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
public function supprimer(): void
|
||||
{
|
||||
Storage::disk('private')->delete($this->chemin);
|
||||
$this->delete();
|
||||
}
|
||||
}
|
||||
21
app/Models/Service.php
Normal file
21
app/Models/Service.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Service extends Model
|
||||
{
|
||||
protected $fillable = ['nom', 'description', 'couleur', 'icone'];
|
||||
|
||||
public function users(): HasMany
|
||||
{
|
||||
return $this->hasMany(User::class);
|
||||
}
|
||||
|
||||
public function commandes(): HasMany
|
||||
{
|
||||
return $this->hasMany(Commande::class);
|
||||
}
|
||||
}
|
||||
48
app/Models/User.php
Normal file
48
app/Models/User.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\UserFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasFactory, Notifiable, HasRoles;
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'email', 'password', 'service_id', 'telephone', 'active',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'password', 'remember_token',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
'active' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function service(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Service::class);
|
||||
}
|
||||
|
||||
public function commandesCreees(): HasMany
|
||||
{
|
||||
return $this->hasMany(Commande::class, 'user_id');
|
||||
}
|
||||
|
||||
public function commandesValidees(): HasMany
|
||||
{
|
||||
return $this->hasMany(Commande::class, 'validateur_id');
|
||||
}
|
||||
}
|
||||
68
app/Policies/CommandePolicy.php
Normal file
68
app/Policies/CommandePolicy.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Commande;
|
||||
use App\Models\User;
|
||||
|
||||
class CommandePolicy
|
||||
{
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function view(User $user, Commande $commande): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->hasAnyRole(['admin', 'responsable', 'acheteur']);
|
||||
}
|
||||
|
||||
public function update(User $user, Commande $commande): bool
|
||||
{
|
||||
if ($user->hasRole('admin')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$statutsEditables = ['brouillon', 'en_attente_validation'];
|
||||
if (!in_array($commande->statut, $statutsEditables)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $user->hasAnyRole(['responsable', 'acheteur'])
|
||||
&& ($commande->user_id === $user->id || $commande->service_id === $user->service_id);
|
||||
}
|
||||
|
||||
public function delete(User $user, Commande $commande): bool
|
||||
{
|
||||
return $user->hasRole('admin');
|
||||
}
|
||||
|
||||
public function transition(User $user, Commande $commande, string $targetStatut): bool
|
||||
{
|
||||
if (!$commande->peutTransitionnerVers($targetStatut)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($user->hasRole('admin')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return match ($targetStatut) {
|
||||
'en_attente_validation' => $user->hasAnyRole(['responsable', 'acheteur']) && $commande->user_id === $user->id,
|
||||
'brouillon' => $user->hasAnyRole(['responsable', 'acheteur']) && $commande->user_id === $user->id,
|
||||
'validee' => $user->hasRole('responsable') && $commande->service_id === $user->service_id,
|
||||
'commandee' => $user->hasAnyRole(['responsable', 'acheteur']),
|
||||
'partiellement_recue',
|
||||
'recue_complete' => $user->hasAnyRole(['responsable', 'acheteur']),
|
||||
'cloturee' => $user->hasAnyRole(['responsable', 'acheteur']),
|
||||
'annulee' => $user->hasAnyRole(['responsable', 'acheteur'])
|
||||
&& !in_array($commande->statut, ['commandee', 'partiellement_recue', 'recue_complete', 'cloturee']),
|
||||
default => false,
|
||||
};
|
||||
}
|
||||
}
|
||||
46
app/Policies/ContratPolicy.php
Normal file
46
app/Policies/ContratPolicy.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Contrat;
|
||||
use App\Models\User;
|
||||
|
||||
class ContratPolicy
|
||||
{
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function view(User $user, Contrat $contrat): bool
|
||||
{
|
||||
if ($user->hasRole('admin')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $user->service_id === $contrat->service_id;
|
||||
}
|
||||
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return true; // Anyone can create, but in the controller we'll restrict to their own service
|
||||
}
|
||||
|
||||
public function update(User $user, Contrat $contrat): bool
|
||||
{
|
||||
if ($user->hasRole('admin')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $user->service_id === $contrat->service_id;
|
||||
}
|
||||
|
||||
public function delete(User $user, Contrat $contrat): bool
|
||||
{
|
||||
if ($user->hasRole('admin')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $user->service_id === $contrat->service_id;
|
||||
}
|
||||
}
|
||||
44
app/Policies/DomainePolicy.php
Normal file
44
app/Policies/DomainePolicy.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Domaine;
|
||||
use App\Models\User;
|
||||
|
||||
class DomainePolicy
|
||||
{
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function view(User $user, Domaine $domaine): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private function canManage(User $user): bool
|
||||
{
|
||||
if ($user->hasRole('admin')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Must belong to "Infrastructure" service
|
||||
return $user->service && $user->service->nom === 'Infrastructure';
|
||||
}
|
||||
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $this->canManage($user);
|
||||
}
|
||||
|
||||
public function update(User $user, Domaine $domaine): bool
|
||||
{
|
||||
return $this->canManage($user);
|
||||
}
|
||||
|
||||
public function delete(User $user, Domaine $domaine): bool
|
||||
{
|
||||
return $this->canManage($user);
|
||||
}
|
||||
}
|
||||
34
app/Policies/FournisseurPolicy.php
Normal file
34
app/Policies/FournisseurPolicy.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Fournisseur;
|
||||
use App\Models\User;
|
||||
|
||||
class FournisseurPolicy
|
||||
{
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function view(User $user, Fournisseur $fournisseur): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->hasAnyRole(['admin', 'responsable', 'acheteur']);
|
||||
}
|
||||
|
||||
public function update(User $user, Fournisseur $fournisseur): bool
|
||||
{
|
||||
return $user->hasAnyRole(['admin', 'responsable', 'acheteur']);
|
||||
}
|
||||
|
||||
public function delete(User $user, Fournisseur $fournisseur): bool
|
||||
{
|
||||
return $user->hasRole('admin');
|
||||
}
|
||||
}
|
||||
15
app/Policies/PieceJointePolicy.php
Normal file
15
app/Policies/PieceJointePolicy.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\PieceJointe;
|
||||
use App\Models\User;
|
||||
|
||||
class PieceJointePolicy
|
||||
{
|
||||
public function delete(User $user, PieceJointe $pieceJointe): bool
|
||||
{
|
||||
// Admin ou celui qui a uploadé
|
||||
return $user->hasRole('admin') || $pieceJointe->user_id === $user->id;
|
||||
}
|
||||
}
|
||||
23
app/Policies/UserPolicy.php
Normal file
23
app/Policies/UserPolicy.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
class UserPolicy
|
||||
{
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->hasRole('admin');
|
||||
}
|
||||
|
||||
public function update(User $user, User $model): bool
|
||||
{
|
||||
return $user->hasRole('admin');
|
||||
}
|
||||
|
||||
public function delete(User $user, User $model): bool
|
||||
{
|
||||
return $user->hasRole('admin') && $user->id !== $model->id;
|
||||
}
|
||||
}
|
||||
48
app/Providers/AppServiceProvider.php
Normal file
48
app/Providers/AppServiceProvider.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\Categorie;
|
||||
use App\Models\Commande;
|
||||
use App\Models\Fournisseur;
|
||||
use App\Models\PieceJointe;
|
||||
use App\Models\User;
|
||||
use App\Policies\CommandePolicy;
|
||||
use App\Policies\FournisseurPolicy;
|
||||
use App\Policies\PieceJointePolicy;
|
||||
use App\Policies\UserPolicy;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\Facades\Vite;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected $policies = [
|
||||
Commande::class => CommandePolicy::class,
|
||||
Fournisseur::class => FournisseurPolicy::class,
|
||||
PieceJointe::class => PieceJointePolicy::class,
|
||||
User::class => UserPolicy::class,
|
||||
];
|
||||
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
$this->registerPolicies();
|
||||
Vite::prefetch(concurrency: 3);
|
||||
|
||||
// Les admins passent toutes les gates sauf les policies de user
|
||||
Gate::before(function (User $user, string $ability) {
|
||||
if ($user->hasRole('admin')) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// Gates pour catégories et services (pas de modèle dédié à une Policy)
|
||||
Gate::define('manage-categories', fn (User $user) => $user->hasAnyRole(['admin', 'responsable']));
|
||||
Gate::define('manage-services', fn (User $user) => $user->hasRole('admin'));
|
||||
}
|
||||
}
|
||||
18
artisan
Normal file
18
artisan
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
|
||||
define('LARAVEL_START', microtime(true));
|
||||
|
||||
// Register the Composer autoloader...
|
||||
require __DIR__.'/vendor/autoload.php';
|
||||
|
||||
// Bootstrap Laravel and handle the command...
|
||||
/** @var Application $app */
|
||||
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||
|
||||
$status = $app->handleCommand(new ArgvInput);
|
||||
|
||||
exit($status);
|
||||
26
bootstrap/app.php
Normal file
26
bootstrap/app.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Foundation\Configuration\Exceptions;
|
||||
use Illuminate\Foundation\Configuration\Middleware;
|
||||
|
||||
return Application::configure(basePath: dirname(__DIR__))
|
||||
->withRouting(
|
||||
web: __DIR__.'/../routes/web.php',
|
||||
commands: __DIR__.'/../routes/console.php',
|
||||
health: '/up',
|
||||
)
|
||||
->withMiddleware(function (Middleware $middleware): void {
|
||||
$middleware->web(append: [
|
||||
\App\Http\Middleware\HandleInertiaRequests::class,
|
||||
\Illuminate\Http\Middleware\AddLinkHeadersForPreloadedAssets::class,
|
||||
]);
|
||||
|
||||
$middleware->alias([
|
||||
'role' => \Spatie\Permission\Middleware\RoleMiddleware::class,
|
||||
'permission' => \Spatie\Permission\Middleware\PermissionMiddleware::class,
|
||||
]);
|
||||
})
|
||||
->withExceptions(function (Exceptions $exceptions): void {
|
||||
//
|
||||
})->create();
|
||||
2
bootstrap/cache/.gitignore
vendored
Normal file
2
bootstrap/cache/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
7
bootstrap/providers.php
Normal file
7
bootstrap/providers.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Providers\AppServiceProvider;
|
||||
|
||||
return [
|
||||
AppServiceProvider::class,
|
||||
];
|
||||
93
composer.json
Normal file
93
composer.json
Normal file
@@ -0,0 +1,93 @@
|
||||
{
|
||||
"$schema": "https://getcomposer.org/schema.json",
|
||||
"name": "laravel/laravel",
|
||||
"type": "project",
|
||||
"description": "The skeleton application for the Laravel framework.",
|
||||
"keywords": ["laravel", "framework"],
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^8.3",
|
||||
"barryvdh/laravel-dompdf": "^3.1",
|
||||
"inertiajs/inertia-laravel": "^2.0",
|
||||
"io-developer/php-whois": "^4.1",
|
||||
"laravel/framework": "^13.0",
|
||||
"laravel/sanctum": "^4.0",
|
||||
"laravel/tinker": "^3.0",
|
||||
"spatie/laravel-activitylog": "^4.11",
|
||||
"spatie/laravel-permission": "^7.1",
|
||||
"tightenco/ziggy": "^2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1.23",
|
||||
"laravel/breeze": "^2.3",
|
||||
"laravel/pail": "^1.2.5",
|
||||
"laravel/pint": "^1.27",
|
||||
"mockery/mockery": "^1.6",
|
||||
"nunomaduro/collision": "^8.6",
|
||||
"phpunit/phpunit": "^12.5.12"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "app/",
|
||||
"Database\\Factories\\": "database/factories/",
|
||||
"Database\\Seeders\\": "database/seeders/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"setup": [
|
||||
"composer install",
|
||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
|
||||
"@php artisan key:generate",
|
||||
"@php artisan migrate --force",
|
||||
"npm install --ignore-scripts",
|
||||
"npm run build"
|
||||
],
|
||||
"dev": [
|
||||
"Composer\\Config::disableProcessTimeout",
|
||||
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1 --timeout=0\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite --kill-others"
|
||||
],
|
||||
"test": [
|
||||
"@php artisan config:clear --ansi",
|
||||
"@php artisan test"
|
||||
],
|
||||
"post-autoload-dump": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
||||
"@php artisan package:discover --ansi"
|
||||
],
|
||||
"post-update-cmd": [
|
||||
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
|
||||
],
|
||||
"post-root-package-install": [
|
||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
||||
],
|
||||
"post-create-project-cmd": [
|
||||
"@php artisan key:generate --ansi",
|
||||
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
|
||||
"@php artisan migrate --graceful --ansi"
|
||||
],
|
||||
"pre-package-uninstall": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::prePackageUninstall"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"dont-discover": []
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true,
|
||||
"allow-plugins": {
|
||||
"pestphp/pest-plugin": true,
|
||||
"php-http/discovery": true
|
||||
}
|
||||
},
|
||||
"minimum-stability": "stable",
|
||||
"prefer-stable": true
|
||||
}
|
||||
9116
composer.lock
generated
Normal file
9116
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
126
config/app.php
Normal file
126
config/app.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value is the name of your application, which will be used when the
|
||||
| framework needs to place the application's name in a notification or
|
||||
| other UI elements where an application name needs to be displayed.
|
||||
|
|
||||
*/
|
||||
|
||||
'name' => env('APP_NAME', 'Laravel'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Environment
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value determines the "environment" your application is currently
|
||||
| running in. This may determine how you prefer to configure various
|
||||
| services the application utilizes. Set this in your ".env" file.
|
||||
|
|
||||
*/
|
||||
|
||||
'env' => env('APP_ENV', 'production'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Debug Mode
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When your application is in debug mode, detailed error messages with
|
||||
| stack traces will be shown on every error that occurs within your
|
||||
| application. If disabled, a simple generic error page is shown.
|
||||
|
|
||||
*/
|
||||
|
||||
'debug' => (bool) env('APP_DEBUG', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application URL
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This URL is used by the console to properly generate URLs when using
|
||||
| the Artisan command line tool. You should set this to the root of
|
||||
| the application so that it's available within Artisan commands.
|
||||
|
|
||||
*/
|
||||
|
||||
'url' => env('APP_URL', 'http://localhost'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Timezone
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the default timezone for your application, which
|
||||
| will be used by the PHP date and date-time functions. The timezone
|
||||
| is set to "UTC" by default as it is suitable for most use cases.
|
||||
|
|
||||
*/
|
||||
|
||||
'timezone' => 'UTC',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Locale Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The application locale determines the default locale that will be used
|
||||
| by Laravel's translation / localization methods. This option can be
|
||||
| set to any locale for which you plan to have translation strings.
|
||||
|
|
||||
*/
|
||||
|
||||
'locale' => env('APP_LOCALE', 'en'),
|
||||
|
||||
'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
|
||||
|
||||
'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Encryption Key
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This key is utilized by Laravel's encryption services and should be set
|
||||
| to a random, 32 character string to ensure that all encrypted values
|
||||
| are secure. You should do this prior to deploying the application.
|
||||
|
|
||||
*/
|
||||
|
||||
'cipher' => 'AES-256-CBC',
|
||||
|
||||
'key' => env('APP_KEY'),
|
||||
|
||||
'previous_keys' => [
|
||||
...array_filter(
|
||||
explode(',', (string) env('APP_PREVIOUS_KEYS', ''))
|
||||
),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Maintenance Mode Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These configuration options determine the driver used to determine and
|
||||
| manage Laravel's "maintenance mode" status. The "cache" driver will
|
||||
| allow maintenance mode to be controlled across multiple machines.
|
||||
|
|
||||
| Supported drivers: "file", "cache"
|
||||
|
|
||||
*/
|
||||
|
||||
'maintenance' => [
|
||||
'driver' => env('APP_MAINTENANCE_DRIVER', 'file'),
|
||||
'store' => env('APP_MAINTENANCE_STORE', 'database'),
|
||||
],
|
||||
|
||||
];
|
||||
117
config/auth.php
Normal file
117
config/auth.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Defaults
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option defines the default authentication "guard" and password
|
||||
| reset "broker" for your application. You may change these values
|
||||
| as required, but they're a perfect start for most applications.
|
||||
|
|
||||
*/
|
||||
|
||||
'defaults' => [
|
||||
'guard' => env('AUTH_GUARD', 'web'),
|
||||
'passwords' => env('AUTH_PASSWORD_BROKER', 'users'),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Guards
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Next, you may define every authentication guard for your application.
|
||||
| Of course, a great default configuration has been defined for you
|
||||
| which utilizes session storage plus the Eloquent user provider.
|
||||
|
|
||||
| All authentication guards have a user provider, which defines how the
|
||||
| users are actually retrieved out of your database or other storage
|
||||
| system used by the application. Typically, Eloquent is utilized.
|
||||
|
|
||||
| Supported: "session"
|
||||
|
|
||||
*/
|
||||
|
||||
'guards' => [
|
||||
'web' => [
|
||||
'driver' => 'session',
|
||||
'provider' => 'users',
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| User Providers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| All authentication guards have a user provider, which defines how the
|
||||
| users are actually retrieved out of your database or other storage
|
||||
| system used by the application. Typically, Eloquent is utilized.
|
||||
|
|
||||
| If you have multiple user tables or models you may configure multiple
|
||||
| providers to represent the model / table. These providers may then
|
||||
| be assigned to any extra authentication guards you have defined.
|
||||
|
|
||||
| Supported: "database", "eloquent"
|
||||
|
|
||||
*/
|
||||
|
||||
'providers' => [
|
||||
'users' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => env('AUTH_MODEL', User::class),
|
||||
],
|
||||
|
||||
// 'users' => [
|
||||
// 'driver' => 'database',
|
||||
// 'table' => 'users',
|
||||
// ],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Resetting Passwords
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These configuration options specify the behavior of Laravel's password
|
||||
| reset functionality, including the table utilized for token storage
|
||||
| and the user provider that is invoked to actually retrieve users.
|
||||
|
|
||||
| The expiry time is the number of minutes that each reset token will be
|
||||
| considered valid. This security feature keeps tokens short-lived so
|
||||
| they have less time to be guessed. You may change this as needed.
|
||||
|
|
||||
| The throttle setting is the number of seconds a user must wait before
|
||||
| generating more password reset tokens. This prevents the user from
|
||||
| quickly generating a very large amount of password reset tokens.
|
||||
|
|
||||
*/
|
||||
|
||||
'passwords' => [
|
||||
'users' => [
|
||||
'provider' => 'users',
|
||||
'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
|
||||
'expire' => 60,
|
||||
'throttle' => 60,
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Confirmation Timeout
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define the number of seconds before a password confirmation
|
||||
| window expires and users are asked to re-enter their password via the
|
||||
| confirmation screen. By default, the timeout lasts for three hours.
|
||||
|
|
||||
*/
|
||||
|
||||
'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800),
|
||||
|
||||
];
|
||||
130
config/cache.php
Normal file
130
config/cache.php
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Cache Store
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default cache store that will be used by the
|
||||
| framework. This connection is utilized if another isn't explicitly
|
||||
| specified when running a cache operation inside the application.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('CACHE_STORE', 'database'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Stores
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define all of the cache "stores" for your application as
|
||||
| well as their drivers. You may even define multiple stores for the
|
||||
| same cache driver to group types of items stored in your caches.
|
||||
|
|
||||
| Supported drivers: "array", "database", "file", "memcached",
|
||||
| "redis", "dynamodb", "octane",
|
||||
| "failover", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'stores' => [
|
||||
|
||||
'array' => [
|
||||
'driver' => 'array',
|
||||
'serialize' => false,
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'connection' => env('DB_CACHE_CONNECTION'),
|
||||
'table' => env('DB_CACHE_TABLE', 'cache'),
|
||||
'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'),
|
||||
'lock_table' => env('DB_CACHE_LOCK_TABLE'),
|
||||
],
|
||||
|
||||
'file' => [
|
||||
'driver' => 'file',
|
||||
'path' => storage_path('framework/cache/data'),
|
||||
'lock_path' => storage_path('framework/cache/data'),
|
||||
],
|
||||
|
||||
'memcached' => [
|
||||
'driver' => 'memcached',
|
||||
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
|
||||
'sasl' => [
|
||||
env('MEMCACHED_USERNAME'),
|
||||
env('MEMCACHED_PASSWORD'),
|
||||
],
|
||||
'options' => [
|
||||
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
|
||||
],
|
||||
'servers' => [
|
||||
[
|
||||
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
|
||||
'port' => env('MEMCACHED_PORT', 11211),
|
||||
'weight' => 100,
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => env('REDIS_CACHE_CONNECTION', 'cache'),
|
||||
'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'),
|
||||
],
|
||||
|
||||
'dynamodb' => [
|
||||
'driver' => 'dynamodb',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
|
||||
'endpoint' => env('DYNAMODB_ENDPOINT'),
|
||||
],
|
||||
|
||||
'octane' => [
|
||||
'driver' => 'octane',
|
||||
],
|
||||
|
||||
'failover' => [
|
||||
'driver' => 'failover',
|
||||
'stores' => [
|
||||
'database',
|
||||
'array',
|
||||
],
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Key Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When utilizing the APC, database, memcached, Redis, and DynamoDB cache
|
||||
| stores, there might be other applications using the same cache. For
|
||||
| that reason, you may prefix every cache key to avoid collisions.
|
||||
|
|
||||
*/
|
||||
|
||||
'prefix' => env('CACHE_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-cache-'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Serializable Classes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value determines the classes that can be unserialized from cache
|
||||
| storage. By default, no PHP classes will be unserialized from your
|
||||
| cache to prevent gadget chain attacks if your APP_KEY is leaked.
|
||||
|
|
||||
*/
|
||||
|
||||
'serializable_classes' => false,
|
||||
|
||||
];
|
||||
184
config/database.php
Normal file
184
config/database.php
Normal file
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Pdo\Mysql;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Database Connection Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify which of the database connections below you wish
|
||||
| to use as your default connection for database operations. This is
|
||||
| the connection which will be utilized unless another connection
|
||||
| is explicitly specified when you execute a query / statement.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('DB_CONNECTION', 'sqlite'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Database Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Below are all of the database connections defined for your application.
|
||||
| An example configuration is provided for each database system which
|
||||
| is supported by Laravel. You're free to add / remove connections.
|
||||
|
|
||||
*/
|
||||
|
||||
'connections' => [
|
||||
|
||||
'sqlite' => [
|
||||
'driver' => 'sqlite',
|
||||
'url' => env('DB_URL'),
|
||||
'database' => env('DB_DATABASE', database_path('database.sqlite')),
|
||||
'prefix' => '',
|
||||
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
|
||||
'busy_timeout' => null,
|
||||
'journal_mode' => null,
|
||||
'synchronous' => null,
|
||||
'transaction_mode' => 'DEFERRED',
|
||||
],
|
||||
|
||||
'mysql' => [
|
||||
'driver' => 'mysql',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '3306'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'unix_socket' => env('DB_SOCKET', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8mb4'),
|
||||
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'strict' => true,
|
||||
'engine' => null,
|
||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||
(PHP_VERSION_ID >= 80500 ? Mysql::ATTR_SSL_CA : PDO::MYSQL_ATTR_SSL_CA) => env('MYSQL_ATTR_SSL_CA'),
|
||||
]) : [],
|
||||
],
|
||||
|
||||
'mariadb' => [
|
||||
'driver' => 'mariadb',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '3306'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'unix_socket' => env('DB_SOCKET', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8mb4'),
|
||||
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'strict' => true,
|
||||
'engine' => null,
|
||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||
(PHP_VERSION_ID >= 80500 ? Mysql::ATTR_SSL_CA : PDO::MYSQL_ATTR_SSL_CA) => env('MYSQL_ATTR_SSL_CA'),
|
||||
]) : [],
|
||||
],
|
||||
|
||||
'pgsql' => [
|
||||
'driver' => 'pgsql',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '5432'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'search_path' => 'public',
|
||||
'sslmode' => env('DB_SSLMODE', 'prefer'),
|
||||
],
|
||||
|
||||
'sqlsrv' => [
|
||||
'driver' => 'sqlsrv',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', 'localhost'),
|
||||
'port' => env('DB_PORT', '1433'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
|
||||
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Migration Repository Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This table keeps track of all the migrations that have already run for
|
||||
| your application. Using this information, we can determine which of
|
||||
| the migrations on disk haven't actually been run on the database.
|
||||
|
|
||||
*/
|
||||
|
||||
'migrations' => [
|
||||
'table' => 'migrations',
|
||||
'update_date_on_publish' => true,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Redis Databases
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Redis is an open source, fast, and advanced key-value store that also
|
||||
| provides a richer body of commands than a typical key-value system
|
||||
| such as Memcached. You may define your connection settings here.
|
||||
|
|
||||
*/
|
||||
|
||||
'redis' => [
|
||||
|
||||
'client' => env('REDIS_CLIENT', 'phpredis'),
|
||||
|
||||
'options' => [
|
||||
'cluster' => env('REDIS_CLUSTER', 'redis'),
|
||||
'prefix' => env('REDIS_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-database-'),
|
||||
'persistent' => env('REDIS_PERSISTENT', false),
|
||||
],
|
||||
|
||||
'default' => [
|
||||
'url' => env('REDIS_URL'),
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_DB', '0'),
|
||||
'max_retries' => env('REDIS_MAX_RETRIES', 3),
|
||||
'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'),
|
||||
'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
|
||||
'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
|
||||
],
|
||||
|
||||
'cache' => [
|
||||
'url' => env('REDIS_URL'),
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_CACHE_DB', '1'),
|
||||
'max_retries' => env('REDIS_MAX_RETRIES', 3),
|
||||
'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'),
|
||||
'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
|
||||
'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
86
config/filesystems.php
Normal file
86
config/filesystems.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Filesystem Disk
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the default filesystem disk that should be used
|
||||
| by the framework. The "local" disk, as well as a variety of cloud
|
||||
| based disks are available to your application for file storage.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('FILESYSTEM_DISK', 'local'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Filesystem Disks
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Below you may configure as many filesystem disks as necessary, and you
|
||||
| may even configure multiple disks for the same driver. Examples for
|
||||
| most supported storage drivers are configured here for reference.
|
||||
|
|
||||
| Supported drivers: "local", "ftp", "sftp", "s3"
|
||||
|
|
||||
*/
|
||||
|
||||
'disks' => [
|
||||
|
||||
'local' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/private'),
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
'private' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/private'),
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
'public' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/public'),
|
||||
'url' => rtrim(env('APP_URL', 'http://localhost'), '/').'/storage',
|
||||
'visibility' => 'public',
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
's3' => [
|
||||
'driver' => 's3',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION'),
|
||||
'bucket' => env('AWS_BUCKET'),
|
||||
'url' => env('AWS_URL'),
|
||||
'endpoint' => env('AWS_ENDPOINT'),
|
||||
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Symbolic Links
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the symbolic links that will be created when the
|
||||
| `storage:link` Artisan command is executed. The array keys should be
|
||||
| the locations of the links and the values should be their targets.
|
||||
|
|
||||
*/
|
||||
|
||||
'links' => [
|
||||
public_path('storage') => storage_path('app/public'),
|
||||
],
|
||||
|
||||
];
|
||||
132
config/logging.php
Normal file
132
config/logging.php
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
use Monolog\Handler\NullHandler;
|
||||
use Monolog\Handler\StreamHandler;
|
||||
use Monolog\Handler\SyslogUdpHandler;
|
||||
use Monolog\Processor\PsrLogMessageProcessor;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Log Channel
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option defines the default log channel that is utilized to write
|
||||
| messages to your logs. The value provided here should match one of
|
||||
| the channels present in the list of "channels" configured below.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('LOG_CHANNEL', 'stack'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Deprecations Log Channel
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the log channel that should be used to log warnings
|
||||
| regarding deprecated PHP and library features. This allows you to get
|
||||
| your application ready for upcoming major versions of dependencies.
|
||||
|
|
||||
*/
|
||||
|
||||
'deprecations' => [
|
||||
'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
|
||||
'trace' => env('LOG_DEPRECATIONS_TRACE', false),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Log Channels
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the log channels for your application. Laravel
|
||||
| utilizes the Monolog PHP logging library, which includes a variety
|
||||
| of powerful log handlers and formatters that you're free to use.
|
||||
|
|
||||
| Available drivers: "single", "daily", "slack", "syslog",
|
||||
| "errorlog", "monolog", "custom", "stack"
|
||||
|
|
||||
*/
|
||||
|
||||
'channels' => [
|
||||
|
||||
'stack' => [
|
||||
'driver' => 'stack',
|
||||
'channels' => explode(',', (string) env('LOG_STACK', 'single')),
|
||||
'ignore_exceptions' => false,
|
||||
],
|
||||
|
||||
'single' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'daily' => [
|
||||
'driver' => 'daily',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'days' => env('LOG_DAILY_DAYS', 14),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'slack' => [
|
||||
'driver' => 'slack',
|
||||
'url' => env('LOG_SLACK_WEBHOOK_URL'),
|
||||
'username' => env('LOG_SLACK_USERNAME', env('APP_NAME', 'Laravel')),
|
||||
'emoji' => env('LOG_SLACK_EMOJI', ':boom:'),
|
||||
'level' => env('LOG_LEVEL', 'critical'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'papertrail' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
|
||||
'handler_with' => [
|
||||
'host' => env('PAPERTRAIL_URL'),
|
||||
'port' => env('PAPERTRAIL_PORT'),
|
||||
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
|
||||
],
|
||||
'processors' => [PsrLogMessageProcessor::class],
|
||||
],
|
||||
|
||||
'stderr' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => StreamHandler::class,
|
||||
'handler_with' => [
|
||||
'stream' => 'php://stderr',
|
||||
],
|
||||
'formatter' => env('LOG_STDERR_FORMATTER'),
|
||||
'processors' => [PsrLogMessageProcessor::class],
|
||||
],
|
||||
|
||||
'syslog' => [
|
||||
'driver' => 'syslog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'facility' => env('LOG_SYSLOG_FACILITY', LOG_USER),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'errorlog' => [
|
||||
'driver' => 'errorlog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'null' => [
|
||||
'driver' => 'monolog',
|
||||
'handler' => NullHandler::class,
|
||||
],
|
||||
|
||||
'emergency' => [
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
118
config/mail.php
Normal file
118
config/mail.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Mailer
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default mailer that is used to send all email
|
||||
| messages unless another mailer is explicitly specified when sending
|
||||
| the message. All additional mailers can be configured within the
|
||||
| "mailers" array. Examples of each type of mailer are provided.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('MAIL_MAILER', 'log'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Mailer Configurations
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure all of the mailers used by your application plus
|
||||
| their respective settings. Several examples have been configured for
|
||||
| you and you are free to add your own as your application requires.
|
||||
|
|
||||
| Laravel supports a variety of mail "transport" drivers that can be used
|
||||
| when delivering an email. You may specify which one you're using for
|
||||
| your mailers below. You may also add additional mailers if needed.
|
||||
|
|
||||
| Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2",
|
||||
| "postmark", "resend", "log", "array",
|
||||
| "failover", "roundrobin"
|
||||
|
|
||||
*/
|
||||
|
||||
'mailers' => [
|
||||
|
||||
'smtp' => [
|
||||
'transport' => 'smtp',
|
||||
'scheme' => env('MAIL_SCHEME'),
|
||||
'url' => env('MAIL_URL'),
|
||||
'host' => env('MAIL_HOST', '127.0.0.1'),
|
||||
'port' => env('MAIL_PORT', 2525),
|
||||
'username' => env('MAIL_USERNAME'),
|
||||
'password' => env('MAIL_PASSWORD'),
|
||||
'timeout' => null,
|
||||
'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url((string) env('APP_URL', 'http://localhost'), PHP_URL_HOST)),
|
||||
],
|
||||
|
||||
'ses' => [
|
||||
'transport' => 'ses',
|
||||
],
|
||||
|
||||
'postmark' => [
|
||||
'transport' => 'postmark',
|
||||
// 'message_stream_id' => env('POSTMARK_MESSAGE_STREAM_ID'),
|
||||
// 'client' => [
|
||||
// 'timeout' => 5,
|
||||
// ],
|
||||
],
|
||||
|
||||
'resend' => [
|
||||
'transport' => 'resend',
|
||||
],
|
||||
|
||||
'sendmail' => [
|
||||
'transport' => 'sendmail',
|
||||
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
|
||||
],
|
||||
|
||||
'log' => [
|
||||
'transport' => 'log',
|
||||
'channel' => env('MAIL_LOG_CHANNEL'),
|
||||
],
|
||||
|
||||
'array' => [
|
||||
'transport' => 'array',
|
||||
],
|
||||
|
||||
'failover' => [
|
||||
'transport' => 'failover',
|
||||
'mailers' => [
|
||||
'smtp',
|
||||
'log',
|
||||
],
|
||||
'retry_after' => 60,
|
||||
],
|
||||
|
||||
'roundrobin' => [
|
||||
'transport' => 'roundrobin',
|
||||
'mailers' => [
|
||||
'ses',
|
||||
'postmark',
|
||||
],
|
||||
'retry_after' => 60,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Global "From" Address
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| You may wish for all emails sent by your application to be sent from
|
||||
| the same address. Here you may specify a name and address that is
|
||||
| used globally for all emails that are sent by your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'from' => [
|
||||
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
|
||||
'name' => env('MAIL_FROM_NAME', env('APP_NAME', 'Laravel')),
|
||||
],
|
||||
|
||||
];
|
||||
202
config/permission.php
Normal file
202
config/permission.php
Normal file
@@ -0,0 +1,202 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
'models' => [
|
||||
|
||||
/*
|
||||
* When using the "HasPermissions" trait from this package, we need to know which
|
||||
* Eloquent model should be used to retrieve your permissions. Of course, it
|
||||
* is often just the "Permission" model but you may use whatever you like.
|
||||
*
|
||||
* The model you want to use as a Permission model needs to implement the
|
||||
* `Spatie\Permission\Contracts\Permission` contract.
|
||||
*/
|
||||
|
||||
'permission' => Spatie\Permission\Models\Permission::class,
|
||||
|
||||
/*
|
||||
* When using the "HasRoles" trait from this package, we need to know which
|
||||
* Eloquent model should be used to retrieve your roles. Of course, it
|
||||
* is often just the "Role" model but you may use whatever you like.
|
||||
*
|
||||
* The model you want to use as a Role model needs to implement the
|
||||
* `Spatie\Permission\Contracts\Role` contract.
|
||||
*/
|
||||
|
||||
'role' => Spatie\Permission\Models\Role::class,
|
||||
|
||||
],
|
||||
|
||||
'table_names' => [
|
||||
|
||||
/*
|
||||
* When using the "HasRoles" trait from this package, we need to know which
|
||||
* table should be used to retrieve your roles. We have chosen a basic
|
||||
* default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'roles' => 'roles',
|
||||
|
||||
/*
|
||||
* When using the "HasPermissions" trait from this package, we need to know which
|
||||
* table should be used to retrieve your permissions. We have chosen a basic
|
||||
* default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'permissions' => 'permissions',
|
||||
|
||||
/*
|
||||
* When using the "HasPermissions" trait from this package, we need to know which
|
||||
* table should be used to retrieve your models permissions. We have chosen a
|
||||
* basic default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'model_has_permissions' => 'model_has_permissions',
|
||||
|
||||
/*
|
||||
* When using the "HasRoles" trait from this package, we need to know which
|
||||
* table should be used to retrieve your models roles. We have chosen a
|
||||
* basic default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'model_has_roles' => 'model_has_roles',
|
||||
|
||||
/*
|
||||
* When using the "HasRoles" trait from this package, we need to know which
|
||||
* table should be used to retrieve your roles permissions. We have chosen a
|
||||
* basic default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'role_has_permissions' => 'role_has_permissions',
|
||||
],
|
||||
|
||||
'column_names' => [
|
||||
/*
|
||||
* Change this if you want to name the related pivots other than defaults
|
||||
*/
|
||||
'role_pivot_key' => null, // default 'role_id',
|
||||
'permission_pivot_key' => null, // default 'permission_id',
|
||||
|
||||
/*
|
||||
* Change this if you want to name the related model primary key other than
|
||||
* `model_id`.
|
||||
*
|
||||
* For example, this would be nice if your primary keys are all UUIDs. In
|
||||
* that case, name this `model_uuid`.
|
||||
*/
|
||||
|
||||
'model_morph_key' => 'model_id',
|
||||
|
||||
/*
|
||||
* Change this if you want to use the teams feature and your related model's
|
||||
* foreign key is other than `team_id`.
|
||||
*/
|
||||
|
||||
'team_foreign_key' => 'team_id',
|
||||
],
|
||||
|
||||
/*
|
||||
* When set to true, the method for checking permissions will be registered on the gate.
|
||||
* Set this to false if you want to implement custom logic for checking permissions.
|
||||
*/
|
||||
|
||||
'register_permission_check_method' => true,
|
||||
|
||||
/*
|
||||
* When set to true, Laravel\Octane\Events\OperationTerminated event listener will be registered
|
||||
* this will refresh permissions on every TickTerminated, TaskTerminated and RequestTerminated
|
||||
* NOTE: This should not be needed in most cases, but an Octane/Vapor combination benefited from it.
|
||||
*/
|
||||
'register_octane_reset_listener' => false,
|
||||
|
||||
/*
|
||||
* Events will fire when a role or permission is assigned/unassigned:
|
||||
* \Spatie\Permission\Events\RoleAttachedEvent
|
||||
* \Spatie\Permission\Events\RoleDetachedEvent
|
||||
* \Spatie\Permission\Events\PermissionAttachedEvent
|
||||
* \Spatie\Permission\Events\PermissionDetachedEvent
|
||||
*
|
||||
* To enable, set to true, and then create listeners to watch these events.
|
||||
*/
|
||||
'events_enabled' => false,
|
||||
|
||||
/*
|
||||
* Teams Feature.
|
||||
* When set to true the package implements teams using the 'team_foreign_key'.
|
||||
* If you want the migrations to register the 'team_foreign_key', you must
|
||||
* set this to true before doing the migration.
|
||||
* If you already did the migration then you must make a new migration to also
|
||||
* add 'team_foreign_key' to 'roles', 'model_has_roles', and 'model_has_permissions'
|
||||
* (view the latest version of this package's migration file)
|
||||
*/
|
||||
|
||||
'teams' => false,
|
||||
|
||||
/*
|
||||
* The class to use to resolve the permissions team id
|
||||
*/
|
||||
'team_resolver' => \Spatie\Permission\DefaultTeamResolver::class,
|
||||
|
||||
/*
|
||||
* Passport Client Credentials Grant
|
||||
* When set to true the package will use Passports Client to check permissions
|
||||
*/
|
||||
|
||||
'use_passport_client_credentials' => false,
|
||||
|
||||
/*
|
||||
* When set to true, the required permission names are added to exception messages.
|
||||
* This could be considered an information leak in some contexts, so the default
|
||||
* setting is false here for optimum safety.
|
||||
*/
|
||||
|
||||
'display_permission_in_exception' => false,
|
||||
|
||||
/*
|
||||
* When set to true, the required role names are added to exception messages.
|
||||
* This could be considered an information leak in some contexts, so the default
|
||||
* setting is false here for optimum safety.
|
||||
*/
|
||||
|
||||
'display_role_in_exception' => false,
|
||||
|
||||
/*
|
||||
* By default wildcard permission lookups are disabled.
|
||||
* See documentation to understand supported syntax.
|
||||
*/
|
||||
|
||||
'enable_wildcard_permission' => false,
|
||||
|
||||
/*
|
||||
* The class to use for interpreting wildcard permissions.
|
||||
* If you need to modify delimiters, override the class and specify its name here.
|
||||
*/
|
||||
// 'wildcard_permission' => Spatie\Permission\WildcardPermission::class,
|
||||
|
||||
/* Cache-specific settings */
|
||||
|
||||
'cache' => [
|
||||
|
||||
/*
|
||||
* By default all permissions are cached for 24 hours to speed up performance.
|
||||
* When permissions or roles are updated the cache is flushed automatically.
|
||||
*/
|
||||
|
||||
'expiration_time' => \DateInterval::createFromDateString('24 hours'),
|
||||
|
||||
/*
|
||||
* The cache key used to store all permissions.
|
||||
*/
|
||||
|
||||
'key' => 'spatie.permission.cache',
|
||||
|
||||
/*
|
||||
* You may optionally indicate a specific cache driver to use for permission and
|
||||
* role caching using any of the `store` drivers listed in the cache.php config
|
||||
* file. Using 'default' here means to use the `default` set in cache.php.
|
||||
*/
|
||||
|
||||
'store' => 'default',
|
||||
],
|
||||
];
|
||||
129
config/queue.php
Normal file
129
config/queue.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Queue Connection Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Laravel's queue supports a variety of backends via a single, unified
|
||||
| API, giving you convenient access to each backend using identical
|
||||
| syntax for each. The default queue connection is defined below.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('QUEUE_CONNECTION', 'database'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Queue Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the connection options for every queue backend
|
||||
| used by your application. An example configuration is provided for
|
||||
| each backend supported by Laravel. You're also free to add more.
|
||||
|
|
||||
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis",
|
||||
| "deferred", "background", "failover", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'connections' => [
|
||||
|
||||
'sync' => [
|
||||
'driver' => 'sync',
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'connection' => env('DB_QUEUE_CONNECTION'),
|
||||
'table' => env('DB_QUEUE_TABLE', 'jobs'),
|
||||
'queue' => env('DB_QUEUE', 'default'),
|
||||
'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90),
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'beanstalkd' => [
|
||||
'driver' => 'beanstalkd',
|
||||
'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'),
|
||||
'queue' => env('BEANSTALKD_QUEUE', 'default'),
|
||||
'retry_after' => (int) env('BEANSTALKD_QUEUE_RETRY_AFTER', 90),
|
||||
'block_for' => 0,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'sqs' => [
|
||||
'driver' => 'sqs',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
|
||||
'queue' => env('SQS_QUEUE', 'default'),
|
||||
'suffix' => env('SQS_SUFFIX'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => env('REDIS_QUEUE_CONNECTION', 'default'),
|
||||
'queue' => env('REDIS_QUEUE', 'default'),
|
||||
'retry_after' => (int) env('REDIS_QUEUE_RETRY_AFTER', 90),
|
||||
'block_for' => null,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'deferred' => [
|
||||
'driver' => 'deferred',
|
||||
],
|
||||
|
||||
'background' => [
|
||||
'driver' => 'background',
|
||||
],
|
||||
|
||||
'failover' => [
|
||||
'driver' => 'failover',
|
||||
'connections' => [
|
||||
'database',
|
||||
'deferred',
|
||||
],
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Job Batching
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following options configure the database and table that store job
|
||||
| batching information. These options can be updated to any database
|
||||
| connection and table which has been defined by your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'batching' => [
|
||||
'database' => env('DB_CONNECTION', 'sqlite'),
|
||||
'table' => 'job_batches',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Failed Queue Jobs
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These options configure the behavior of failed queue job logging so you
|
||||
| can control how and where failed jobs are stored. Laravel ships with
|
||||
| support for storing failed jobs in a simple file or in a database.
|
||||
|
|
||||
| Supported drivers: "database-uuids", "dynamodb", "file", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'failed' => [
|
||||
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
|
||||
'database' => env('DB_CONNECTION', 'sqlite'),
|
||||
'table' => 'failed_jobs',
|
||||
],
|
||||
|
||||
];
|
||||
38
config/services.php
Normal file
38
config/services.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Third Party Services
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This file is for storing the credentials for third party services such
|
||||
| as Mailgun, Postmark, AWS and more. This file provides the de facto
|
||||
| location for this type of information, allowing packages to have
|
||||
| a conventional file to locate the various service credentials.
|
||||
|
|
||||
*/
|
||||
|
||||
'postmark' => [
|
||||
'key' => env('POSTMARK_API_KEY'),
|
||||
],
|
||||
|
||||
'resend' => [
|
||||
'key' => env('RESEND_API_KEY'),
|
||||
],
|
||||
|
||||
'ses' => [
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
],
|
||||
|
||||
'slack' => [
|
||||
'notifications' => [
|
||||
'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),
|
||||
'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'),
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
233
config/session.php
Normal file
233
config/session.php
Normal file
@@ -0,0 +1,233 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Session Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option determines the default session driver that is utilized for
|
||||
| incoming requests. Laravel supports a variety of storage options to
|
||||
| persist session data. Database storage is a great default choice.
|
||||
|
|
||||
| Supported: "file", "cookie", "database", "memcached",
|
||||
| "redis", "dynamodb", "array"
|
||||
|
|
||||
*/
|
||||
|
||||
'driver' => env('SESSION_DRIVER', 'database'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Lifetime
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the number of minutes that you wish the session
|
||||
| to be allowed to remain idle before it expires. If you want them
|
||||
| to expire immediately when the browser is closed then you may
|
||||
| indicate that via the expire_on_close configuration option.
|
||||
|
|
||||
*/
|
||||
|
||||
'lifetime' => (int) env('SESSION_LIFETIME', 120),
|
||||
|
||||
'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Encryption
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option allows you to easily specify that all of your session data
|
||||
| should be encrypted before it's stored. All encryption is performed
|
||||
| automatically by Laravel and you may use the session like normal.
|
||||
|
|
||||
*/
|
||||
|
||||
'encrypt' => env('SESSION_ENCRYPT', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session File Location
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When utilizing the "file" session driver, the session files are placed
|
||||
| on disk. The default storage location is defined here; however, you
|
||||
| are free to provide another location where they should be stored.
|
||||
|
|
||||
*/
|
||||
|
||||
'files' => storage_path('framework/sessions'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Database Connection
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the "database" or "redis" session drivers, you may specify a
|
||||
| connection that should be used to manage these sessions. This should
|
||||
| correspond to a connection in your database configuration options.
|
||||
|
|
||||
*/
|
||||
|
||||
'connection' => env('SESSION_CONNECTION'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Database Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the "database" session driver, you may specify the table to
|
||||
| be used to store sessions. Of course, a sensible default is defined
|
||||
| for you; however, you're welcome to change this to another table.
|
||||
|
|
||||
*/
|
||||
|
||||
'table' => env('SESSION_TABLE', 'sessions'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cache Store
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using one of the framework's cache driven session backends, you may
|
||||
| define the cache store which should be used to store the session data
|
||||
| between requests. This must match one of your defined cache stores.
|
||||
|
|
||||
| Affects: "dynamodb", "memcached", "redis"
|
||||
|
|
||||
*/
|
||||
|
||||
'store' => env('SESSION_STORE'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Sweeping Lottery
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Some session drivers must manually sweep their storage location to get
|
||||
| rid of old sessions from storage. Here are the chances that it will
|
||||
| happen on a given request. By default, the odds are 2 out of 100.
|
||||
|
|
||||
*/
|
||||
|
||||
'lottery' => [2, 100],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may change the name of the session cookie that is created by
|
||||
| the framework. Typically, you should not need to change this value
|
||||
| since doing so does not grant a meaningful security improvement.
|
||||
|
|
||||
*/
|
||||
|
||||
'cookie' => env(
|
||||
'SESSION_COOKIE',
|
||||
Str::slug((string) env('APP_NAME', 'laravel')).'-session'
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The session cookie path determines the path for which the cookie will
|
||||
| be regarded as available. Typically, this will be the root path of
|
||||
| your application, but you're free to change this when necessary.
|
||||
|
|
||||
*/
|
||||
|
||||
'path' => env('SESSION_PATH', '/'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Domain
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value determines the domain and subdomains the session cookie is
|
||||
| available to. By default, the cookie will be available to the root
|
||||
| domain without subdomains. Typically, this shouldn't be changed.
|
||||
|
|
||||
*/
|
||||
|
||||
'domain' => env('SESSION_DOMAIN'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| HTTPS Only Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| By setting this option to true, session cookies will only be sent back
|
||||
| to the server if the browser has a HTTPS connection. This will keep
|
||||
| the cookie from being sent to you when it can't be done securely.
|
||||
|
|
||||
*/
|
||||
|
||||
'secure' => env('SESSION_SECURE_COOKIE'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| HTTP Access Only
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Setting this value to true will prevent JavaScript from accessing the
|
||||
| value of the cookie and the cookie will only be accessible through
|
||||
| the HTTP protocol. It's unlikely you should disable this option.
|
||||
|
|
||||
*/
|
||||
|
||||
'http_only' => env('SESSION_HTTP_ONLY', true),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Same-Site Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option determines how your cookies behave when cross-site requests
|
||||
| take place, and can be used to mitigate CSRF attacks. By default, we
|
||||
| will set this value to "lax" to permit secure cross-site requests.
|
||||
|
|
||||
| See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value
|
||||
|
|
||||
| Supported: "lax", "strict", "none", null
|
||||
|
|
||||
*/
|
||||
|
||||
'same_site' => env('SESSION_SAME_SITE', 'lax'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Partitioned Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Setting this value to true will tie the cookie to the top-level site for
|
||||
| a cross-site context. Partitioned cookies are accepted by the browser
|
||||
| when flagged "secure" and the Same-Site attribute is set to "none".
|
||||
|
|
||||
*/
|
||||
|
||||
'partitioned' => env('SESSION_PARTITIONED_COOKIE', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Serialization
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value controls the serialization strategy for session data, which
|
||||
| is JSON by default. Setting this to "php" allows the storage of PHP
|
||||
| objects in the session but can make an application vulnerable to
|
||||
| "gadget chain" serialization attacks if the APP_KEY is leaked.
|
||||
|
|
||||
| Supported: "json", "php"
|
||||
|
|
||||
*/
|
||||
|
||||
'serialization' => 'json',
|
||||
|
||||
];
|
||||
1
database/.gitignore
vendored
Normal file
1
database/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.sqlite*
|
||||
45
database/factories/UserFactory.php
Normal file
45
database/factories/UserFactory.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<User>
|
||||
*/
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The current password being used by the factory.
|
||||
*/
|
||||
protected static ?string $password;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*/
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
49
database/migrations/0001_01_01_000000_create_users_table.php
Normal file
49
database/migrations/0001_01_01_000000_create_users_table.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?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('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||
$table->string('email')->primary();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->foreignId('user_id')->nullable()->index();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->longText('payload');
|
||||
$table->integer('last_activity')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
Schema::dropIfExists('password_reset_tokens');
|
||||
Schema::dropIfExists('sessions');
|
||||
}
|
||||
};
|
||||
35
database/migrations/0001_01_01_000001_create_cache_table.php
Normal file
35
database/migrations/0001_01_01_000001_create_cache_table.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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('cache', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->mediumText('value');
|
||||
$table->bigInteger('expiration')->index();
|
||||
});
|
||||
|
||||
Schema::create('cache_locks', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->string('owner');
|
||||
$table->bigInteger('expiration')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('cache');
|
||||
Schema::dropIfExists('cache_locks');
|
||||
}
|
||||
};
|
||||
57
database/migrations/0001_01_01_000002_create_jobs_table.php
Normal file
57
database/migrations/0001_01_01_000002_create_jobs_table.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?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('jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedTinyInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
});
|
||||
|
||||
Schema::create('job_batches', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->string('name');
|
||||
$table->integer('total_jobs');
|
||||
$table->integer('pending_jobs');
|
||||
$table->integer('failed_jobs');
|
||||
$table->longText('failed_job_ids');
|
||||
$table->mediumText('options')->nullable();
|
||||
$table->integer('cancelled_at')->nullable();
|
||||
$table->integer('created_at');
|
||||
$table->integer('finished_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('uuid')->unique();
|
||||
$table->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('jobs');
|
||||
Schema::dropIfExists('job_batches');
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('services', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('nom')->unique();
|
||||
$table->text('description')->nullable();
|
||||
$table->string('couleur', 7)->nullable()->default('#3B82F6');
|
||||
$table->string('icone', 50)->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('services');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->foreignId('service_id')->nullable()->after('id')->constrained('services')->nullOnDelete();
|
||||
$table->string('telephone', 20)->nullable()->after('email');
|
||||
$table->boolean('active')->default(true)->after('telephone');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropForeign(['service_id']);
|
||||
$table->dropColumn(['service_id', 'telephone', 'active']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('fournisseurs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('nom');
|
||||
$table->string('raison_sociale')->nullable();
|
||||
$table->string('siret', 14)->nullable();
|
||||
$table->text('adresse')->nullable();
|
||||
$table->string('code_postal', 10)->nullable();
|
||||
$table->string('ville')->nullable();
|
||||
$table->string('telephone', 20)->nullable();
|
||||
$table->string('email')->nullable();
|
||||
$table->string('contact_commercial')->nullable();
|
||||
$table->string('email_commercial')->nullable();
|
||||
$table->string('telephone_commercial', 20)->nullable();
|
||||
$table->string('site_web')->nullable();
|
||||
$table->text('notes')->nullable();
|
||||
$table->boolean('active')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('fournisseurs');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('categories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('nom')->unique();
|
||||
$table->text('description')->nullable();
|
||||
$table->string('couleur', 7)->nullable();
|
||||
$table->string('icone', 50)->nullable();
|
||||
$table->unsignedInteger('ordre')->default(0);
|
||||
$table->boolean('active')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('categories');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('articles', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('reference')->nullable();
|
||||
$table->string('designation');
|
||||
$table->text('description')->nullable();
|
||||
$table->foreignId('categorie_id')->nullable()->constrained('categories')->nullOnDelete();
|
||||
$table->foreignId('fournisseur_id')->nullable()->constrained('fournisseurs')->nullOnDelete();
|
||||
$table->decimal('prix_unitaire_ht', 10, 2)->nullable();
|
||||
$table->string('unite', 30)->default('unité');
|
||||
$table->boolean('active')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('articles');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('commandes', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('numero_commande')->unique();
|
||||
|
||||
$table->foreignId('service_id')->constrained('services')->restrictOnDelete();
|
||||
$table->foreignId('fournisseur_id')->nullable()->constrained('fournisseurs')->nullOnDelete();
|
||||
$table->foreignId('user_id')->constrained('users')->restrictOnDelete();
|
||||
$table->foreignId('validateur_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->foreignId('acheteur_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
|
||||
$table->string('objet');
|
||||
$table->text('description')->nullable();
|
||||
$table->text('justification')->nullable();
|
||||
|
||||
$table->enum('statut', [
|
||||
'brouillon',
|
||||
'en_attente_validation',
|
||||
'validee',
|
||||
'commandee',
|
||||
'partiellement_recue',
|
||||
'recue_complete',
|
||||
'cloturee',
|
||||
'annulee',
|
||||
])->default('brouillon');
|
||||
|
||||
$table->enum('priorite', ['normale', 'haute', 'urgente'])->default('normale');
|
||||
|
||||
$table->string('reference_fournisseur')->nullable();
|
||||
$table->string('imputation_budgetaire')->nullable();
|
||||
|
||||
$table->decimal('montant_ht', 10, 2)->nullable();
|
||||
$table->decimal('montant_ttc', 10, 2)->nullable();
|
||||
|
||||
$table->date('date_demande');
|
||||
$table->date('date_souhaitee')->nullable();
|
||||
$table->datetime('date_validation')->nullable();
|
||||
$table->datetime('date_commande')->nullable();
|
||||
$table->date('date_livraison_prevue')->nullable();
|
||||
$table->datetime('date_reception')->nullable();
|
||||
$table->datetime('date_reception_complete')->nullable();
|
||||
$table->datetime('date_cloture')->nullable();
|
||||
|
||||
$table->text('notes')->nullable();
|
||||
$table->text('notes_fournisseur')->nullable();
|
||||
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('commandes');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('lignes_commande', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('commande_id')->constrained('commandes')->cascadeOnDelete();
|
||||
$table->foreignId('article_id')->nullable()->constrained('articles')->nullOnDelete();
|
||||
$table->foreignId('categorie_id')->nullable()->constrained('categories')->nullOnDelete();
|
||||
|
||||
$table->string('designation');
|
||||
$table->string('reference')->nullable();
|
||||
$table->decimal('quantite', 10, 3)->default(1);
|
||||
$table->decimal('quantite_recue', 10, 3)->default(0);
|
||||
$table->string('unite', 30)->default('unité');
|
||||
$table->decimal('prix_unitaire_ht', 10, 2)->nullable();
|
||||
$table->decimal('taux_tva', 5, 2)->default(20.00);
|
||||
$table->decimal('montant_ht', 10, 2)->nullable();
|
||||
$table->decimal('montant_ttc', 10, 2)->nullable();
|
||||
$table->text('notes')->nullable();
|
||||
$table->unsignedInteger('ordre')->default(0);
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('lignes_commande');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('historique_commandes', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('commande_id')->constrained('commandes')->cascadeOnDelete();
|
||||
$table->foreignId('user_id')->constrained('users')->restrictOnDelete();
|
||||
$table->string('ancien_statut')->nullable();
|
||||
$table->string('nouveau_statut');
|
||||
$table->text('commentaire')->nullable();
|
||||
$table->timestamp('created_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('historique_commandes');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('pieces_jointes', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('commande_id')->constrained('commandes')->cascadeOnDelete();
|
||||
$table->foreignId('user_id')->constrained('users')->restrictOnDelete();
|
||||
|
||||
$table->enum('type', [
|
||||
'devis',
|
||||
'bon_commande',
|
||||
'bon_livraison',
|
||||
'facture',
|
||||
'autre',
|
||||
]);
|
||||
|
||||
$table->string('nom_original'); // nom du fichier tel qu'uploadé
|
||||
$table->string('chemin'); // chemin dans storage/app/private
|
||||
$table->string('mime_type', 100);
|
||||
$table->unsignedBigInteger('taille'); // en octets
|
||||
$table->text('description')->nullable();
|
||||
|
||||
$table->timestamp('created_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('pieces_jointes');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,137 @@
|
||||
<?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
|
||||
{
|
||||
$teams = config('permission.teams');
|
||||
$tableNames = config('permission.table_names');
|
||||
$columnNames = config('permission.column_names');
|
||||
$pivotRole = $columnNames['role_pivot_key'] ?? 'role_id';
|
||||
$pivotPermission = $columnNames['permission_pivot_key'] ?? 'permission_id';
|
||||
|
||||
throw_if(empty($tableNames), 'Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||
throw_if($teams && empty($columnNames['team_foreign_key'] ?? null), 'Error: team_foreign_key on config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||
|
||||
/**
|
||||
* See `docs/prerequisites.md` for suggested lengths on 'name' and 'guard_name' if "1071 Specified key was too long" errors are encountered.
|
||||
*/
|
||||
Schema::create($tableNames['permissions'], static function (Blueprint $table) {
|
||||
$table->id(); // permission id
|
||||
$table->string('name');
|
||||
$table->string('guard_name');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['name', 'guard_name']);
|
||||
});
|
||||
|
||||
/**
|
||||
* See `docs/prerequisites.md` for suggested lengths on 'name' and 'guard_name' if "1071 Specified key was too long" errors are encountered.
|
||||
*/
|
||||
Schema::create($tableNames['roles'], static function (Blueprint $table) use ($teams, $columnNames) {
|
||||
$table->id(); // role id
|
||||
if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable();
|
||||
$table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index');
|
||||
}
|
||||
$table->string('name');
|
||||
$table->string('guard_name');
|
||||
$table->timestamps();
|
||||
if ($teams || config('permission.testing')) {
|
||||
$table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']);
|
||||
} else {
|
||||
$table->unique(['name', 'guard_name']);
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create($tableNames['model_has_permissions'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotPermission, $teams) {
|
||||
$table->unsignedBigInteger($pivotPermission);
|
||||
|
||||
$table->string('model_type');
|
||||
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
||||
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index');
|
||||
|
||||
$table->foreign($pivotPermission)
|
||||
->references('id') // permission id
|
||||
->on($tableNames['permissions'])
|
||||
->cascadeOnDelete();
|
||||
if ($teams) {
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
||||
$table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index');
|
||||
|
||||
$table->primary([$columnNames['team_foreign_key'], $pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_permissions_permission_model_type_primary');
|
||||
} else {
|
||||
$table->primary([$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_permissions_permission_model_type_primary');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create($tableNames['model_has_roles'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotRole, $teams) {
|
||||
$table->unsignedBigInteger($pivotRole);
|
||||
|
||||
$table->string('model_type');
|
||||
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
||||
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index');
|
||||
|
||||
$table->foreign($pivotRole)
|
||||
->references('id') // role id
|
||||
->on($tableNames['roles'])
|
||||
->cascadeOnDelete();
|
||||
if ($teams) {
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
||||
$table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index');
|
||||
|
||||
$table->primary([$columnNames['team_foreign_key'], $pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_roles_role_model_type_primary');
|
||||
} else {
|
||||
$table->primary([$pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_roles_role_model_type_primary');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create($tableNames['role_has_permissions'], static function (Blueprint $table) use ($tableNames, $pivotRole, $pivotPermission) {
|
||||
$table->unsignedBigInteger($pivotPermission);
|
||||
$table->unsignedBigInteger($pivotRole);
|
||||
|
||||
$table->foreign($pivotPermission)
|
||||
->references('id') // permission id
|
||||
->on($tableNames['permissions'])
|
||||
->cascadeOnDelete();
|
||||
|
||||
$table->foreign($pivotRole)
|
||||
->references('id') // role id
|
||||
->on($tableNames['roles'])
|
||||
->cascadeOnDelete();
|
||||
|
||||
$table->primary([$pivotPermission, $pivotRole], 'role_has_permissions_permission_id_role_id_primary');
|
||||
});
|
||||
|
||||
app('cache')
|
||||
->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
|
||||
->forget(config('permission.cache.key'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
$tableNames = config('permission.table_names');
|
||||
|
||||
throw_if(empty($tableNames), 'Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.');
|
||||
|
||||
Schema::dropIfExists($tableNames['role_has_permissions']);
|
||||
Schema::dropIfExists($tableNames['model_has_roles']);
|
||||
Schema::dropIfExists($tableNames['model_has_permissions']);
|
||||
Schema::dropIfExists($tableNames['roles']);
|
||||
Schema::dropIfExists($tableNames['permissions']);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateActivityLogTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->create(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('log_name')->nullable();
|
||||
$table->text('description');
|
||||
$table->nullableMorphs('subject', 'subject');
|
||||
$table->nullableMorphs('causer', 'causer');
|
||||
$table->json('properties')->nullable();
|
||||
$table->timestamps();
|
||||
$table->index('log_name');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->dropIfExists(config('activitylog.table_name'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddEventColumnToActivityLogTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->string('event')->nullable()->after('subject_type');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->dropColumn('event');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddBatchUuidColumnToActivityLogTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->uuid('batch_uuid')->nullable()->after('properties');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->dropColumn('batch_uuid');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?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('contrats', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('titre');
|
||||
$table->text('description')->nullable();
|
||||
$table->foreignId('fournisseur_id')->constrained('fournisseurs')->onDelete('cascade');
|
||||
$table->foreignId('service_id')->constrained('services')->onDelete('cascade');
|
||||
$table->date('date_debut')->nullable();
|
||||
$table->date('date_echeance');
|
||||
$table->enum('statut', ['actif', 'a_renouveler', 'expire', 'resilie'])->default('actif');
|
||||
$table->decimal('montant', 10, 2)->nullable();
|
||||
$table->integer('preavis_jours')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('contrats');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?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('pieces_jointes', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('commande_id')->nullable()->change();
|
||||
$table->foreignId('contrat_id')->nullable()->after('commande_id')->constrained('contrats')->cascadeOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('pieces_jointes', function (Blueprint $table) {
|
||||
$table->dropForeign(['contrat_id']);
|
||||
$table->dropColumn('contrat_id');
|
||||
// Reverting commande_id to non-nullable might fail if there are records where it is null.
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?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('domaines', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('nom')->unique();
|
||||
$table->date('date_echeance')->nullable();
|
||||
$table->text('prestataire')->nullable();
|
||||
$table->string('hebergeur')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('domaines');
|
||||
}
|
||||
};
|
||||
25
database/seeders/AdminUserSeeder.php
Normal file
25
database/seeders/AdminUserSeeder.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use App\Models\User;
|
||||
|
||||
class AdminUserSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$admin = User::firstOrCreate(
|
||||
['email' => 'admin@dsi.local'],
|
||||
[
|
||||
'name' => 'Administrateur',
|
||||
'password' => Hash::make('password'),
|
||||
'email_verified_at' => now(),
|
||||
'active' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$admin->assignRole('admin');
|
||||
}
|
||||
}
|
||||
29
database/seeders/CategorieSeeder.php
Normal file
29
database/seeders/CategorieSeeder.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CategorieSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$categories = [
|
||||
['nom' => 'Serveurs', 'couleur' => '#EF4444', 'icone' => 'server', 'ordre' => 1],
|
||||
['nom' => 'Ordinateurs', 'couleur' => '#3B82F6', 'icone' => 'computer', 'ordre' => 2],
|
||||
['nom' => 'Périphériques', 'couleur' => '#F59E0B', 'icone' => 'device', 'ordre' => 3],
|
||||
['nom' => 'Licences', 'couleur' => '#10B981', 'icone' => 'key', 'ordre' => 4],
|
||||
['nom' => 'Accessoires', 'couleur' => '#8B5CF6', 'icone' => 'package', 'ordre' => 5],
|
||||
['nom' => 'Autres', 'couleur' => '#6B7280', 'icone' => 'archive', 'ordre' => 6],
|
||||
];
|
||||
|
||||
foreach ($categories as $cat) {
|
||||
DB::table('categories')->insertOrIgnore(array_merge($cat, [
|
||||
'active' => true,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]));
|
||||
}
|
||||
}
|
||||
}
|
||||
18
database/seeders/DatabaseSeeder.php
Normal file
18
database/seeders/DatabaseSeeder.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$this->call([
|
||||
ServiceSeeder::class,
|
||||
CategorieSeeder::class,
|
||||
RolesPermissionsSeeder::class,
|
||||
AdminUserSeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
20
database/seeders/RolesPermissionsSeeder.php
Normal file
20
database/seeders/RolesPermissionsSeeder.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class RolesPermissionsSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
app()[\Spatie\Permission\PermissionRegistrar::class]->forgetCachedPermissions();
|
||||
|
||||
$roles = ['admin', 'responsable', 'acheteur', 'lecteur'];
|
||||
|
||||
foreach ($roles as $role) {
|
||||
Role::firstOrCreate(['name' => $role, 'guard_name' => 'web']);
|
||||
}
|
||||
}
|
||||
}
|
||||
25
database/seeders/ServiceSeeder.php
Normal file
25
database/seeders/ServiceSeeder.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ServiceSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$services = [
|
||||
['nom' => 'Relation Utilisateurs', 'description' => 'Service chargé des relations avec les utilisateurs et du support.', 'couleur' => '#3B82F6', 'icone' => 'users'],
|
||||
['nom' => 'Infrastructure', 'description' => 'Service infrastructure réseau, serveurs et systèmes.', 'couleur' => '#10B981', 'icone' => 'server'],
|
||||
['nom' => 'Études Projets', 'description' => 'Service études, développement et gestion de projets SI.', 'couleur' => '#8B5CF6', 'icone' => 'briefcase'],
|
||||
];
|
||||
|
||||
foreach ($services as $service) {
|
||||
DB::table('services')->insertOrIgnore(array_merge($service, [
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]));
|
||||
}
|
||||
}
|
||||
}
|
||||
10
jsconfig.json
Normal file
10
jsconfig.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["resources/js/*"],
|
||||
"ziggy-js": ["./vendor/tightenco/ziggy"]
|
||||
}
|
||||
},
|
||||
"exclude": ["node_modules", "public"]
|
||||
}
|
||||
3343
package-lock.json
generated
Normal file
3343
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
23
package.json
Normal file
23
package.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"$schema": "https://www.schemastore.org/package.json",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "vite build",
|
||||
"dev": "vite"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@inertiajs/vue3": "^2.0.0",
|
||||
"@tailwindcss/forms": "^0.5.3",
|
||||
"@tailwindcss/vite": "^4.0.0",
|
||||
"@vitejs/plugin-vue": "^6.0.0",
|
||||
"autoprefixer": "^10.4.12",
|
||||
"axios": ">=1.11.0 <=1.14.0",
|
||||
"concurrently": "^9.0.1",
|
||||
"laravel-vite-plugin": "^3.0.0",
|
||||
"postcss": "^8.4.31",
|
||||
"tailwindcss": "^3.2.1",
|
||||
"vite": "^8.0.0",
|
||||
"vue": "^3.4.0"
|
||||
}
|
||||
}
|
||||
36
phpunit.xml
Normal file
36
phpunit.xml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
|
||||
bootstrap="vendor/autoload.php"
|
||||
colors="true"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Unit">
|
||||
<directory>tests/Unit</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Feature">
|
||||
<directory>tests/Feature</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<source>
|
||||
<include>
|
||||
<directory>app</directory>
|
||||
</include>
|
||||
</source>
|
||||
<php>
|
||||
<env name="APP_ENV" value="testing"/>
|
||||
<env name="APP_MAINTENANCE_DRIVER" value="file"/>
|
||||
<env name="BCRYPT_ROUNDS" value="4"/>
|
||||
<env name="BROADCAST_CONNECTION" value="null"/>
|
||||
<env name="CACHE_STORE" value="array"/>
|
||||
<env name="DB_CONNECTION" value="sqlite"/>
|
||||
<env name="DB_DATABASE" value=":memory:"/>
|
||||
<env name="DB_URL" value=""/>
|
||||
<env name="MAIL_MAILER" value="array"/>
|
||||
<env name="QUEUE_CONNECTION" value="sync"/>
|
||||
<env name="SESSION_DRIVER" value="array"/>
|
||||
<env name="PULSE_ENABLED" value="false"/>
|
||||
<env name="TELESCOPE_ENABLED" value="false"/>
|
||||
<env name="NIGHTWATCH_ENABLED" value="false"/>
|
||||
</php>
|
||||
</phpunit>
|
||||
6
postcss.config.js
Normal file
6
postcss.config.js
Normal file
@@ -0,0 +1,6 @@
|
||||
export default {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
};
|
||||
25
public/.htaccess
Normal file
25
public/.htaccess
Normal file
@@ -0,0 +1,25 @@
|
||||
<IfModule mod_rewrite.c>
|
||||
<IfModule mod_negotiation.c>
|
||||
Options -MultiViews -Indexes
|
||||
</IfModule>
|
||||
|
||||
RewriteEngine On
|
||||
|
||||
# Handle Authorization Header
|
||||
RewriteCond %{HTTP:Authorization} .
|
||||
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
||||
|
||||
# Handle X-XSRF-Token Header
|
||||
RewriteCond %{HTTP:x-xsrf-token} .
|
||||
RewriteRule .* - [E=HTTP_X_XSRF_TOKEN:%{HTTP:X-XSRF-Token}]
|
||||
|
||||
# Redirect Trailing Slashes If Not A Folder...
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_URI} (.+)/$
|
||||
RewriteRule ^ %1 [L,R=301]
|
||||
|
||||
# Send Requests To Front Controller...
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^ index.php [L]
|
||||
</IfModule>
|
||||
0
public/favicon.ico
Normal file
0
public/favicon.ico
Normal file
20
public/index.php
Normal file
20
public/index.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
define('LARAVEL_START', microtime(true));
|
||||
|
||||
// Determine if the application is in maintenance mode...
|
||||
if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) {
|
||||
require $maintenance;
|
||||
}
|
||||
|
||||
// Register the Composer autoloader...
|
||||
require __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
// Bootstrap Laravel and handle the request...
|
||||
/** @var Application $app */
|
||||
$app = require_once __DIR__.'/../bootstrap/app.php';
|
||||
|
||||
$app->handleRequest(Request::capture());
|
||||
2
public/robots.txt
Normal file
2
public/robots.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
User-agent: *
|
||||
Disallow:
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user