Initial commit of the L'Ami Fiduciaire SaaS platform built on Laravel 12, Vue 3, Inertia.js 2, and Tailwind CSS 4. Story 0.1 (rename folders to declarations in database) is implemented and code-reviewed: migration, rollback, and 6 Pest tests all passing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
51 lines
1.2 KiB
PHP
51 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Concerns;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
trait ProfileValidationRules
|
|
{
|
|
/**
|
|
* Get the validation rules used to validate user profiles.
|
|
*
|
|
* @return array<string, array<int, \Illuminate\Contracts\Validation\Rule|array<mixed>|string>>
|
|
*/
|
|
protected function profileRules(?int $userId = null): array
|
|
{
|
|
return [
|
|
'name' => $this->nameRules(),
|
|
'email' => $this->emailRules($userId),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules used to validate user names.
|
|
*
|
|
* @return array<int, \Illuminate\Contracts\Validation\Rule|array<mixed>|string>
|
|
*/
|
|
protected function nameRules(): array
|
|
{
|
|
return ['required', 'string', 'max:255'];
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules used to validate user emails.
|
|
*
|
|
* @return array<int, \Illuminate\Contracts\Validation\Rule|array<mixed>|string>
|
|
*/
|
|
protected function emailRules(?int $userId = null): array
|
|
{
|
|
return [
|
|
'required',
|
|
'string',
|
|
'email',
|
|
'max:255',
|
|
$userId === null
|
|
? Rule::unique(User::class)
|
|
: Rule::unique(User::class)->ignore($userId),
|
|
];
|
|
}
|
|
}
|