feat(api): implement tracer bullet for employees and OpenAPI specification

This commit is contained in:
Jérémy Munsch 2026-08-12 15:45:29 +02:00
parent ecb6eca475
commit 34169a9feb
Signed by: forge-joniko
GPG key ID: D7EFE2F5CB6CC0E4
194 changed files with 20484 additions and 92 deletions

35
.editorconfig Normal file
View file

@ -0,0 +1,35 @@
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.{php,json}]
indent_size = 4
[*.blade.php]
indent_size = 2
[*.{yml,yaml}]
indent_size = 2
[{compose,docker-compose}.{yml,yaml}]
indent_size = 2
[*.scss]
indent_size = 2
quote_type = single
[*.css]
indent_size = 2
quote_type = single
[*.vue]
indent_size = 2

82
.env.example Normal file
View file

@ -0,0 +1,82 @@
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_URL=
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=laravel
# DB_USERNAME=root
# DB_PASSWORD=
# DB_SOCKET=
# DB_CHARSET=utf8mb4
# DB_COLLATION=utf8mb4_unicode_ci
# MYSQL_ATTR_SSL_CA=
ARCADIA_DB_CONNECTION=mysql
# ARCADIA_DB_URL=
ARCADIA_DB_HOST=127.0.0.1
ARCADIA_DB_PORT=3306
ARCADIA_DB=arcadia
ARCADIA_DB_USERNAME=root
ARCADIA_DB_PASSWORD=
# ARCADIA_DB_SOCKET=
# ARCADIA_DB_CHARSET=utf8mb4
# ARCADIA_DB_COLLATION=utf8mb4_unicode_ci
# ARCADIA_DB_SSL_CA=
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}"

38
.env.testing Normal file
View file

@ -0,0 +1,38 @@
APP_NAME="Arcadia Api"
APP_ENV=testing
APP_KEY=base64:2ik2NRSDu8/Lxsxzdnnom3xWEglXe+cGd/7beOt/eXY=
APP_DEBUG=true
APP_URL=http://localhost
APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US
APP_MAINTENANCE_DRIVER=file
BCRYPT_ROUNDS=4
LOG_CHANNEL=stack
LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=sqlite
DB_DATABASE=:memory:
ARCADIA_DB_CONNECTION=sqlite
SESSION_DRIVER=array
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
BROADCAST_CONNECTION=null
FILESYSTEM_DISK=local
QUEUE_CONNECTION=sync
CACHE_STORE=array
MAIL_MAILER=array
SPEC_PATH=documentation/OpenApi
PULSE_ENABLED=false
TELESCOPE_ENABLED=false
NIGHTWATCH_ENABLED=false

11
.gitattributes vendored Normal file
View 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

27
.gitignore vendored Normal file
View file

@ -0,0 +1,27 @@
*.log
.DS_Store
.env
.env.backup
.env.production
.phpactor.json
.phpunit.result.cache
/.codex
/.cursor/
/.idea
/.nova
/.phpunit.cache
/.vscode
/.zed
/auth.json
/node_modules
/public/build
/public/fonts-manifest.dev.json
/public/hot
/public/storage
/storage/*.key
/storage/pail
/vendor
_ide_helper.php
Homestead.json
Homestead.yaml
Thumbs.db

View file

@ -0,0 +1,57 @@
<?php
namespace {
/**
* Runs the given closure after each test in the current file.
*
* @param-closure-this \Tests\TestCase|\PHPUnit\Framework\TestCase $closure
*/
function afterEach(?Closure $closure = null): \Pest\PendingCalls\AfterEachCall {}
/**
* Runs the given closure before each test in the current file.
*
* @param-closure-this \Tests\TestCase|\PHPUnit\Framework\TestCase $closure
*/
function beforeEach(?Closure $closure = null): \Pest\PendingCalls\BeforeEachCall {}
/**
* Adds the given closure as a test. The first argument
* is the test description; the second argument is
* a closure that contains the test expectations.
*
* @param-closure-this \Tests\TestCase|\PHPUnit\Framework\TestCase $closure
*
* @return ($description is string ? TestCall : HigherOrderTapProxy|TestCall)
*/
function test(?string $description = null, ?Closure $closure = null): \Pest\Support\HigherOrderTapProxy|\Pest\PendingCalls\TestCall {}
/**
* Adds the given closure as a test. The first argument
* is the test description; the second argument is
* a closure that contains the test expectations.
*
* @param-closure-this \Tests\TestCase|\PHPUnit\Framework\TestCase $closure
*/
function it(string $description, ?Closure $closure = null): \Pest\PendingCalls\TestCall {}
}
namespace Tests {
class TestCase
{
use \Illuminate\Foundation\Testing\RefreshDatabase;
}
}
namespace Tests {
class TestCase
{
use \Illuminate\Foundation\Testing\RefreshDatabase;
}
}

View file

@ -1,93 +1 @@
# Arcadia Api
## Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
* [Create](https://docs.gitlab.com/user/project/repository/web_editor/#create-a-file) or [upload](https://docs.gitlab.com/user/project/repository/web_editor/#upload-a-file) files
* [Add files using the command line](https://docs.gitlab.com/topics/git/add_files/#add-files-to-a-git-repository) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin https://lab.s-web.fr/arcadia/arcadia-api.git
git branch -M main
git push -uf origin main
```
## Integrate with your tools
* [Set up project integrations](https://lab.s-web.fr/arcadia/arcadia-api/-/settings/integrations)
## Collaborate with your team
* [Invite team members and collaborators](https://docs.gitlab.com/user/project/members/)
* [Create a new merge request](https://docs.gitlab.com/user/project/merge_requests/creating_merge_requests/)
* [Automatically close issues from merge requests](https://docs.gitlab.com/user/project/issues/managing_issues/#closing-issues-automatically)
* [Enable merge request approvals](https://docs.gitlab.com/user/project/merge_requests/approvals/)
* [Set auto-merge](https://docs.gitlab.com/user/project/merge_requests/auto_merge/)
## Test and Deploy
Use the built-in continuous integration in GitLab.
* [Get started with GitLab CI/CD](https://docs.gitlab.com/ci/quick_start/)
* [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/user/application_security/sast/)
* [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/topics/autodevops/requirements/)
* [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/user/clusters/agent/)
* [Set up protected environments](https://docs.gitlab.com/ci/environments/protected_environments/)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.

18
artisan Executable file
View 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);

45
bootstrap/app.php Normal file
View file

@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Http\Request;
use Illuminate\Support\Env;
use Presentation\Api\Exceptions\ApiExceptionDispatcher;
use Presentation\Web\Exceptions\WebExceptionRenderer;
use Sentry\State\HubInterface;
return Application::configure(Env::get('APP_BASE_PATH', dirname(__DIR__)))
->withRouting(
web: __DIR__ . '/../routes/web.php',
api: __DIR__ . '/../routes/api.php',
commands: __DIR__ . '/../routes/console.php',
health: '/up',
)
->withMiddleware(require __DIR__ . '/middlewares.php')
->withExceptions(function (Exceptions $exceptions): void {
$exceptions->reportable(function (\Throwable $e): void {
if (app()->bound(HubInterface::class)) {
resolve(HubInterface::class)->captureException($e);
}
});
$exceptions->render(function (\Throwable $e, Request $request) {
$apiDispatcher = resolve(ApiExceptionDispatcher::class);
if ($apiResponse = $apiDispatcher->render($e, $request)) {
return $apiResponse;
}
$webRenderer = resolve(WebExceptionRenderer::class);
if ($webResponse = $webRenderer->render($e, $request)) {
return $webResponse;
}
return null;
});
$exceptions->shouldRenderJsonWhen(
fn (Request $request) => $request->is('api/*'),
);
})->create();

2
bootstrap/cache/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*
!.gitignore

12
bootstrap/middlewares.php Normal file
View file

@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
use Illuminate\Foundation\Configuration\Middleware;
use Infra\Http\Middleware\VerifyHmacSignature;
return function (Middleware $middleware): void {
$middleware->alias([
'auth.hmac' => VerifyHmacSignature::class,
]);
};

11
bootstrap/providers.php Normal file
View file

@ -0,0 +1,11 @@
<?php
declare(strict_types=1);
use Infra\Providers\AppServiceProvider;
use Infra\Providers\DomainServiceProvider;
return [
DomainServiceProvider::class,
AppServiceProvider::class,
];

111
composer.json Normal file
View file

@ -0,0 +1,111 @@
{
"$schema": "https://getcomposer.org/schema.json",
"name": "uwil/arcadia-api",
"description": "Arcadia Api in order to abstract corporate metamodel to a proper and stable implemented api",
"type": "project",
"license": "MIT",
"require": {
"driftingly/rector-laravel": "^2.5",
"laravel/framework": "^13.24",
"laravel/sanctum": "^4.0",
"league/uri": "^7.8",
"sentry/sentry-laravel": "^4.27"
},
"require-dev": {
"ace-of-aces/intellipest": "^1.0",
"barryvdh/laravel-ide-helper": "^3.7",
"fakerphp/faker": "^1.23",
"hotmeteor/spectator": "^3.0",
"larastan/larastan": "^3.10",
"laravel/pail": "^1.2.5",
"laravel/pao": "^1.0.6",
"laravel/pint": "^1.30",
"mockery/mockery": "^1.6",
"nunomaduro/collision": "^8.6",
"nunomaduro/mock-final-classes": "^1.2",
"pestphp/pest": "^4.7",
"pestphp/pest-plugin-faker": "^4.0",
"pestphp/pest-plugin-laravel": "^4.1",
"pestphp/pest-plugin-type-coverage": "^4.0",
"php-parallel-lint/php-parallel-lint": "^1.4",
"phpunit/phpunit": "^12.5.12",
"slevomat/coding-standard": "^8.31"
},
"autoload": {
"psr-4": {
"Application\\": "src/Application/",
"Domain\\": "src/Domain/",
"Infra\\": "src/Infra/",
"Presentation\\": "src/Presentation/",
"Shared\\": "src/Shared/"
}
},
"autoload-dev": {
"psr-4": {
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/",
"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 @no_additional_args",
"@php artisan test"
],
"lint": [
"vendor/bin/parallel-lint --exclude vendor --exclude storage --exclude bootstrap --exclude node_modules .",
"vendor/bin/phpcs --standard=phpcs.xml --extensions=php --ignore=vendor/*,storage/*,bootstrap/*,node_modules/*",
"vendor/bin/phpstan analyse",
"vendor/bin/pint --test"
],
"analyse": "vendor/bin/phpstan analyse",
"format": "vendor/bin/pint",
"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": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"pestphp/pest-plugin": true,
"php-http/discovery": true
}
},
"minimum-stability": "stable",
"prefer-stable": true
}

11763
composer.lock generated Normal file

File diff suppressed because it is too large Load diff

128
config/app.php Normal file
View file

@ -0,0 +1,128 @@
<?php
declare(strict_types=1);
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'),
],
];

119
config/auth.php Normal file
View file

@ -0,0 +1,119 @@
<?php
declare(strict_types=1);
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),
];

138
config/cache.php Normal file
View file

@ -0,0 +1,138 @@
<?php
declare(strict_types=1);
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", "storage", "octane",
| "session", "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'),
],
'storage' => [
'driver' => 'storage',
'disk' => env('CACHE_STORAGE_DISK'),
'path' => env('CACHE_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,
];

208
config/database.php Normal file
View file

@ -0,0 +1,208 @@
<?php
declare(strict_types=1);
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'),
'arcadia_meta_model' => env('ARCADIA_DB_CONNECTION', 'arcadia'),
/*
|--------------------------------------------------------------------------
| 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' => [
'arcadia' => [
'driver' => 'mariadb',
'url' => env('ARCADIA_DB_URL'),
'host' => env('ARCADIA_DB_HOST', '127.0.0.1'),
'port' => env('ARCADIA_DB_PORT', '3306'),
'database' => env('ARCADIA_DB', 'arcadia'),
'username' => env('ARCADIA_DB_USERNAME', 'root'),
'password' => env('ARCADIA_DB_PASSWORD', ''),
'unix_socket' => env('ARCADIA_DB_SOCKET', ''),
'charset' => env('ARCADIA_DB_CHARSET', 'utf8mb4'),
'collation' => env('ARCADIA_DB_COLLATION', 'utf8mb4_unicode_ci'),
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
Mysql::ATTR_SSL_CA => env('ARCADIA_DB_SSL_CA'),
]) : [],
],
'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([
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([
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),
],
],
];

82
config/filesystems.php Normal file
View file

@ -0,0 +1,82 @@
<?php
declare(strict_types=1);
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'),
'serve' => true,
'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'),
],
];

379
config/ide-helper.php Normal file
View file

@ -0,0 +1,379 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Client\Factory;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Session\Store;
return [
/*
|--------------------------------------------------------------------------
| Filename
|--------------------------------------------------------------------------
|
| The default filename.
|
*/
'filename' => '_ide_helper.php',
/*
|--------------------------------------------------------------------------
| Models filename
|--------------------------------------------------------------------------
|
| The default filename for the models helper file.
|
*/
'models_filename' => '_ide_helper_models.php',
/*
|--------------------------------------------------------------------------
| PhpStorm meta filename
|--------------------------------------------------------------------------
|
| PhpStorm also supports the directory `.phpstorm.meta.php/` with arbitrary
| files in it, should you need additional files for your project; e.g.
| `.phpstorm.meta.php/laravel_ide_Helper.php'.
|
*/
'meta_filename' => '.phpstorm.meta.php',
/*
|--------------------------------------------------------------------------
| Fluent helpers
|--------------------------------------------------------------------------
|
| Set to true to generate commonly used Fluent methods.
|
*/
'include_fluent' => false,
/*
|--------------------------------------------------------------------------
| Write model query methods
|--------------------------------------------------------------------------
|
| Set to false to disable generated docs for the 'query()', 'newQuery()' and 'newModelQuery()' methods.
|
*/
'write_query_methods' => false,
/*
|--------------------------------------------------------------------------
| Write model magic methods
|--------------------------------------------------------------------------
|
| Set to false to disable write magic methods of model.
|
*/
'write_model_magic_where' => false,
/*
|--------------------------------------------------------------------------
| Write model external Eloquent builder methods
|--------------------------------------------------------------------------
|
| Set to false to disable write external Eloquent builder methods.
|
*/
'write_model_external_builder_methods' => false,
/*
|--------------------------------------------------------------------------
| Write model relation count and exists properties
|--------------------------------------------------------------------------
|
| Set to false to disable writing of relation count and exists properties
| to model DocBlocks.
|
*/
'write_model_relation_count_properties' => false,
'write_model_relation_exists_properties' => false,
/*
|--------------------------------------------------------------------------
| Write Eloquent model mixins
|--------------------------------------------------------------------------
|
| This will add the necessary DocBlock mixins to the model class
| contained in the Laravel framework. This helps the IDE with
| auto-completion.
|
| Please be aware that this setting changes a file within the /vendor directory.
|
*/
'write_eloquent_model_mixins' => false,
/*
|--------------------------------------------------------------------------
| Helper files to include
|--------------------------------------------------------------------------
|
| Include helper files. By default not included, but can be toggled with the
| -- helpers (-H) option. Extra helper files can be included.
|
*/
'include_helpers' => false,
'helper_files' => [
base_path() . '/vendor/laravel/framework/src/Illuminate/Support/helpers.php',
base_path() . '/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php',
],
/*
|--------------------------------------------------------------------------
| Model locations to include
|--------------------------------------------------------------------------
|
| Define in which directories the ide-helper:models command should look
| for models.
|
| glob patterns are supported to easier reach models in sub-directories,
| e.g. `app/Services/* /Models` (without the space).
|
*/
'model_locations' => [
'src/Presentation',
],
/*
|--------------------------------------------------------------------------
| Models to ignore
|--------------------------------------------------------------------------
|
| Define which models should be ignored.
|
*/
'ignored_models' => [],
/*
|--------------------------------------------------------------------------
| Models hooks
|--------------------------------------------------------------------------
|
| Define which hook classes you want to run for models to add custom information.
|
| Hooks should implement Barryvdh\LaravelIdeHelper\Contracts\ModelHookInterface.
|
*/
'model_hooks' => [
// App\Support\IdeHelper\MyModelHook::class
],
/*
|--------------------------------------------------------------------------
| Extra classes
|--------------------------------------------------------------------------
|
| These implementations are not really extended, but called with magic functions.
|
*/
'extra' => [
'Eloquent' => [Builder::class, \Illuminate\Database\Query\Builder::class],
'Session' => [Store::class],
],
'magic' => [],
/*
|--------------------------------------------------------------------------
| Interface implementations
|--------------------------------------------------------------------------
|
| These interfaces will be replaced with the implementing class. Some interfaces
| are detected by the helpers, others can be listed below.
|
*/
'interfaces' => [
// App\MyInterface::class => App\MyImplementation::class,
],
/*
|--------------------------------------------------------------------------
| Support for camel cased models
|--------------------------------------------------------------------------
|
| There are some Laravel packages (such as Eloquence) that allow for accessing
| Eloquent model properties via camel case, instead of snake case.
|
| Enabling this option will support these packages by saving all model
| properties as camel case, instead of snake case.
|
| For example, normally you would see this:
|
| * @property \Illuminate\Support\Carbon $created_at
| * @property \Illuminate\Support\Carbon $updated_at
|
| With this enabled, the properties will be this:
|
| * @property \Illuminate\Support\Carbon $createdAt
| * @property \Illuminate\Support\Carbon $updatedAt
|
| Note, it is currently an all-or-nothing option.
|
*/
'model_camel_case_properties' => false,
/*
|--------------------------------------------------------------------------
| Property casts
|--------------------------------------------------------------------------
|
| Cast the given "real type" to the given "type".
|
*/
'type_overrides' => [
'integer' => 'int',
'boolean' => 'bool',
],
/*
|--------------------------------------------------------------------------
| Include DocBlocks from classes
|--------------------------------------------------------------------------
|
| Include DocBlocks from classes to allow additional code inspection for
| magic methods and properties.
|
*/
'include_class_docblocks' => false,
/*
|--------------------------------------------------------------------------
| Force FQN usage
|--------------------------------------------------------------------------
|
| Use the fully qualified (class) name in DocBlocks,
| even if the class exists in the same namespace
| or there is an import (use className) of the class.
|
*/
'force_fqn' => false,
/*
|--------------------------------------------------------------------------
| Use generics syntax
|--------------------------------------------------------------------------
|
| Use generics syntax within DocBlocks,
| e.g. `Collection<User>` instead of `Collection|User[]`.
|
*/
'use_generics_annotations' => true,
/*
|--------------------------------------------------------------------------
| Default return types for macros
|--------------------------------------------------------------------------
|
| Define default return types for macros without explicit return types.
| e.g. `\Illuminate\Database\Query\Builder::class => 'static'`,
| `\Illuminate\Support\Str::class => 'string'`
|
*/
'macro_default_return_types' => [
Factory::class => PendingRequest::class,
],
/*
|--------------------------------------------------------------------------
| Additional relation types
|--------------------------------------------------------------------------
|
| Sometimes it's needed to create custom relation types. The key of the array
| is the relationship method name. The value of the array is the fully-qualified
| class name of the relationship, e.g. `'relationName' => RelationShipClass::class`.
|
*/
'additional_relation_types' => [],
/*
|--------------------------------------------------------------------------
| Additional relation return types
|--------------------------------------------------------------------------
|
| When using custom relation types its possible for the class name to not contain
| the proper return type of the relation. The key of the array is the relationship
| method name. The value of the array is the return type of the relation ('many'
| or 'morphTo').
| e.g. `'relationName' => 'many'`.
|
*/
'additional_relation_return_types' => [],
/*
|--------------------------------------------------------------------------
| Enforce nullable Eloquent relationships on not null columns
|--------------------------------------------------------------------------
|
| When set to true (default), this option enforces nullable Eloquent relationships.
| However, in cases where the application logic ensures the presence of related
| records it may be desirable to set this option to false to avoid unwanted null warnings.
|
| Default: true
| A not null column with no foreign key constraint will have a "nullable" relationship.
| * @property int $not_null_column_with_no_foreign_key_constraint
| * @property-read BelongsToVariation|null $notNullColumnWithNoForeignKeyConstraint
|
| Option: false
| A not null column with no foreign key constraint will have a "not nullable" relationship.
| * @property int $not_null_column_with_no_foreign_key_constraint
| * @property-read BelongsToVariation $notNullColumnWithNoForeignKeyConstraint
|
*/
'enforce_nullable_relationships' => true,
/*
|--------------------------------------------------------------------------
| Make soft deletable relations nullable
|--------------------------------------------------------------------------
|
| When set to true (default), relationships to models using SoftDeletes trait
| will be marked as nullable. This is because soft-deleted records are excluded
| from queries by default, meaning even non-nullable foreign keys can return
| null when the related model is soft-deleted.
|
| Default: true
| A relationship to a soft-deletable model will include |null in the type:
| * @property-read Team|null $team
|
| Option: false
| A relationship to a soft-deletable model will NOT include |null (unless
| nullable for other reasons such as nullable foreign key column):
| * @property-read Team $team
|
*/
'soft_deletes_force_nullable' => true,
/*
|--------------------------------------------------------------------------
| Run artisan commands after migrations to generate model helpers
|--------------------------------------------------------------------------
|
| The specified commands should run after migrations are finished running.
|
*/
'post_migrate' => [
// 'ide-helper:models --nowrite',
],
];

134
config/logging.php Normal file
View file

@ -0,0 +1,134 @@
<?php
declare(strict_types=1);
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'),
],
],
];

120
config/mail.php Normal file
View file

@ -0,0 +1,120 @@
<?php
declare(strict_types=1);
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')),
],
];

131
config/queue.php Normal file
View file

@ -0,0 +1,131 @@
<?php
declare(strict_types=1);
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',
],
];

89
config/sanctum.php Normal file
View file

@ -0,0 +1,89 @@
<?php
declare(strict_types=1);
use Illuminate\Cookie\Middleware\EncryptCookies;
use Illuminate\Foundation\Http\Middleware\ValidateCsrfToken;
use Laravel\Sanctum\Http\Middleware\AuthenticateSession;
use Laravel\Sanctum\Sanctum;
return [
/*
|--------------------------------------------------------------------------
| Stateful Domains
|--------------------------------------------------------------------------
|
| Requests from the following domains / hosts will receive stateful API
| authentication cookies. Typically, these should include your local
| and production domains which access your API via a frontend SPA.
|
*/
'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
'%s%s',
'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
Sanctum::currentApplicationUrlWithPort(),
// Sanctum::currentRequestHost(),
))),
/*
|--------------------------------------------------------------------------
| Sanctum Guards
|--------------------------------------------------------------------------
|
| This array contains the authentication guards that will be checked when
| Sanctum is trying to authenticate a request. If none of these guards
| are able to authenticate the request, Sanctum will use the bearer
| token that's present on an incoming request for authentication.
|
*/
'guard' => ['web'],
/*
|--------------------------------------------------------------------------
| Expiration Minutes
|--------------------------------------------------------------------------
|
| This value controls the number of minutes until an issued token will be
| considered expired. This will override any values set in the token's
| "expires_at" attribute, but first-party sessions are not affected.
|
*/
'expiration' => null,
/*
|--------------------------------------------------------------------------
| Token Prefix
|--------------------------------------------------------------------------
|
| Sanctum can prefix new tokens in order to take advantage of numerous
| security scanning initiatives maintained by open source platforms
| that notify developers if they commit tokens into repositories.
|
| See: https://docs.github.com/en/code-security/secret-scanning/about-secret-scanning
|
*/
'token_prefix' => env('SANCTUM_TOKEN_PREFIX', ''),
/*
|--------------------------------------------------------------------------
| Sanctum Middleware
|--------------------------------------------------------------------------
|
| When authenticating your first-party SPA with Sanctum you may need to
| customize some of the middleware Sanctum uses while processing the
| request. You may change the middleware listed below as required.
|
*/
'middleware' => [
'authenticate_session' => AuthenticateSession::class,
'encrypt_cookies' => EncryptCookies::class,
'validate_csrf_token' => ValidateCsrfToken::class,
],
];

40
config/services.php Normal file
View file

@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
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'),
],
],
];

235
config/session.php Normal file
View file

@ -0,0 +1,235 @@
<?php
declare(strict_types=1);
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',
];

83
config/spectator.php Normal file
View file

@ -0,0 +1,83 @@
<?php
declare(strict_types=1);
return [
/*
|--------------------------------------------------------------------------
| Default Spec Source
|--------------------------------------------------------------------------
|
| Here you may specify the default spec source that should be used
| by the framework.
|
*/
'default' => env('SPEC_SOURCE', 'local'),
/*
|--------------------------------------------------------------------------
| Sources
|--------------------------------------------------------------------------
|
| Here you may configure as many sources as you wish, and you
| may even configure multiple source of the same type. Defaults have
| been setup for each driver as an example of the required options.
|
*/
'sources' => [
'local' => [
'source' => 'local',
'base_path' => env('SPEC_PATH'),
],
'remote' => [
'source' => 'remote',
'base_path' => env('SPEC_PATH'),
'params' => env('SPEC_URL_PARAMS', ''),
],
'github' => [
'source' => 'github',
'base_path' => env('SPEC_GITHUB_PATH'),
'repo' => env('SPEC_GITHUB_REPO'),
'token' => env('SPEC_GITHUB_TOKEN'),
],
],
/*
|--------------------------------------------------------------------------
| Paths
|--------------------------------------------------------------------------
|
| Configure path defaults, like prefixes.
|
*/
'path_prefix' => 'api/v1',
/*
|--------------------------------------------------------------------------
| Error Format
|--------------------------------------------------------------------------
|
| Controls the format of schema validation error messages in test output.
| Use 'text' (default) for human-readable coloured terminal output, or
| 'json' for machine-readable output suited to CI log parsers and LLMs.
|
| You can also call Spectator::useJsonErrors() / useTextErrors() per-test.
|
*/
'error_format' => env('SPECTATOR_ERROR_FORMAT', 'text'),
/*
|--------------------------------------------------------------------------
|
| Specify the groups that spectator's middleware should be prepended to.
|
*/
'middleware_groups' => ['api'],
];

38
config/view.php Normal file
View file

@ -0,0 +1,38 @@
<?php
declare(strict_types=1);
return [
/*
|--------------------------------------------------------------------------
| View Storage Paths
|--------------------------------------------------------------------------
|
| Most templating systems load templates from disk. Here you may specify
| an array of paths that should be checked for your views. Of course
| the usual Laravel view path has already been registered for you.
|
*/
'paths' => [
base_path('src/Presentation/Web/resources/views'),
],
/*
|--------------------------------------------------------------------------
| Compiled View Path
|--------------------------------------------------------------------------
|
| This option determines where all the compiled Blade templates will be
| stored for your application. Typically, this is within the storage
| directory. However, as usual, you are free to change this value.
|
*/
'compiled' => env(
'VIEW_COMPILED_PATH',
realpath(storage_path('framework/views'))
),
];

1
database/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
*.sqlite*

View file

@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Infra\Database\Models\Employee;
/**
* @extends Factory<Employee>
*/
final class EmployeeFactory extends Factory
{
protected $model = Employee::class;
/**
* @return array<string, mixed>
*/
#[\Override]
public function definition(): array
{
return [
'public_employee_number' => (string) fake()->unique()->numberBetween(1000000, 9999999),
'last_name' => strtoupper(fake()->lastName()),
'first_name' => fake()->firstName(),
'start_date' => '2024-01-15',
'end_date' => null,
'planned_end_date' => null,
'establishment' => '01',
'site' => 'LDCSER',
'service' => '097',
];
}
}

View file

@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
namespace Database\Factories;
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,
]);
}
}

View file

@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
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');
}
};

View file

@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
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');
}
};

View file

@ -0,0 +1,61 @@
<?php
declare(strict_types=1);
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->unsignedSmallInteger('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->string('connection');
$table->string('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
$table->index(['connection', 'queue', 'failed_at']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('jobs');
Schema::dropIfExists('job_batches');
Schema::dropIfExists('failed_jobs');
}
};

View file

@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
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('personal_access_tokens', function (Blueprint $table) {
$table->id();
$table->morphs('tokenable');
$table->text('name');
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();
$table->timestamp('last_used_at')->nullable();
$table->timestamp('expires_at')->nullable()->index();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('personal_access_tokens');
}
};

View file

@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
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('api_clients', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('name');
$table->string('identifier')->unique();
$table->string('secret');
$table->boolean('is_active');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('api_clients');
}
};

View file

@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$schema = Schema::connection(Config::string('database.arcadia_meta_model'));
$schema->dropIfExists('employees');
$schema->create('employees', function (Blueprint $table) {
$table->string('public_employee_number', 8)->primary();
$table->string('last_name');
$table->string('first_name');
$table->date('start_date');
$table->date('end_date')->nullable();
$table->date('planned_end_date')->nullable();
$table->string('establishment', 20);
$table->string('site', 20);
$table->string('service', 20);
$table->timestamps();
$table->index('site');
$table->index('service');
$table->index('establishment');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::connection(Config::string('database.arcadia_meta_model'))
->dropIfExists('employees');
}
};

View file

@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
use WithoutModelEvents;
/**
* Seed the application's database.
*/
public function run(): void
{
$this->call(EmployeeSeeder::class);
}
}

View file

@ -0,0 +1,84 @@
<?php
declare(strict_types=1);
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Infra\Database\Models\Employee;
final class EmployeeSeeder extends Seeder
{
/**
* Seed the application's database.
*/
public function run(): void
{
$timestamp = now();
Employee::query()->upsert([
[
'public_employee_number' => '01155902',
'last_name' => 'DOE',
'first_name' => 'John',
'start_date' => '2024-01-15',
'end_date' => null,
'planned_end_date' => null,
'establishment' => '01',
'site' => 'LDCSER',
'service' => '097',
'created_at' => $timestamp,
'updated_at' => $timestamp,
],
[
'public_employee_number' => '1234567',
'last_name' => 'MARTIN',
'first_name' => 'Alice',
'start_date' => '2024-01-08',
'end_date' => null,
'planned_end_date' => null,
'establishment' => 'LY',
'site' => 'LDCSER',
'service' => '101',
'created_at' => $timestamp,
'updated_at' => $timestamp,
],
[
'public_employee_number' => '2345678',
'last_name' => 'DUPONT',
'first_name' => 'Louis',
'start_date' => '2023-05-15',
'end_date' => null,
'planned_end_date' => '2026-12-31',
'establishment' => 'PA',
'site' => 'SLELA',
'service' => '097',
'created_at' => $timestamp,
'updated_at' => $timestamp,
],
[
'public_employee_number' => '3456789',
'last_name' => 'BERNARD',
'first_name' => 'Nora',
'start_date' => '2022-09-01',
'end_date' => null,
'planned_end_date' => null,
'establishment' => 'BO',
'site' => 'DDE',
'service' => '205',
'created_at' => $timestamp,
'updated_at' => $timestamp,
],
], ['public_employee_number'], [
'last_name',
'first_name',
'start_date',
'end_date',
'planned_end_date',
'establishment',
'site',
'service',
'updated_at',
]);
}
}

View file

@ -0,0 +1,9 @@
# Secrets
.env*
# Dependencies
node_modules
# OS files
.DS_Store
Thumbs.db

View file

@ -0,0 +1,15 @@
info:
name: Api Root
type: http
seq: 2
http:
method: GET
url: "{{ENDPOINT}}/api/"
auth: inherit
settings:
encodeUrl: true
timeout: 0
followRedirects: true
maxRedirects: 5

View file

@ -0,0 +1,19 @@
info:
name: Get Employee
type: http
seq: 2
http:
method: GET
url: "{{ENDPOINT}}/api/{{APIV1}}/employees/:employeeId"
params:
- name: employeeId
value: "{{EMPLOYEE_ID}}"
type: path
auth: inherit
settings:
encodeUrl: true
timeout: 0
followRedirects: true
maxRedirects: 5

View file

@ -0,0 +1,62 @@
info:
name: List Employees
type: http
seq: 1
http:
method: GET
url: "{{ENDPOINT}}/api/{{APIV1}}/employees?page=1&pageSize=25&sortBy=arcadiaId&sortDirection=Ascending"
params:
- name: page
value: "1"
type: query
description: 1-based page index
- name: pageSize
value: "25"
type: query
description: Number of items per page (max 10000)
- name: offset
value: "0"
type: query
description: Offset for offset-based pagination
disabled: true
- name: limit
value: "25"
type: query
description: Limit for offset-based pagination
disabled: true
- name: since
value: 2026-01-01T00:00:00Z
type: query
description: Filter employees updated since timestamp (RFC3339)
disabled: true
- name: establishment
value: "01"
type: query
description: Filter by establishment code (e.g. 01, PA, LY)
disabled: true
- name: siteId
value: LDCSER
type: query
description: Filter by site ID (e.g. LDCSER, SLELA)
disabled: true
- name: serviceId
value: "097"
type: query
description: Filter by service ID (e.g. 097, 101)
disabled: true
- name: sortBy
value: arcadiaId
type: query
description: "Sort column: arcadiaId, startDate, endDate, plannedEndDate, createdAt, updatedAt"
- name: sortDirection
value: Ascending
type: query
description: "Sort direction: Ascending or Descending"
auth: inherit
settings:
encodeUrl: true
timeout: 0
followRedirects: true
maxRedirects: 5

View file

@ -0,0 +1,7 @@
info:
name: Employees
type: folder
seq: 3
request:
auth: inherit

View file

@ -0,0 +1,15 @@
info:
name: OpenApi Spec
type: http
seq: 3
http:
method: GET
url: "{{ENDPOINT}}/api/{{APIV1}}/openapi"
auth: inherit
settings:
encodeUrl: true
timeout: 0
followRedirects: true
maxRedirects: 5

View file

@ -0,0 +1,15 @@
info:
name: Ping
type: http
seq: 2
http:
method: GET
url: "{{ENDPOINT}}/api/{{APIV1}}/ping"
auth: inherit
settings:
encodeUrl: true
timeout: 0
followRedirects: true
maxRedirects: 5

View file

@ -0,0 +1,15 @@
info:
name: Root
type: http
seq: 1
http:
method: GET
url: "{{ENDPOINT}}/api/{{APIV1}}/"
auth: inherit
settings:
encodeUrl: true
timeout: 0
followRedirects: true
maxRedirects: 5

View file

@ -0,0 +1,7 @@
info:
name: V1
type: folder
seq: 2
request:
auth: inherit

View file

@ -0,0 +1,7 @@
info:
name: Api
type: folder
seq: 2
request:
auth: inherit

View file

@ -0,0 +1,15 @@
info:
name: Root Url
type: http
seq: 1
http:
method: GET
url: "{{ENDPOINT}}/"
auth: inherit
settings:
encodeUrl: true
timeout: 0
followRedirects: true
maxRedirects: 5

View file

@ -0,0 +1,11 @@
name: Local Dev
variables:
- name: ENDPOINT
value: http://127.0.0.1:8000
description: ""
- name: APIV1
value: v1
description: ""
- name: EMPLOYEE_ID
value: "01155902"
description: "Employee public matricule (7-8 digits)"

View file

@ -0,0 +1,10 @@
opencollection: 1.0.0
info:
name: Arcadia Api
bundled: false
extensions:
bruno:
ignore:
- node_modules
- .git

View file

@ -0,0 +1,546 @@
openapi: 3.1.0
info:
title: Arcadia API
description: |
Arcadia API in order to abstract corporate metamodel to a proper and stable implemented API.
Architecture Clean Architecture, Domain-Driven Design (DDD) & Ports & Adapters (Hexagonale).
contact:
name: Uwil Engineering Team
email: digital@ldc.fr
license:
name: MIT
url: https://opensource.org/licenses/MIT
version: 1.0.0
servers:
- url: http://127.0.0.1:8000/api/v1
description: Serveur de développement local v1
security:
- HmacClientId: []
HmacTimestamp: []
HmacSignature: []
tags:
- name: Employees
description: Gestion et consultation du référentiel RH des employés.
paths:
/employees:
get:
tags:
- Employees
summary: Liste paginée des employés
description: |
Retourne la liste paginée des employés du système Arcadia.
Prend en charge le filtrage par date de modification (`since`), code établissement (`establishment`),
code site (`siteId`), code service (`serviceId`), ainsi que le tri et la pagination HATEOAS.
operationId: listEmployees
parameters:
- $ref: '#/components/parameters/Page'
- $ref: '#/components/parameters/PageSize'
- $ref: '#/components/parameters/Offset'
- $ref: '#/components/parameters/Limit'
- $ref: '#/components/parameters/Since'
- $ref: '#/components/parameters/Establishment'
- $ref: '#/components/parameters/SiteId'
- $ref: '#/components/parameters/ServiceId'
- $ref: '#/components/parameters/SortBy'
- $ref: '#/components/parameters/SortDirection'
responses:
'200':
description: Page d'employés récupérée avec succès.
content:
application/json:
schema:
$ref: '#/components/schemas/EmployeeListResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'422':
$ref: '#/components/responses/UnprocessableEntity'
'500':
$ref: '#/components/responses/InternalServerError'
'503':
$ref: '#/components/responses/ServiceUnavailable'
/employees/{employeeId}:
get:
tags:
- Employees
summary: Détail d'un employé par son identifiant
description: |
Retourne la fiche détaillée d'un employé spécifié par son matricule public unique.
operationId: getEmployee
parameters:
- $ref: '#/components/parameters/EmployeeIdPath'
responses:
'200':
description: Fiche employé trouvée.
content:
application/json:
schema:
$ref: '#/components/schemas/EmployeeItemResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'422':
$ref: '#/components/responses/UnprocessableEntity'
'500':
$ref: '#/components/responses/InternalServerError'
'503':
$ref: '#/components/responses/ServiceUnavailable'
components:
securitySchemes:
HmacClientId:
type: apiKey
in: header
name: X-Client-Id
description: Identifiant public du client API autorisé.
HmacTimestamp:
type: apiKey
in: header
name: X-Timestamp
description: Horodatage au format ISO8601 / RFC3339 (tolérance anti-replay ±5 minutes).
HmacSignature:
type: apiKey
in: header
name: X-Signature
description: Signature HMAC-SHA256 calculée avec la clé secrète partagée.
parameters:
EmployeeIdPath:
name: employeeId
in: path
required: true
description: Matricule public unique de l'employé (7 ou 8 chiffres).
schema:
type: string
pattern: '^\d{7,8}$'
example: '01155902'
Page:
name: page
in: query
required: false
description: Numéro de page (1-based).
schema:
type: integer
minimum: 1
default: 1
example: 1
PageSize:
name: pageSize
in: query
required: false
description: Nombre d'éléments par page (max 10000).
schema:
type: integer
minimum: 1
maximum: 10000
default: 25
example: 25
Offset:
name: offset
in: query
required: false
description: Décalage d'index pour la pagination basée sur l'offset.
schema:
type: integer
minimum: 0
example: 0
Limit:
name: limit
in: query
required: false
description: Nombre maximal d'enregistrements pour la pagination par offset.
schema:
type: integer
minimum: 1
maximum: 10000
example: 25
Since:
name: since
in: query
required: false
description: Horodatage au format RFC3339 (borne inférieure sur updatedAt).
schema:
type: string
format: date-time
example: '2026-01-01T00:00:00Z'
Establishment:
name: establishment
in: query
required: false
description: "Filtrer par code établissement (ex: 01, PA, LY)."
schema:
type: string
pattern: '^[\dA-Z]{2,}$'
example: '01'
SiteId:
name: siteId
in: query
required: false
description: "Filtrer par code site (ex: LDCSER, SLELA)."
schema:
type: string
pattern: '^[A-Z]{2,}$'
example: 'LDCSER'
ServiceId:
name: serviceId
in: query
required: false
description: "Filtrer par identifiant de service (ex: 097, 101)."
schema:
type: string
pattern: '^\d{1,}$'
example: '097'
SortBy:
name: sortBy
in: query
required: false
description: Champ d'ordonnancement des employés.
schema:
type: string
enum:
- arcadiaId
- startDate
- endDate
- plannedEndDate
- createdAt
- updatedAt
default: arcadiaId
example: arcadiaId
SortDirection:
name: sortDirection
in: query
required: false
description: Sens du tri.
schema:
type: string
enum:
- Ascending
- Descending
default: Ascending
example: Ascending
responses:
BadRequest:
description: Requête malformée ou paramètres invalides (400 Bad Request).
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ProblemDetails'
Unauthorized:
description: Échec d'authentification HMAC ou signature invalide (401 Unauthorized).
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ProblemDetails'
Forbidden:
description: Client non autorisé à accéder à cette ressource (403 Forbidden).
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ProblemDetails'
NotFound:
description: Ressource introuvable (404 Not Found).
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ProblemDetails'
UnprocessableEntity:
description: Erreurs de validation de la requête HTTP (422 Unprocessable Entity).
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ValidationErrorProblemDetails'
InternalServerError:
description: Erreur interne du serveur (500 Internal Server Error).
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ProblemDetails'
ServiceUnavailable:
description: Service temporairement indisponible (503 Service Unavailable).
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ProblemDetails'
schemas:
Employee:
type: object
description: Représentation canonique d'un employé dans le métamodèle Arcadia.
required:
- id
- firstName
- lastName
- establishment
- site
- service
- startDate
properties:
id:
type: string
pattern: '^\d{7,8}$'
description: Matricule public unique de l'employé.
example: '01155902'
firstName:
type: string
description: Prénom de l'employé.
example: John
lastName:
type: string
description: Nom de famille de l'employé.
example: DOE
establishment:
type: string
pattern: '^[\dA-Z]{2,}$'
description: Code de l'établissement d'affectation.
example: '01'
site:
type: string
pattern: '^[A-Z]{2,}$'
description: Code du site géographique.
example: LDCSER
service:
type: string
pattern: '^\d{1,}$'
description: Identifiant du service interne.
example: '097'
startDate:
type: string
format: date
description: Date de prise de poste (YYYY-MM-DD).
example: '2024-01-15'
endDate:
type:
- string
- 'null'
format: date
description: Date de fin de contrat effective (optionnelle).
example: null
plannedEndDate:
type:
- string
- 'null'
format: date
description: Date de fin de contrat prévue (optionnelle).
example: null
createdAt:
type:
- string
- 'null'
format: date-time
description: Date d'enregistrement dans le système.
example: '2026-08-11T14:00:00Z'
updatedAt:
type:
- string
- 'null'
format: date-time
description: Date de dernière mise à jour.
example: '2026-08-11T14:00:00Z'
PaginationLinks:
type: object
description: Liens de navigation HATEOAS pour la pagination.
required:
- self
- first
- last
properties:
self:
type: string
format: uri
description: Lien vers la page courante.
example: 'http://127.0.0.1:8000/api/v1/employees?page=1&pageSize=25'
first:
type: string
format: uri
description: Lien vers la première page.
example: 'http://127.0.0.1:8000/api/v1/employees?page=1&pageSize=25'
prev:
type:
- string
- 'null'
format: uri
description: Lien vers la page précédente (null si première page).
example: null
next:
type:
- string
- 'null'
format: uri
description: Lien vers la page suivante (null si dernière page).
example: 'http://127.0.0.1:8000/api/v1/employees?page=2&pageSize=25'
last:
type: string
format: uri
description: Lien vers la dernière page.
example: 'http://127.0.0.1:8000/api/v1/employees?page=2&pageSize=25'
PaginationMeta:
type: object
description: Métadonnées de pagination.
required:
- page
- pageSize
- totalItems
- totalPages
- links
properties:
page:
type: integer
minimum: 1
description: Index de la page courante (1-based).
example: 1
pageSize:
type: integer
minimum: 1
description: Nombre d'éléments par page.
example: 25
totalItems:
type: integer
minimum: 0
description: Nombre total d'éléments correspondant aux filtres.
example: 42
totalPages:
type: integer
minimum: 0
description: Nombre total de pages disponibles.
example: 2
links:
$ref: '#/components/schemas/PaginationLinks'
EmployeeListResponse:
type: object
description: Enveloppe de réponse pour la liste paginée des employés.
required:
- employees
- pagination
properties:
employees:
type: array
description: Collection des employés de la page.
items:
$ref: '#/components/schemas/Employee'
pagination:
$ref: '#/components/schemas/PaginationMeta'
EmployeeItemResponse:
type: object
description: Enveloppe de réponse pour le détail d'un employé.
required:
- employee
properties:
employee:
$ref: '#/components/schemas/Employee'
ProblemDetails:
type: object
description: Format d'erreur standardisé RFC 7807 (Problem Details for HTTP APIs).
required:
- type
- title
- status
- detail
properties:
type:
type: string
format: uri
description: URI identifiant le type de problème.
example: 'http://127.0.0.1:8000/errors/not-found'
title:
type: string
description: Titre court lisible résumant le problème.
example: 'Resource Not Found'
status:
type: integer
description: Code statut HTTP.
example: 404
detail:
type: string
description: Explication humaine détaillée de l'erreur.
example: "Employee '9999999' not found."
instance:
type:
- string
- 'null'
format: uri-reference
description: URI de l'endpoint ayant généré l'erreur.
example: '/api/v1/employees/9999999'
InvalidParamItem:
type: object
description: Détail d'une erreur de validation sur un paramètre.
required:
- name
- reason
properties:
name:
type: string
description: Nom du champ ou paramètre invalide.
example: employeeId
reason:
type: string
description: Raison du rejet de validation.
example: 'The employeeId pattern must be 7 or 8 digits.'
ValidationErrorProblemDetails:
type: object
description: Format RFC 7807 pour les erreurs de validation HTTP (422 Unprocessable Entity).
required:
- type
- title
- status
- detail
- invalidParams
properties:
type:
type: string
format: uri
description: URI identifiant l'erreur de validation.
example: 'http://127.0.0.1:8000/errors/validation-error'
title:
type: string
description: Titre de l'erreur.
example: 'Unprocessable Entity'
status:
type: integer
description: Code HTTP (422).
example: 422
detail:
type: string
description: Message d'ensemble.
example: 'The given data was invalid.'
invalidParams:
type: array
description: Liste des paramètres invalides et motifs.
items:
$ref: '#/components/schemas/InvalidParamItem'

View file

@ -0,0 +1,819 @@
openapi: 3.1.1
info:
title: Arcadia Genesis API (for PHP client)
version: 1.0.0
summary: Proposed HTTP API contract consumed by arcadia-genesis-php-client
description: |
This specification describes the API surface implied by the PHP client.
It models employee and INCO sheet use cases exposed by the client services.
servers:
- url: https://api.example.com/gaston/api
description: Example production server
security:
- ArcadiaAuth: []
tags:
- name: Employees
- name: IncoSheets
- name: IncoComposition
paths:
/employees:
get:
tags: [Employees]
operationId: listEmployees
summary: List employees
description: |
Returns a paginated list of employees.
Supports optional filtering by update timestamp and site ids.
parameters:
- $ref: '#/components/parameters/Page'
- $ref: '#/components/parameters/PageSize'
- $ref: '#/components/parameters/Since'
- $ref: '#/components/parameters/EmployeeSortBy'
- $ref: '#/components/parameters/SortDirection'
- name: siteIds
in: query
required: false
description: Filter on one or many site ids
style: form
explode: true
schema:
type: array
minItems: 1
items:
type: string
responses:
'200':
description: Employees page
content:
application/json:
schema:
$ref: '#/components/schemas/EmployeeListResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'429':
$ref: '#/components/responses/TooManyRequests'
'503':
$ref: '#/components/responses/ServiceUnavailable'
/employees/{employeeId}:
get:
tags: [Employees]
operationId: getEmployeeById
summary: Get an employee by id
parameters:
- name: employeeId
in: path
required: true
schema:
type: string
responses:
'200':
description: Employee detail
content:
application/json:
schema:
$ref: '#/components/schemas/EmployeeItemResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
description: Employee not found
content:
application/json:
schema:
$ref: '#/components/schemas/NotFoundResponse'
'429':
$ref: '#/components/responses/TooManyRequests'
'503':
$ref: '#/components/responses/ServiceUnavailable'
/inco-sheets:
get:
tags: [IncoSheets]
operationId: listIncoSheets
summary: List INCO sheets
description: |
Returns paginated INCO sheets.
Supports brand filtering and optional updated_at lower bound.
parameters:
- $ref: '#/components/parameters/Page'
- $ref: '#/components/parameters/PageSize'
- $ref: '#/components/parameters/Since'
- $ref: '#/components/parameters/IncoSortBy'
- $ref: '#/components/parameters/SortDirection'
- name: brands
in: query
required: false
description: Filter on one or many brand codes
style: form
explode: true
schema:
type: array
minItems: 1
items:
type: string
responses:
'200':
description: INCO sheets page
content:
application/json:
schema:
$ref: '#/components/schemas/IncoListResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'429':
$ref: '#/components/responses/TooManyRequests'
'503':
$ref: '#/components/responses/ServiceUnavailable'
/inco-sheets/short:
get:
tags: [IncoSheets]
operationId: listIncoSheetsShort
summary: List INCO sheets (short payload)
parameters:
- $ref: '#/components/parameters/Page'
- $ref: '#/components/parameters/PageSize'
- $ref: '#/components/parameters/IncoSortBy'
- $ref: '#/components/parameters/SortDirection'
- name: brands
in: query
required: true
description: One or many brand codes
style: form
explode: true
schema:
type: array
minItems: 1
items:
type: string
responses:
'200':
description: INCO short page
content:
application/json:
schema:
$ref: '#/components/schemas/IncoShortListResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'429':
$ref: '#/components/responses/TooManyRequests'
'503':
$ref: '#/components/responses/ServiceUnavailable'
/inco-sheets/search:
get:
tags: [IncoSheets]
operationId: searchIncoSheetsByIdLike
summary: Search INCO sheets by id-like pattern
parameters:
- name: incoIdLike
in: query
required: true
schema:
type: string
description: Pattern used with SQL-like matching rules
- name: brands
in: query
required: true
style: form
explode: true
schema:
type: array
minItems: 1
items:
type: string
- name: short
in: query
required: false
schema:
type: boolean
default: false
description: Return short projection when true
responses:
'200':
description: Search result (first page, size 50)
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/IncoListResponse'
- $ref: '#/components/schemas/IncoShortListResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'429':
$ref: '#/components/responses/TooManyRequests'
'503':
$ref: '#/components/responses/ServiceUnavailable'
/inco-sheets/{incoId}:
get:
tags: [IncoSheets]
operationId: getIncoSheetById
summary: Get INCO sheet by id
parameters:
- name: incoId
in: path
required: true
schema:
type: string
pattern: '^\\d{1,}$'
responses:
'200':
description: INCO sheet detail
content:
application/json:
schema:
$ref: '#/components/schemas/IncoItemResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
description: INCO not found
content:
application/json:
schema:
$ref: '#/components/schemas/NotFoundResponse'
'429':
$ref: '#/components/responses/TooManyRequests'
'503':
$ref: '#/components/responses/ServiceUnavailable'
/inco-sheets/{incoId}/composition:
get:
tags: [IncoComposition]
operationId: getIncoCompositionByIncoId
summary: Get composition by INCO id
parameters:
- name: incoId
in: path
required: true
schema:
type: string
pattern: '^\\d{1,}$'
responses:
'200':
description: Composition detail
content:
application/json:
schema:
$ref: '#/components/schemas/IncoCompoItemResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
description: Composition not found
content:
application/json:
schema:
$ref: '#/components/schemas/NotFoundResponse'
'429':
$ref: '#/components/responses/TooManyRequests'
'503':
$ref: '#/components/responses/ServiceUnavailable'
/inco-compositions/{incoCompoId}:
get:
tags: [IncoComposition]
operationId: getIncoCompositionById
summary: Get composition by composition id
parameters:
- name: incoCompoId
in: path
required: true
schema:
type: string
pattern: '^\\d{1,}$'
responses:
'200':
description: Composition detail
content:
application/json:
schema:
$ref: '#/components/schemas/IncoCompoItemResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
description: Composition not found
content:
application/json:
schema:
$ref: '#/components/schemas/NotFoundResponse'
'429':
$ref: '#/components/responses/TooManyRequests'
'503':
$ref: '#/components/responses/ServiceUnavailable'
components:
securitySchemes:
ArcadiaAuth:
type: apiKey
in: header
name: X-API-Key
description: |
Requests also require `X-API-Signature` and `X-Timestamp` headers.
Signature is computed from method, URI, body payload, shared secret, and timestamp.
parameters:
Page:
name: page
in: query
required: false
schema:
type: integer
minimum: 1
default: 1
description: 1-based page index
PageSize:
name: page_size
in: query
required: false
schema:
type: integer
minimum: 1
default: 50
maximum: 10000
description: Max records per page
Since:
name: since
in: query
required: false
schema:
type: string
format: date-time
description: RFC3339 timestamp lower bound (>=)
SortDirection:
name: sortDirection
in: query
required: false
schema:
type: string
enum: [asc, desc]
default: desc
EmployeeSortBy:
name: sortBy
in: query
required: false
schema:
type: string
enum:
- arcadiaId
- startDate
- endDate
- plannedEndDate
- createdAt
- updatedAt
IncoSortBy:
name: sortBy
in: query
required: false
schema:
type: string
enum:
- id
- createdAt
- updatedAt
responses:
BadRequest:
description: Invalid request
content:
application/json:
schema:
$ref: '#/components/schemas/ApiErrorResponse'
Unauthorized:
description: Authentication failed
content:
application/json:
schema:
$ref: '#/components/schemas/ApiErrorResponse'
TooManyRequests:
description: Rate limited
content:
application/json:
schema:
$ref: '#/components/schemas/ApiErrorResponse'
ServiceUnavailable:
description: Upstream service unavailable
content:
application/json:
schema:
$ref: '#/components/schemas/ApiErrorResponse'
schemas:
Employee:
type: object
additionalProperties: false
required:
- matriculePublique
- lastname
- firstname
- start_date
- establishment
- site
- service
- created_at
properties:
matriculePublique:
type: string
lastname:
type: string
firstname:
type: string
start_date:
type: string
format: date-time
end_date:
type: [string, 'null']
format: date-time
planned_end_date:
type: [string, 'null']
format: date-time
establishment:
type: string
site:
type: string
service:
type: string
created_at:
type: string
format: date-time
updated_at:
type: [string, 'null']
format: date-time
IncoBrand:
type: object
additionalProperties: false
required: [code, label]
properties:
code:
type: string
label:
type: string
Inco:
type: object
additionalProperties: false
required:
- id
- name
- libelle
- description
- allegations
- sellArguments
- preparationAdvices
- ingredients
- allergens
- brand
- isSeasonal
- additives
properties:
id:
type: string
pattern: '^\\d{1,}$'
name:
type: string
libelle:
type: string
description:
type: string
allegations:
type: object
additionalProperties: true
sellArguments:
type: string
preparationAdvices:
type: string
tips:
type: [string, 'null']
sellFamilly:
type: [string, 'null']
ingredients:
type: object
additionalProperties: true
portions:
type: [object, 'null']
additionalProperties: true
allergens:
type: array
items:
type: object
additionalProperties: true
brand:
$ref: '#/components/schemas/IncoBrand'
isSeasonal:
type: boolean
weight:
type: [object, 'null']
additionalProperties: true
nutriscore:
type: [object, 'null']
additionalProperties: true
storageCondition:
type: [object, 'null']
additionalProperties: true
additives:
type: array
items:
type: object
additionalProperties: true
compo:
type: [string, 'null']
pattern: '^\\d{1,}$'
created_at:
type: [string, 'null']
format: date-time
updated_at:
type: [string, 'null']
format: date-time
IncoShort:
type: object
additionalProperties: false
required:
- id
- name
- libelle
- description
properties:
id:
type: string
pattern: '^\\d{1,}$'
name:
type: string
libelle:
type: string
description:
type: string
created_at:
type: [string, 'null']
format: date-time
updated_at:
type: [string, 'null']
format: date-time
IncoCompo:
type: object
additionalProperties: false
required:
- id
- idInco
- identification
- energie
- macronutrimentsRef
- macronutrimentsPortion
- fnl
- apportsReference
- nutriScore
- pointsNutriScore
- mineraux
- vitamines
- glucidesDetail
- acideGras
- acidesAmines
- composesSpeciaux
properties:
id:
type: string
pattern: '^\\d{1,}$'
idInco:
type: string
pattern: '^\\d{1,}$'
identification:
type: object
additionalProperties: true
energie:
type: object
additionalProperties: true
macronutrimentsRef:
type: object
additionalProperties: true
macronutrimentsPortion:
type: object
additionalProperties: true
fnl:
type: object
additionalProperties: true
apportsReference:
type: object
additionalProperties: true
nutriScore:
type: object
additionalProperties: true
pointsNutriScore:
type: object
additionalProperties: true
mineraux:
type: object
additionalProperties: true
vitamines:
type: object
additionalProperties: true
glucidesDetail:
type: object
additionalProperties: true
acideGras:
type: object
additionalProperties: true
acidesAmines:
type: object
additionalProperties: true
composesSpeciaux:
type: object
additionalProperties: true
Pagination:
type: object
additionalProperties: false
required:
- page
- pageSize
- totalItems
- totalPages
- links
properties:
page:
type: integer
minimum: 1
pageSize:
type: integer
minimum: 1
totalItems:
type: integer
minimum: 0
totalPages:
type: integer
minimum: 0
links:
type: object
additionalProperties: false
required: [first, last]
properties:
first:
type: string
format: uri
last:
type: string
format: uri
EmployeeListResponse:
allOf:
- $ref: '#/components/schemas/SuccessEnvelope'
- type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/Employee'
pagination:
$ref: '#/components/schemas/Pagination'
EmployeeItemResponse:
allOf:
- $ref: '#/components/schemas/SuccessEnvelope'
- type: object
properties:
data:
$ref: '#/components/schemas/Employee'
IncoListResponse:
allOf:
- $ref: '#/components/schemas/SuccessEnvelope'
- type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/Inco'
pagination:
$ref: '#/components/schemas/Pagination'
IncoShortListResponse:
allOf:
- $ref: '#/components/schemas/SuccessEnvelope'
- type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/IncoShort'
pagination:
$ref: '#/components/schemas/Pagination'
IncoItemResponse:
allOf:
- $ref: '#/components/schemas/SuccessEnvelope'
- type: object
properties:
data:
$ref: '#/components/schemas/Inco'
IncoCompoItemResponse:
allOf:
- $ref: '#/components/schemas/SuccessEnvelope'
- type: object
properties:
data:
$ref: '#/components/schemas/IncoCompo'
SuccessEnvelope:
type: object
additionalProperties: false
required: [success, data]
properties:
success:
type: boolean
const: true
data: {}
pagination:
$ref: '#/components/schemas/Pagination'
ApiErrorCode:
type: string
enum:
- '0004'
- ERR_UNAUTHORIZED_PARAMETER
- ERR_DEFAULT
- ERR_LIST_SIZE_MISMATCH
- ERR_METAEXCEPTION
- ERR_SORT_LIST_SIZE_MISMATCH
- ERR_TABLE_NAME_MISSING
- ERR_UNAUTHORIZED_OPERATOR
- ERR_BAD_DATE_FORMAT
- ERR_PAGE_TYPE_MISMATCH
- ERR_PAGE_SIZE_TYPE_MISMATCH
- ERR_TOO_MANY_RECORDS
- ERR_INVALID_API_KEY
- ERR_INVALID_API_SIGNATURE
- ERR_TOO_MANY_REQUESTS
- UNKNOWN
ApiErrorObject:
type: object
additionalProperties: true
required: [code]
properties:
code:
$ref: '#/components/schemas/ApiErrorCode'
message:
type: string
ApiErrorResponse:
type: object
additionalProperties: false
required: [success, error]
properties:
success:
type: boolean
const: false
error:
oneOf:
- $ref: '#/components/schemas/ApiErrorObject'
- type: array
items:
$ref: '#/components/schemas/ApiErrorObject'
NotFoundResponse:
type: object
additionalProperties: false
required: [success, error]
properties:
success:
type: boolean
const: false
error:
type: object
additionalProperties: false
required: [code, message]
properties:
code:
type: string
enum: [NOT_FOUND]
message:
type: string

67
phpcs.xml Normal file
View file

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Php Coding Standard"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
<description>Standard optimisé : Analyse statique complémentaire à Pint.</description>
<arg name="colors" />
<arg name="extensions" value="php" />
<arg name="parallel" value="75" />
<file>src/</file>
<file>config/</file>
<file>database/</file>
<file>routes/</file>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/storage/*</exclude-pattern>
<exclude-pattern>_ide_helper.php</exclude-pattern>
<exclude-pattern>*/tests/*</exclude-pattern>
<exclude-pattern>*.blade.php</exclude-pattern>
<rule ref="PSR12"/>
<rule ref="Generic.CodeAnalysis.EmptyStatement"/>
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<rule ref="Generic.Metrics.CyclomaticComplexity">
<properties>
<property name="complexity" value="10"/>
<property name="absoluteComplexity" value="20"/>
</properties>
</rule>
<rule ref="Generic.Metrics.NestingLevel"/>
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<rule ref="Generic.PHP.ForbiddenFunctions"/>
<rule ref="Generic.PHP.NoSilencedErrors"/>
<rule ref="Squiz.PHP.Eval"/>
<rule ref="Squiz.PHP.GlobalKeyword"/>
<rule ref="Squiz.PHP.NonExecutableCode"/>
<rule ref="Squiz.Scope.StaticThisUsage"/>
<rule ref="Generic.NamingConventions.ConstructorName"/>
<rule ref="Generic.NamingConventions.CamelCapsFunctionName"/>
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="150"/>
<property name="absoluteLineLimit" value="250"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses" />
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="spacesCountAroundEqualsSign" value="0" />
<property name="declareOnFirstLine" value="false" />
<property name="linesCountBeforeDeclare" value="1" />
<property name="linesCountAfterDeclare" value="1" />
</properties>
</rule>
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
<exclude-pattern>*/database/migrations/*</exclude-pattern>
</rule>
</ruleset>

16
phpstan.neon Normal file
View file

@ -0,0 +1,16 @@
includes:
- vendor/larastan/larastan/extension.neon
- vendor/nesbot/carbon/extension.neon
- vendor/pestphp/pest/extension.neon
parameters:
paths:
- src/
excludePaths:
- tests/Architecture/
level: 10
# Enforce strict types analysis
treatPhpDocTypesAsCertain: false

22
phpunit.xml Normal file
View file

@ -0,0 +1,22 @@
<?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>
<testsuite name="Architecture">
<directory>tests/Architecture</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>src</directory>
</include>
</source>
<php>
<env name="APP_ENV" value="testing"/>
</php>
</phpunit>

77
pint.json Normal file
View file

@ -0,0 +1,77 @@
{
"preset": "laravel",
"rules": {
"indentation_type": true,
"single_line_empty_body": false,
"types_spaces": {
"space": "single",
"space_multiple_catch": "single"
},
"control_structure_braces": true,
"new_with_parentheses": {
"anonymous_class": true,
"named_class": true
},
"class_definition": {
"single_item_single_line": false,
"single_line": false,
"space_before_parenthesis": true
},
"curly_braces_position": {
"allow_single_line_empty_anonymous_classes": false,
"classes_opening_brace": "next_line_unless_newline_at_signature_end",
"anonymous_classes_opening_brace": "next_line_unless_newline_at_signature_end",
"control_structures_opening_brace": "same_line",
"functions_opening_brace": "next_line_unless_newline_at_signature_end",
"anonymous_functions_opening_brace": "same_line"
},
"binary_operator_spaces": {
"default": "align_single_space_minimal",
"operators": {
"=": "align_single_space",
"|": "single_space",
"=>": "align_single_space",
".=": "align_single_space"
}
},
"concat_space": {
"spacing": "one"
},
"align_multiline_comment": {
"comment_type": "all_multiline"
},
"array_indentation": true,
"method_chaining_indentation": true,
"statement_indentation": {
"stick_comment_to_next_continuous_control_statement": true
},
"no_unused_imports": true,
"fully_qualified_strict_types": {
"import_symbols": true,
"leading_backslash_in_global_namespace": true,
"phpdoc_tags": []
},
"visibility_required": {
"elements": [
"const",
"method",
"property"
]
},
"no_useless_else": true,
"function_declaration": {
"closure_function_spacing": "one",
"closure_fn_spacing": "one",
"trailing_comma_single_line": false
},
"single_line_after_imports": true,
"combine_consecutive_issets": true,
"array_syntax": {
"syntax": "short"
},
"single_quote": true,
"blank_line_after_namespace": true,
"blank_line_after_opening_tag": true,
"declare_strict_types": true
}
}

25
public/.htaccess Normal file
View 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
View file

21
public/index.php Normal file
View file

@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
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
View file

@ -0,0 +1,2 @@
User-agent: *
Disallow:

34
rector.php Normal file
View file

@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
use RectorLaravel\Set\LaravelLevelSetList;
use RectorLaravel\Set\LaravelSetList;
use RectorLaravel\Set\LaravelSetProvider;
return RectorConfig::configure()
->withSetProviders(LaravelSetProvider::class)
->withPaths([
__DIR__ . '/src',
__DIR__ . '/bootstrap',
__DIR__ . '/config',
__DIR__ . '/public',
__DIR__ . '/resources',
__DIR__ . '/routes',
__DIR__ . '/tests',
])
->withPhpSets()
->withComposerBased(laravel: true)
->withSets([
LaravelLevelSetList::UP_TO_LARAVEL_130,
LaravelSetList::LARAVEL_CODE_QUALITY,
LaravelSetList::LARAVEL_COLLECTION,
LaravelSetList::LARAVEL_IF_HELPERS,
LaravelSetList::LARAVEL_LEGACY_FACTORIES_TO_CLASSES,
LaravelSetList::LARAVEL_TYPE_DECLARATIONS,
LaravelSetList::LARAVEL_ELOQUENT_MAGIC_METHOD_TO_QUERY_BUILDER,
])
->withTypeCoverageLevel(0)
->withDeadCodeLevel(0)
->withCodeQualityLevel(0);

15
routes/api.php Normal file
View file

@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Route;
// * Api Root URL
Route::get('/', fn () => response()->json(Config::string('app.name') . ' choose a version'))
->name('api.root');
// * V1 API
Route::prefix('v1')->name('api.v1.')->group(function () {
require __DIR__ . '/apiv1.php';
});

21
routes/apiv1.php Normal file
View file

@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Route;
use Presentation\Api\V1\Http\Controllers\Employees\EmployeeShowController;
use Presentation\Api\V1\Http\Controllers\Employees\EmployeesIndexController;
Route::get('/', fn () => response()->json(Config::string('app.name') . ' v1'))->name('root');
Route::get('/ping', fn () => response()->json('pong'))->name('ping');
Route::get('/openapi', function () {
return response()->file(
base_path('documentation/OpenApi/openapi.yaml'),
['Content-Type' => 'application/yaml']
);
})->name('openapi');
Route::get('/employees', EmployeesIndexController::class)->name('employees.index');
Route::get('/employees/{employeeId}', EmployeeShowController::class)->name('employees.show');

3
routes/console.php Normal file
View file

@ -0,0 +1,3 @@
<?php
declare(strict_types=1);

10
routes/web.php Normal file
View file

@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
use Illuminate\Support\Facades\Route;
use Presentation\Web\Http\Controllers\ErrorDocumentationController;
use Presentation\Web\Http\Controllers\HomeController;
Route::get('/', HomeController::class)->name('home');
Route::get('/errors/{code}', ErrorDocumentationController::class)->name('errors.doc');

View file

@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
namespace Application\Usecase\Employees\Find;
use Shared\DDD\Usecase\Output as UsecaseOutput;
use Shared\DDD\Usecase\Presenter;
/** @implements Presenter<\Shared\DDD\Usecase\Output, EmployeeShowView> */
final readonly class EmployeeShowPresenter implements Presenter
{
#[\Override]
public function present(UsecaseOutput $output): object
{
assert($output instanceof Output);
return EmployeeShowView::fromOutput($output);
}
}

View file

@ -0,0 +1,38 @@
<?php
declare(strict_types=1);
namespace Application\Usecase\Employees\Find;
use Domain\Models\ValueObjects\Entities\ArcadiaEmployeeId;
final readonly class EmployeeShowView
{
public function __construct(
public ArcadiaEmployeeId $id,
public string $firstName,
public string $lastName,
public string $establishment,
public string $site,
public string $service,
public \DateTimeInterface $startDate,
public ?\DateTimeInterface $endDate,
public ?\DateTimeInterface $plannedEndDate,
) {
}
public static function fromOutput(Output $output): self
{
return new self(
id: $output->id,
firstName: $output->firstName,
lastName: $output->lastName,
establishment: $output->establishment,
site: $output->site,
service: $output->service,
startDate: $output->startDate,
endDate: $output->endDate,
plannedEndDate: $output->plannedEndDate,
);
}
}

View file

@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace Application\Usecase\Employees\Find;
use Domain\Exceptions\NotFoundException;
use Domain\Ports\Directories\EmployeeDirectory;
use Shared\DDD\Usecase\Input as BaseInput;
use Shared\DDD\Usecase\Usecase;
/** @implements Usecase<\Shared\DDD\Usecase\Input, \Shared\DDD\Usecase\Output> */
final readonly class FindEmployee implements Usecase
{
public function __construct(
private EmployeeDirectory $directory
) {
}
#[\Override]
public function execute(BaseInput $input): Output
{
assert($input instanceof Input);
$employee = $this->directory->find($input->id);
if ($employee === null) {
throw NotFoundException::forEntity('Employee', (string) $input->id);
}
return new Output(
id: $employee->id(),
firstName: $employee->firstName,
lastName: $employee->lastName,
establishment: $employee->establishment->value,
site: $employee->site->value,
service: $employee->service->value,
startDate: $employee->startDate,
endDate: $employee->endDate,
plannedEndDate: $employee->plannedEndDate,
);
}
}

View file

@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
namespace Application\Usecase\Employees\Find;
use Domain\Models\ValueObjects\Entities\ArcadiaEmployeeId;
use Shared\DDD\Usecase\Input as UsecaseInput;
final readonly class Input implements UsecaseInput
{
public function __construct(
public ArcadiaEmployeeId $id,
) {
}
}

View file

@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
namespace Application\Usecase\Employees\Find;
use Domain\Models\ValueObjects\Entities\ArcadiaEmployeeId;
use Shared\DDD\Usecase\Output as UsecaseOutput;
final readonly class Output implements UsecaseOutput
{
public function __construct(
public ArcadiaEmployeeId $id,
public string $firstName,
public string $lastName,
public string $establishment,
public string $site,
public string $service,
public \DateTimeInterface $startDate,
public ?\DateTimeInterface $endDate,
public ?\DateTimeInterface $plannedEndDate,
) {
}
}

View file

@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
namespace Application\Usecase\Employees\FindAll;
use Shared\DDD\Usecase\Output as UsecaseOutput;
use Shared\DDD\Usecase\Presenter;
/** @implements Presenter<\Shared\DDD\Usecase\Output, EmployeesIndexView> */
final readonly class EmployeesIndexPresenter implements Presenter
{
#[\Override]
public function present(UsecaseOutput $output): object
{
assert($output instanceof Output);
return EmployeesIndexView::fromOutput($output);
}
}

View file

@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace Application\Usecase\Employees\FindAll;
final readonly class EmployeesIndexView
{
/**
* @param PaginatedEmployee[] $employees
*/
public function __construct(
public array $employees,
public int $total,
public int $page,
public int $perPage,
) {
foreach ($this->employees as $employee) {
assert($employee instanceof PaginatedEmployee);
}
}
public static function fromOutput(Output $output): self
{
return new self(
employees: $output->employees,
total: $output->total,
page: $output->page,
perPage: $output->perPage,
);
}
}

View file

@ -0,0 +1,53 @@
<?php
declare(strict_types=1);
namespace Application\Usecase\Employees\FindAll;
use Domain\Models\Entities\Employee;
use Domain\Ports\Directories\EmployeeDirectory;
use Shared\DDD\Usecase\Input as BaseInput;
use Shared\DDD\Usecase\Usecase;
use Shared\Paginated;
/** @implements Usecase<\Shared\DDD\Usecase\Input, \Shared\DDD\Usecase\Output> */
final readonly class FindAllEmployees implements Usecase
{
public function __construct(
private EmployeeDirectory $directory
) {
}
#[\Override]
public function execute(BaseInput $input): Output
{
assert($input instanceof Input);
$page = $this->directory->findAll(
$input->pagination,
$input->sorter
);
return $this->toOutput($page);
}
/**
* @param Paginated<Employee> $resultPage
*/
private function toOutput(Paginated $resultPage): Output
{
$pagination = $resultPage->getPagination();
return new Output(
employees: array_map([$this, 'toPaginatedEmployee'], $resultPage->getItems()),
total: $resultPage->getTotal(),
page: $pagination->pageNumber(),
perPage: $pagination->pageSize(),
);
}
private function toPaginatedEmployee(Employee $employee): PaginatedEmployee
{
return PaginatedEmployee::fromDomain($employee);
}
}

View file

@ -0,0 +1,18 @@
<?php
declare(strict_types=1);
namespace Application\Usecase\Employees\FindAll;
use Domain\Models\ValueObjects\Employees\EmployeeSorter;
use Shared\DDD\Usecase\Input as UsecaseInput;
use Shared\Pagination;
final readonly class Input implements UsecaseInput
{
public function __construct(
public Pagination $pagination,
public EmployeeSorter $sorter,
) {
}
}

View file

@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace Application\Usecase\Employees\FindAll;
use Shared\DDD\Usecase\Output as UsecaseOutput;
final readonly class Output implements UsecaseOutput
{
public function __construct(
/** @var PaginatedEmployee[] */
public array $employees = [],
public int $total = 0,
public int $page = 1,
public int $perPage = 10,
) {
foreach ($this->employees as $employee) {
assert($employee instanceof PaginatedEmployee);
}
}
}

View file

@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace Application\Usecase\Employees\FindAll;
use Domain\Models\Entities\Employee;
use Domain\Models\ValueObjects\Entities\ArcadiaEmployeeId;
use Shared\DDD\Usecase\Output as UsecaseOutput;
final readonly class PaginatedEmployee implements UsecaseOutput
{
public function __construct(
public ArcadiaEmployeeId $id,
public string $firstName,
public string $lastName,
public string $establishment,
public string $site,
public string $service,
public \DateTimeInterface $startDate,
public ?\DateTimeInterface $endDate,
public ?\DateTimeInterface $plannedEndDate,
) {
}
public static function fromDomain(Employee $employee): self
{
return new self(
$employee->id(),
$employee->firstName,
$employee->lastName,
$employee->establishment->value,
$employee->site->value,
$employee->service->value,
$employee->startDate,
$employee->endDate,
$employee->plannedEndDate,
);
}
}

View file

@ -0,0 +1,13 @@
<?php
declare(strict_types=1);
namespace Domain\Exceptions;
final class NotFoundException extends \DomainException
{
public static function forEntity(string $entity, string $id): self
{
return new self("{$entity} '{$id}' not found.");
}
}

View file

@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
namespace Domain\Models\Entities;
use Domain\Models\ValueObjects\Entities\ArcadiaEmployeeId;
use Domain\Models\ValueObjects\EstablishmentCode;
use Domain\Models\ValueObjects\ServiceId;
use Domain\Models\ValueObjects\SiteId;
use Shared\DDD\Entity;
/** @implements \Shared\DDD\Entity<\Domain\Models\ValueObjects\Entities\ArcadiaEmployeeId> */
final readonly class Employee implements Entity
{
public function __construct(
public ArcadiaEmployeeId $publicEmployeeNumber,
public string $lastName,
public string $firstName,
public \DateTimeInterface $startDate,
public ?\DateTimeInterface $endDate,
public ?\DateTimeInterface $plannedEndDate,
public EstablishmentCode $establishment,
public SiteId $site,
public ServiceId $service,
public \DateTimeInterface $createdAt,
public ?\DateTimeInterface $updatedAt,
) {
}
#[\Override]
public function id(): ArcadiaEmployeeId
{
return $this->publicEmployeeNumber;
}
}

View file

@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace Domain\Models\ValueObjects;
/**
* eg: 13 -> Sans marque
*/
final readonly class BrandCode
{
public function __construct(
public readonly int $value
) {
if ($value <= 0) {
throw new \DomainException(
"Invalid code '{$value}' shall be greater than 0"
);
}
}
}

View file

@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace Domain\Models\ValueObjects\Employees;
enum EmployeeSortColumn
{
case arcadiaId;
case startDate;
case endDate;
case plannedEndDate;
case createdAt;
case updatedAt;
}

View file

@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace Domain\Models\ValueObjects\Employees;
final readonly class EmployeeSorter
{
public function __construct(
public EmployeeSortColumn $sortBy,
public \SortDirection $direction,
) {
}
}

View file

@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace Domain\Models\ValueObjects\Entities;
use Shared\DDD\EntityId;
final readonly class ArcadiaEmployeeId extends EntityId
{
private const PATTERN = '/^\d{7,8}$/';
public function __construct(
public readonly string $value
) {
if (! preg_match(self::PATTERN, $value)) {
throw new \DomainException(
"Invalid value '{$value}' does not match pattern " . self::PATTERN
);
}
}
}

View file

@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
namespace Domain\Models\ValueObjects;
final readonly class EstablishmentCode
{
private const PATTERN = '/^[\dA-Z]{2,}$/';
public function __construct(
public readonly string $value
) {
if (! preg_match(self::PATTERN, $value)) {
throw new \DomainException(
"Invalid value '{$value}' does not match pattern " . self::PATTERN
);
}
}
}

View file

@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
namespace Domain\Models\ValueObjects\Inco;
/**
* Represents a food additive identified by its E-number code.
*
* Maps to a single entry of LST_ADDITIF.
*
* Valid formats: E300, E471a, E160ai, E160a(i), E160a(ii), E1404, E1442
*
* @see https://en.wikipedia.org/wiki/E_number
*/
final readonly class Additive
{
public readonly string $code;
public function __construct(
string $code,
public readonly string $label,
) {
$this->code = $code;
$trimmedLabel = trim($label);
if (! preg_match('/^E\d+(?:[a-z]+(?:\([ivx]+\))?)?$/', $this->code)) {
throw new \DomainException(
"Invalid additive code '{$code}': must match E-number format (e.g. E300, E471a, E160ai, E160a(ii), E1404)"
);
}
if ($trimmedLabel === '') {
throw new \DomainException(
"Invalid label for additive '{$code}': must not be empty"
);
}
}
public function jsonSerialize(): mixed
{
return [
'code' => $this->code,
'label' => $this->label,
];
}
}

View file

@ -0,0 +1,85 @@
<?php
declare(strict_types=1);
namespace Domain\Models\ValueObjects\Inco;
final readonly class Allegations
{
/** @var string[] */
private array $allegations;
/** @var string[] */
private array $health;
/** @var string[] */
private array $nutrition;
/** @var string[] */
private array $other;
/**
* ! All array are filtered keeping only strings.
*
* @param string[] $allegations Allegations.
* @param string[] $health Health allegations.
* @param string[] $nutrition Nutrition allegations.
* @param string[] $other Other allegations.
* @return void
*/
public function __construct(
array $allegations = [],
array $health = [],
array $nutrition = [],
array $other = []
) {
$this->allegations = \array_filter($allegations, fn ($el) => ! empty($el));
$this->health = \array_filter($health, fn ($el) => ! empty($el));
$this->nutrition = \array_filter($nutrition, fn ($el) => ! empty($el));
$this->other = \array_filter($other, fn ($el) => ! empty($el));
}
// * Methods
/**
* @return string[]
*/
public function allegations(): array
{
return [...$this->allegations];
}
/**
* @return string[]
*/
public function health(): array
{
return [...$this->health];
}
/**
* @return string[]
*/
public function nutrition(): array
{
return [...$this->nutrition];
}
/**
* @return string[]
*/
public function other(): array
{
return [...$this->other];
}
public function jsonSerialize(): mixed
{
return [
'allegations' => [...$this->allegations],
'health' => [...$this->health],
'nutrition' => [...$this->nutrition],
'other' => [...$this->other],
];
}
}

View file

@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace Domain\Models\ValueObjects\Inco;
final readonly class Allergen
{
public function __construct(
public readonly int $code,
public readonly string $label
) {
if ($code <= 0) {
throw new \DomainException(
"Invalid code '{$code}' shall be greater than 0"
);
}
if (empty(trim($label))) {
throw new \DomainException(
"Invalid label '{$label}' should not be empty"
);
}
}
public function jsonSerialize(): mixed
{
return [
'code' => $this->code,
'label' => $this->label,
];
}
}

View file

@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace Domain\Models\ValueObjects\Inco;
final readonly class IncoWeight
{
/**
* @param int $netUvc In grams.
* @param int $brutUvc In grams.
* @param int $moyTheo In grams.
*/
public function __construct(
public readonly int $netUvc,
public readonly int $brutUvc,
public readonly int $moyTheo,
) {
}
public function jsonSerialize(): mixed
{
return [
'netUvc' => $this->netUvc,
'brutUvc' => $this->brutUvc,
'moyTheo' => $this->moyTheo,
];
}
}

View file

@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
namespace Domain\Models\ValueObjects\Inco;
/**
* Represents a structured and parsed ingredient list.
*
* Each entry is either:
* - an indexed group (int key) -> list of ingredient strings without a section label
* - a labelled group (string key) -> list of ingredient strings under a section label
* (e.g. "Ingrédients", "Traces possibles")
*
* @phpstan-type IngredientGroup array<int|string,string[]>
*/
final readonly class Ingredients
{
/**
* @param array<int|string,string[]> $groups
*/
public function __construct(
public readonly array $groups
) {
foreach ($groups as $key => $lines) {
if (! is_array($lines)) {
throw new \DomainException(
"Invalid ingredient group at key '{$key}': value must be an array of strings"
);
}
foreach ($lines as $i => $line) {
if (! is_string($line)) {
throw new \DomainException(
"Invalid ingredient at group '{$key}', index '{$i}': value must be a string"
);
}
if (empty(trim($line))) {
throw new \DomainException(
"Invalid ingredient at group '{$key}', index '{$i}': string should not be empty"
);
}
}
}
}
public function jsonSerialize(): mixed
{
return $this->groups;
}
}

View file

@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace Domain\Models\ValueObjects\Inco;
/**
* Represents the Nutri-Score grade of a product as displayed on pack.
*
* Valid grades are A, B, C, D and E.
*/
final readonly class Nutriscore
{
public const array VALID_GRADES = ['A', 'B', 'C', 'D', 'E'];
public function __construct(
public readonly string $grade,
) {
if (! in_array($this->grade, self::VALID_GRADES, true)) {
throw new \DomainException(
sprintf(
"Invalid Nutri-Score grade '%s': must be one of %s",
$grade,
implode(', ', self::VALID_GRADES)
)
);
}
}
public function jsonSerialize(): mixed
{
return $this->grade;
}
}

View file

@ -0,0 +1,88 @@
<?php
declare(strict_types=1);
namespace Domain\Models\ValueObjects\Inco;
/**
* Si le type de portion est exact, seul la partie basse est utilisée,
* Si le type de portion est environ, la partie basse seule ou les deux peuvent
* etre utilisés.
*/
final readonly class PortionAmount implements \JsonSerializable
{
/**
* Valeur minimale, ou exacte
*/
private readonly int $lowPart;
/**
* Valeur maximale
*/
private readonly int $highPart;
/**
* The portion is approximative
*/
private readonly bool $approximative;
/**
* The number of decimals allowed, this should not change
*/
private const ALLOWED_DECIMAL_SIZE = 2;
/**
* NbPortion
*
* @param float $lowPart Min value is 0, max depends on lowPart mask.
* @param float $highPart Min value is 0, max depends on lowPart mask.
* @return void
*
* @throws \InvalidArgumentException If lowPart part does not fit in.
* @throws \InvalidArgumentException If highPart part does not fit in.
*/
public function __construct(float $lowPart, float $highPart = 0, bool $approximative = false)
{
$maxMask = (1 << 15) - 1;
$scale = (int) pow(10, self::ALLOWED_DECIMAL_SIZE);
$maxValue = (float) bcdiv((string) $maxMask, (string) $scale, self::ALLOWED_DECIMAL_SIZE);
if ($lowPart < 0.0 || ($lowPart > $maxValue)) {
throw new \InvalidArgumentException("lowPart must be between 0 and '{$maxValue}', given '{$lowPart}'");
}
if ($highPart < 0.0 || ($highPart > $maxValue)) {
throw new \InvalidArgumentException("highPart must be between 0 and '{$maxValue}', given '{$highPart}'");
}
$this->lowPart = (int) bcmul((string) $lowPart, (string) $scale, 0);
$this->highPart = (int) bcmul((string) $highPart, (string) $scale, 0);
$this->approximative = $approximative;
}
public function lowPart(): int
{
return $this->lowPart;
}
public function highPart(): int
{
return $this->highPart;
}
public function approximative(): bool
{
return $this->approximative;
}
/**
* @return array{lowPart: int, highPart: int, approximative: bool}
*/
public function jsonSerialize(): array
{
return [
'lowPart' => $this->lowPart,
'highPart' => $this->highPart,
'approximative' => $this->approximative,
];
}
}

View file

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace Domain\Models\ValueObjects\Inco;
enum PortionType: int
{
case unknown = -1;
case approximative = 0;
case exact = 1;
public function description(): string
{
return match ($this->value) {
self::approximative->name => 'approximatif',
self::exact->name => 'exact',
self::unknown->name => 'inconnue',
default => 'inconnue',
};
}
public function jsonSerialize(): mixed
{
return [
'value' => $this->value,
'name' => $this->name,
'description' => $this->description(),
];
}
}

View file

@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
namespace Domain\Models\ValueObjects\Inco;
/**
* Represents the storage/conservation conditions of a product.
*
* Maps to CONDIT_CONSERV.
*/
final readonly class StorageCondition
{
public function __construct(
public readonly string $instructions,
) {
if (empty(trim($this->instructions))) {
throw new \DomainException(
'Invalid instructions: must not be empty'
);
}
}
public function jsonSerialize(): mixed
{
return $this->instructions;
}
}

View file

@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace Domain\Models\ValueObjects\IncoCompo;
/**
* Base class for Inco composition value objects.
*
* Intentionally empty to keep VO focused on state and invariants.
*/
abstract readonly class AbstractIncoCompoPartDto implements IncoCompoPartDto
{
}

View file

@ -0,0 +1,75 @@
<?php
declare(strict_types=1);
namespace Domain\Models\ValueObjects\IncoCompo;
final readonly class AcideGras extends AbstractIncoCompoPartDto
{
public function __construct(
// Lipides généraux
public string $nutFd,
public string $nutChol,
public string $nutAgt,
// AGS - chaîne courte à longue (classés par nb de carbones)
public string $nutFformiq,
public string $nutFacetiq,
public string $nutFpropioniq,
public string $nutFbutyriq,
public string $nutFvaleriq,
public string $nutFcaproiq,
public string $nutFenatiq,
public string $nutFcapryliq,
public string $nutFpelargoniq,
public string $nutFcapriq,
public string $nutFundecyliq,
public string $nutFlauriq,
public string $nutFtridecyliq,
public string $nutFmyristiq,
public string $nutFpentadecyliq,
public string $nutF16d0,
public string $nutFmargariq,
public string $nutFsteariq,
public string $nutFarachidiq,
public string $nutFheneicosyliq,
public string $nutFbeheniq,
public string $nutFtricosiliq,
public string $nutFlignoceriq,
public string $nutFcarboceriq,
public string $nutFcerotiq,
public string $nutFceroplastiq,
public string $nutFmontaniq,
public string $nutFnonacosyliq,
public string $nutFmelissiq,
public string $nutFlaceroiq,
public string $nutFhentriacontyliq,
public string $nutFhextriacontyliq,
public string $nutFheptatriacontyliq,
public string $nutFoctatriacontyliq,
public string $nutFnonadylique,
public string $nutFpsylliq,
// AGMI
public string $nutFpalm,
public string $nutFoleiq,
public string $nutF18d,
public string $nutF19d,
public string $nutF11eico,
public string $nutFgeddiq,
public string $nutFeruciq,
public string $nutFnervoniq,
public string $nutFhyeniq,
public string $nutFamscis,
// AGPI
public string $nutF18d2cn6,
public string $nutF18d3n3,
public string $nutF20d4,
public string $nutF20d5n3,
public string $nutF22d6n3,
public string $nutFapun3,
public string $nutFapun6,
public string $nutFapun9,
public string $nutFapucis,
public string $nutFapulc,
) {
}
}

View file

@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace Domain\Models\ValueObjects\IncoCompo;
final readonly class AcidesAmines extends AbstractIncoCompoPartDto
{
public function __construct(
public string $nutAae,
public string $nutCasn,
public string $nutWhey,
) {
}
}

View file

@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace Domain\Models\ValueObjects\IncoCompo;
final readonly class ApportsReference extends AbstractIncoCompoPartDto
{
public function __construct(
public string $pourcentApportRefE14P,
public string $pourcentApportRefKjoP,
public string $pourcentApportRefFatP,
public string $pourcentApportRefFatsatP,
public string $pourcentApportRefChovalP,
public string $pourcentApportRefSugarP,
public string $pourcentApportRefProP,
public string $pourcentApportRefSalteqP,
public string $apportPort,
public string $pSurL,
) {
}
}

View file

@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
namespace Domain\Models\ValueObjects\IncoCompo;
final readonly class ComposesSpeciaux extends AbstractIncoCompoPartDto
{
public function __construct(
public string $nutCholn,
public string $nutCarnitine,
public string $nutTau,
public string $nutNucleotide,
) {
}
}

View file

@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
namespace Domain\Models\ValueObjects\IncoCompo;
final readonly class Energie extends AbstractIncoCompoPartDto
{
public function __construct(
// Par 100g/ml (référence)
public string $tailleReference,
public string $valEnergKjReference,
public string $valEnergKcalReference,
// Par portion
public string $taillePortion,
public string $valEnergKjPortion,
public string $valEnergKcalPortion,
) {
}
}

Some files were not shown because too many files have changed in this diff Show more