siakad-itm/app/Concerns/ProfileValidationRules.php
Yoga Pangestu 5cc8ba26b2
Some checks failed
tests / ci (pull_request) Has been cancelled
feat: update user registration to use username instead of name, add user profile model and migration, and implement gender enum
- Changed user creation to use 'username' instead of 'name'.
- Added UserProfile model with relationships to User and gender enum.
- Updated validation rules for username and email.
- Modified migrations to create user_profiles table and adjust users table.
- Updated seeder to create users with profiles.
- Translated various UI texts to Indonesian and improved layout components.
2026-08-03 13:43:30 +07:00

45 lines
1015 B
PHP

<?php
namespace App\Concerns;
use App\Models\User;
use Illuminate\Validation\Rule;
trait ProfileValidationRules
{
protected function profileRules(?int $userId = null): array
{
return [
'username' => $this->usernameRules($userId),
'email' => $this->emailRules($userId),
];
}
protected function usernameRules(?int $userId = null): array
{
return [
'required',
'string',
'max:20',
'min:3',
'alpha_dash',
$userId === null
? Rule::unique(User::class)
: Rule::unique(User::class)->ignore($userId),
];
}
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),
];
}
}