Manage calls and the inbox through the API

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-30 19:42:59 +02:00
parent b02464a7ed
commit 4c65604f04
11 changed files with 890 additions and 1 deletions

View File

@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace App\Http\Requests\Api\V1;
use App\Enums\ApplicationStatus;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
/**
* What the inbox lets anyone change about a submission: nothing the sender
* wrote, only how it is being handled.
*/
class ApplicationRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
/**
* @return array<string, mixed>
*/
public function rules(): array
{
return [
'status' => ['sometimes', Rule::enum(ApplicationStatus::class)],
'notes' => ['sometimes', 'nullable', 'string', 'max:10000'],
];
}
}

View File

@@ -0,0 +1,58 @@
<?php
declare(strict_types=1);
namespace App\Http\Requests\Api\V1;
use App\Enums\CallStatus;
use App\Models\Call;
use App\Rules\Translatable;
use App\Rules\UniqueTranslatedSlug;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
/**
* The panel's call form, as rules. `technology_ids` is replaced whole when
* sent.
*/
class CallRequest extends FormRequest
{
public const SENIORITIES = ['any', 'junior', 'mid', 'senior'];
public function authorize(): bool
{
return true;
}
/**
* @return array<string, mixed>
*/
public function rules(): array
{
$call = $this->route('call');
$creating = ! $call instanceof Call;
$sometimes = $creating ? 'required' : 'sometimes';
return [
'title' => [$sometimes, new Translatable(requireDefaultLocale: $creating, max: 255)],
'slug' => [
$sometimes,
new Translatable(requireDefaultLocale: $creating, max: 255),
new UniqueTranslatedSlug(Call::class, $call?->id),
],
'description' => ['sometimes', 'nullable', new Translatable],
'what_you_get' => ['sometimes', 'nullable', new Translatable],
'status' => ['sometimes', Rule::enum(CallStatus::class)],
'hours_per_week' => ['sometimes', 'nullable', 'integer', 'min:1', 'max:40'],
'duration_weeks' => ['sometimes', 'nullable', 'integer', 'min:1'],
'seniority' => ['sometimes', 'nullable', Rule::in(self::SENIORITIES)],
'opens_at' => ['sometimes', 'nullable', 'date'],
'closes_at' => ['sometimes', 'nullable', 'date', 'after_or_equal:opens_at'],
'project_id' => ['sometimes', 'nullable', 'integer', Rule::exists('projects', 'id')->whereNull('deleted_at')],
'technology_ids' => ['sometimes', 'array'],
'technology_ids.*' => ['integer', 'distinct', Rule::exists('technologies', 'id')],
];
}
}