Merge branch 'main' into new-big-calendar-feature

This commit is contained in:
Adrian Hopek 2022-04-06 10:00:19 +02:00
commit 82b4ada49e
16 changed files with 879 additions and 244 deletions

View File

@ -45,7 +45,7 @@ jobs:
run: composer install --prefer-dist --no-interaction --no-suggest
- name: Run PHP linter
run: composer ecs
run: composer cs
- name: Execute tests
run: php artisan test --env=ci

View File

@ -1,3 +1,3 @@
web: vendor/bin/heroku-php-nginx -C environment/prod/nginx.conf public/
release: php artisan migrate --force && php artisan cache:clear && php artisan config:cache
release: php artisan config:cache && php artisan route:cache && php artisan migrate --force
worker: php artisan queue:work

View File

@ -6,12 +6,15 @@ namespace Toby\Architecture\Providers;
use Illuminate\Support\ServiceProvider;
use Toby\Eloquent\Models\User;
use Toby\Eloquent\Models\VacationRequest;
use Toby\Eloquent\Observers\UserObserver;
use Toby\Eloquent\Observers\VacationRequestObserver;
class ObserverServiceProvider extends ServiceProvider
{
public function boot(): void
{
User::observe(UserObserver::class);
VacationRequest::observe(VacationRequestObserver::class);
}
}

View File

@ -91,11 +91,6 @@ class VacationRequest extends Model
->where("to", ">=", $vacationRequest->from);
}
public function getNameAttribute(): string
{
return "{$this->id}/{$this->yearPeriod->year}";
}
public function hasFlowSkipped(): bool
{
return $this->flow_skipped;

View File

@ -15,6 +15,7 @@ use Illuminate\Support\Collection;
* @property int $id
* @property int $year
* @property Collection $vacationLimits
* @property Collection $vacationRequests
* @property Collection $holidays
*/
class YearPeriod extends Model
@ -41,6 +42,11 @@ class YearPeriod extends Model
return $this->hasMany(VacationLimit::class);
}
public function vacationRequests(): HasMany
{
return $this->hasMany(VacationRequest::class);
}
public function holidays(): HasMany
{
return $this->hasMany(Holiday::class);

View File

@ -0,0 +1,18 @@
<?php
declare(strict_types=1);
namespace Toby\Eloquent\Observers;
use Toby\Eloquent\Models\VacationRequest;
class VacationRequestObserver
{
public function creating(VacationRequest $vacationRequest): void
{
$count = $vacationRequest->yearPeriod->vacationRequests()->count();
$number = $count + 1;
$vacationRequest->name = "{$number}/{$vacationRequest->yearPeriod->year}";
}
}

View File

@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace Toby\Infrastructure\Console\Commands;
use Illuminate\Console\Command;
use Toby\Eloquent\Models\YearPeriod;
class RebuildDocumentNumberingSystem extends Command
{
protected $signature = "toby:rebuild-document-numbering-system";
protected $description = "Rebuilds the document numbering system to {number}/{year}";
public function handle(): void
{
$yearPeriods = YearPeriod::all();
foreach ($yearPeriods as $yearPeriod) {
$number = 1;
$vacationRequests = $yearPeriod
->vacationRequests()
->oldest()
->get();
foreach ($vacationRequests as $vacationRequest) {
$vacationRequest->update(["name" => "{$number}/{$yearPeriod->year}"]);
$number++;
}
}
}
}

View File

@ -1,6 +1,8 @@
#!/usr/bin/env php
<?php
declare(strict_types=1);
use Illuminate\Contracts\Console\Kernel;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\ConsoleOutput;

View File

@ -7,7 +7,7 @@ use Blumilk\Codestyle\Configuration\Defaults\LaravelPaths;
$paths = new LaravelPaths();
$config = new Config(
paths: $paths->add("public", "bootstrap/app.php", "ecs.php", "server.php"),
paths: $paths->add("codestyle.php"),
);
return $config->config();

View File

@ -13,7 +13,7 @@
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"inertiajs/inertia-laravel": "^0.5.1",
"laravel/framework": "^9.0",
"laravel/framework": "9.5.*",
"laravel/sanctum": "^2.14",
"laravel/socialite": "^5.2",
"laravel/telescope": "^4.6",
@ -24,7 +24,7 @@
"spatie/laravel-model-states": "^2.1"
},
"require-dev": {
"blumilksoftware/codestyle": "^0.10.0",
"blumilksoftware/codestyle": "^1.0.0",
"fakerphp/faker": "^1.19",
"laravel/dusk": "^6.21",
"mockery/mockery": "^1.4.4",
@ -45,8 +45,8 @@
}
},
"scripts": {
"ecs": "./vendor/bin/ecs check --clear-cache",
"ecsf": "./vendor/bin/ecs check --clear-cache --fix",
"cs": "./vendor/bin/php-cs-fixer fix --dry-run --diff --config codestyle.php",
"csf": "./vendor/bin/php-cs-fixer fix --diff --config codestyle.php",
"test": "@php artisan test",
"fresh": "@php artisan migrate:fresh",
"fresh:demo": [

969
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,23 @@
<?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 {
public function up(): void
{
Schema::table("vacation_requests", function (Blueprint $table): void {
$table->string("name")->nullable();
});
}
public function down(): void
{
Schema::table("vacation_requests", function (Blueprint $table): void {
$table->dropColumn("name");
});
}
};

28
package-lock.json generated
View File

@ -17,7 +17,7 @@
"@vue/compiler-sfc": "^3.2.31",
"autoprefixer": "^10.4.4",
"axios": "^0.26.1",
"echarts": "^5.3.1",
"echarts": "^5.3.2",
"eslit": "^6.0.0",
"flatpickr": "^4.6.11",
"laravel-mix": "^6.0.43",
@ -34,7 +34,7 @@
"vue3-popper": "^1.4.2"
},
"devDependencies": {
"eslint": "^8.11.0",
"eslint": "^8.12.0",
"eslint-plugin-tailwindcss": "^3.5.0",
"eslint-plugin-vue": "^8.5.0"
}
@ -4167,9 +4167,9 @@
"integrity": "sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA=="
},
"node_modules/echarts": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/echarts/-/echarts-5.3.1.tgz",
"integrity": "sha512-nWdlbgX3OVY0hpqncSvp0gDt1FRSKWn7lsWEH+PHmfCuvE0QmSw17pczQvm8AvawnLEkmf1Cts7YwQJZNC0AEQ==",
"version": "5.3.2",
"resolved": "https://registry.npmjs.org/echarts/-/echarts-5.3.2.tgz",
"integrity": "sha512-LWCt7ohOKdJqyiBJ0OGBmE9szLdfA9sGcsMEi+GGoc6+Xo75C+BkcT/6NNGRHAWtnQl2fNow05AQjznpap28TQ==",
"dependencies": {
"tslib": "2.3.0",
"zrender": "5.3.1"
@ -4295,9 +4295,9 @@
}
},
"node_modules/eslint": {
"version": "8.11.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.11.0.tgz",
"integrity": "sha512-/KRpd9mIRg2raGxHRGwW9ZywYNAClZrHjdueHcrVDuO3a6bj83eoTirCCk0M0yPwOjWYKHwRVRid+xK4F/GHgA==",
"version": "8.12.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.12.0.tgz",
"integrity": "sha512-it1oBL9alZg1S8UycLm5YDMAkIhtH6FtAzuZs6YvoGVldWjbS08BkAdb/ymP9LlAyq8koANu32U7Ib/w+UNh8Q==",
"dev": true,
"dependencies": {
"@eslint/eslintrc": "^1.2.1",
@ -12762,9 +12762,9 @@
"integrity": "sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA=="
},
"echarts": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/echarts/-/echarts-5.3.1.tgz",
"integrity": "sha512-nWdlbgX3OVY0hpqncSvp0gDt1FRSKWn7lsWEH+PHmfCuvE0QmSw17pczQvm8AvawnLEkmf1Cts7YwQJZNC0AEQ==",
"version": "5.3.2",
"resolved": "https://registry.npmjs.org/echarts/-/echarts-5.3.2.tgz",
"integrity": "sha512-LWCt7ohOKdJqyiBJ0OGBmE9szLdfA9sGcsMEi+GGoc6+Xo75C+BkcT/6NNGRHAWtnQl2fNow05AQjznpap28TQ==",
"requires": {
"tslib": "2.3.0",
"zrender": "5.3.1"
@ -12865,9 +12865,9 @@
"dev": true
},
"eslint": {
"version": "8.11.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.11.0.tgz",
"integrity": "sha512-/KRpd9mIRg2raGxHRGwW9ZywYNAClZrHjdueHcrVDuO3a6bj83eoTirCCk0M0yPwOjWYKHwRVRid+xK4F/GHgA==",
"version": "8.12.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.12.0.tgz",
"integrity": "sha512-it1oBL9alZg1S8UycLm5YDMAkIhtH6FtAzuZs6YvoGVldWjbS08BkAdb/ymP9LlAyq8koANu32U7Ib/w+UNh8Q==",
"dev": true,
"requires": {
"@eslint/eslintrc": "^1.2.1",

View File

@ -24,7 +24,7 @@
"@vue/compiler-sfc": "^3.2.31",
"autoprefixer": "^10.4.4",
"axios": "^0.26.1",
"echarts": "^5.3.1",
"echarts": "^5.3.2",
"eslit": "^6.0.0",
"flatpickr": "^4.6.11",
"laravel-mix": "^6.0.43",
@ -41,7 +41,7 @@
"vue3-popper": "^1.4.2"
},
"devDependencies": {
"eslint": "^8.11.0",
"eslint": "^8.12.0",
"eslint-plugin-tailwindcss": "^3.5.0",
"eslint-plugin-vue": "^8.5.0"
}

View File

@ -71,10 +71,8 @@ If xDebug is installed, set environment variable **XDEBUG_MODE=off** to improve
### Code style check
dcr php php vendor/bin/ecs check
dcr php composer ecs
dcr php php vendor/bin/ecs check --fix
dcr php composer ecsf
dcr php composer cs
dcr php composer csf
dcr node npm run lint
dcr node npm run lintf

View File

@ -1,11 +0,0 @@
<?php
declare(strict_types=1);
$uri = urldecode(parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH));
if ($uri !== "/" && file_exists(__DIR__ . "/public" . $uri)) {
return false;
}
require_once __DIR__ . "/public/index.php";