Implement projects and project keys

This commit is contained in:
2026-03-25 00:44:37 +01:00
parent aeee3d2640
commit 7d4b0733b3
16 changed files with 716 additions and 1 deletions
+46
View File
@@ -0,0 +1,46 @@
<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class StoreProjectRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return $this->user() !== null;
}
protected function prepareForValidation(): void
{
if ($this->has('key')) {
$this->merge([
'key' => strtoupper((string) $this->string('key')->trim()),
]);
}
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'key' => [
'required',
'string',
'max:5',
'regex:/^[A-Z0-9]+$/',
Rule::unique('projects', 'key'),
],
'name' => ['required', 'string', 'max:255'],
];
}
}