refactor: restrict intern dashboard updates to pending status and automate username assignment from email
This commit is contained in:
@@ -107,13 +107,16 @@ class InternApplicationResource extends Resource
|
||||
|
||||
TextInput::make('username')
|
||||
->label('Kullanıcı Adı')
|
||||
->unique(ignoreRecord: true)
|
||||
->nullable(),
|
||||
->default(fn ($record) => $record?->email)
|
||||
->disabled()
|
||||
->dehydrated()
|
||||
->autocomplete('new-username'),
|
||||
|
||||
TextInput::make('password')
|
||||
->label('Şifre')
|
||||
->password()
|
||||
->revealable()
|
||||
->autocomplete('new-password')
|
||||
->formatStateUsing(fn () => null)
|
||||
->dehydrateStateUsing(fn ($state) => filled($state) ? Hash::make($state) : null)
|
||||
->dehydrated(fn ($state) => filled($state))
|
||||
|
||||
@@ -37,11 +37,14 @@ class CareerApplication extends Model
|
||||
protected static function booted()
|
||||
{
|
||||
static::saving(function ($model) {
|
||||
if ($model->type === 'internship' && !$model->certificate_code) {
|
||||
do {
|
||||
$code = 'TRN-' . date('Y') . '-' . strtoupper(\Illuminate\Support\Str::random(4)) . '-' . strtoupper(\Illuminate\Support\Str::random(4));
|
||||
} while (static::where('certificate_code', $code)->exists());
|
||||
$model->certificate_code = $code;
|
||||
if ($model->type === 'internship') {
|
||||
$model->username = $model->email;
|
||||
if (!$model->certificate_code) {
|
||||
do {
|
||||
$code = 'TRN-' . date('Y') . '-' . strtoupper(\Illuminate\Support\Str::random(4)) . '-' . strtoupper(\Illuminate\Support\Str::random(4));
|
||||
} while (static::where('certificate_code', $code)->exists());
|
||||
$model->certificate_code = $code;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user