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')
|
TextInput::make('username')
|
||||||
->label('Kullanıcı Adı')
|
->label('Kullanıcı Adı')
|
||||||
->unique(ignoreRecord: true)
|
->default(fn ($record) => $record?->email)
|
||||||
->nullable(),
|
->disabled()
|
||||||
|
->dehydrated()
|
||||||
|
->autocomplete('new-username'),
|
||||||
|
|
||||||
TextInput::make('password')
|
TextInput::make('password')
|
||||||
->label('Şifre')
|
->label('Şifre')
|
||||||
->password()
|
->password()
|
||||||
->revealable()
|
->revealable()
|
||||||
|
->autocomplete('new-password')
|
||||||
->formatStateUsing(fn () => null)
|
->formatStateUsing(fn () => null)
|
||||||
->dehydrateStateUsing(fn ($state) => filled($state) ? Hash::make($state) : null)
|
->dehydrateStateUsing(fn ($state) => filled($state) ? Hash::make($state) : null)
|
||||||
->dehydrated(fn ($state) => filled($state))
|
->dehydrated(fn ($state) => filled($state))
|
||||||
|
|||||||
@@ -37,12 +37,15 @@ class CareerApplication extends Model
|
|||||||
protected static function booted()
|
protected static function booted()
|
||||||
{
|
{
|
||||||
static::saving(function ($model) {
|
static::saving(function ($model) {
|
||||||
if ($model->type === 'internship' && !$model->certificate_code) {
|
if ($model->type === 'internship') {
|
||||||
|
$model->username = $model->email;
|
||||||
|
if (!$model->certificate_code) {
|
||||||
do {
|
do {
|
||||||
$code = 'TRN-' . date('Y') . '-' . strtoupper(\Illuminate\Support\Str::random(4)) . '-' . strtoupper(\Illuminate\Support\Str::random(4));
|
$code = 'TRN-' . date('Y') . '-' . strtoupper(\Illuminate\Support\Str::random(4)) . '-' . strtoupper(\Illuminate\Support\Str::random(4));
|
||||||
} while (static::where('certificate_code', $code)->exists());
|
} while (static::where('certificate_code', $code)->exists());
|
||||||
$model->certificate_code = $code;
|
$model->certificate_code = $code;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -495,27 +495,15 @@
|
|||||||
|
|
||||||
<div class="flex items-center gap-2 w-full sm:w-auto">
|
<div class="flex items-center gap-2 w-full sm:w-auto">
|
||||||
@if($intern->to_be_signed_internship_form_path)
|
@if($intern->to_be_signed_internship_form_path)
|
||||||
<a href="{{ Storage::disk('public')->url($intern->to_be_signed_internship_form_path) }}" target="_blank" class="px-4 py-2.5 bg-slate-850 hover:bg-slate-900 text-white font-bold rounded-xl text-xs transition-all flex items-center justify-center gap-1.5 shadow-sm">
|
<a href="{{ Storage::disk('public')->url($intern->to_be_signed_internship_form_path) }}" target="_blank" class="px-4 py-2.5 bg-slate-800 hover:bg-slate-900 text-white font-bold rounded-xl text-xs transition-all flex items-center justify-center gap-1.5 shadow-sm">
|
||||||
<i class="uil uil-arrow-down-tray"></i>
|
<i class="uil uil-arrow-down-tray"></i>
|
||||||
<span>Görüntüle</span>
|
<span>Görüntüle</span>
|
||||||
</a>
|
</a>
|
||||||
@if(!$intern->signed_internship_form_path)
|
|
||||||
<button type="button" onclick="document.getElementById('upload-form-wrapper').classList.toggle('hidden')" class="px-4 py-2.5 bg-blue-50 hover:bg-blue-100 text-blue-600 font-bold rounded-xl text-xs transition-all flex items-center justify-center gap-1.5">
|
|
||||||
<i class="uil uil-edit"></i>
|
|
||||||
<span>Değiştir</span>
|
|
||||||
</button>
|
|
||||||
@endif
|
|
||||||
@else
|
|
||||||
<button type="button" onclick="document.getElementById('upload-form-wrapper').classList.toggle('hidden')" class="w-full sm:w-auto px-5 py-2.5 bg-blue-600 hover:bg-blue-700 text-white font-bold rounded-xl text-sm transition-all flex items-center justify-center gap-2 shadow-md shadow-blue-500/10">
|
|
||||||
<i class="uil uil-plus"></i>
|
|
||||||
<span>Yükle</span>
|
|
||||||
</button>
|
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if(!$intern->signed_internship_form_path)
|
<div id="upload-form-wrapper" class="mt-4 border-t border-slate-100 pt-4">
|
||||||
<div id="upload-form-wrapper" class="{{ $intern->to_be_signed_internship_form_path ? 'hidden' : '' }} mt-4 border-t border-slate-100 pt-4">
|
|
||||||
<form action="{{ route('intern.upload-form') }}" method="POST" enctype="multipart/form-data" class="space-y-4">
|
<form action="{{ route('intern.upload-form') }}" method="POST" enctype="multipart/form-data" class="space-y-4">
|
||||||
@csrf
|
@csrf
|
||||||
|
|
||||||
@@ -576,11 +564,11 @@
|
|||||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||||
<div>
|
<div>
|
||||||
<label for="internship_start_date" class="block text-xs font-extrabold text-slate-500 uppercase tracking-wider mb-1.5">Staj Başlangıç Tarihi</label>
|
<label for="internship_start_date" class="block text-xs font-extrabold text-slate-500 uppercase tracking-wider mb-1.5">Staj Başlangıç Tarihi</label>
|
||||||
<input type="date" name="internship_start_date" id="internship_start_date" onchange="calculateEndDateFrontend()" oninput="calculateEndDateFrontend()" required value="{{ $intern->internship_start_date }}" class="w-full px-4 py-3 rounded-xl border border-slate-200 focus:border-blue-400 focus:ring-1 focus:ring-blue-400 focus:outline-none text-sm font-semibold text-slate-700 bg-white transition-all" />
|
<input type="date" name="internship_start_date" id="internship_start_date" onchange="calculateEndDateFrontend()" oninput="calculateEndDateFrontend()" required value="{{ $intern->internship_start_date }}" @if($intern->status !== 'pending') disabled @endif class="w-full px-4 py-3 rounded-xl border border-slate-200 focus:border-blue-400 focus:ring-1 focus:ring-blue-400 focus:outline-none text-sm font-semibold text-slate-700 bg-white transition-all disabled:bg-slate-50 disabled:text-slate-500 disabled:cursor-not-allowed" />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label for="internship_total_days" class="block text-xs font-extrabold text-slate-500 uppercase tracking-wider mb-1.5">Staj Süresi (İş Günü)</label>
|
<label for="internship_total_days" class="block text-xs font-extrabold text-slate-500 uppercase tracking-wider mb-1.5">Staj Süresi (İş Günü)</label>
|
||||||
<input type="number" name="internship_total_days" id="internship_total_days" onchange="calculateEndDateFrontend()" oninput="calculateEndDateFrontend()" min="1" required value="{{ $intern->internship_total_days }}" placeholder="Örn: 20" class="w-full px-4 py-3 rounded-xl border border-slate-200 focus:border-blue-400 focus:ring-1 focus:ring-blue-400 focus:outline-none text-sm font-semibold text-slate-700 bg-white transition-all" />
|
<input type="number" name="internship_total_days" id="internship_total_days" onchange="calculateEndDateFrontend()" oninput="calculateEndDateFrontend()" min="1" required value="{{ $intern->internship_total_days }}" placeholder="Örn: 20" @if($intern->status !== 'pending') disabled @endif class="w-full px-4 py-3 rounded-xl border border-slate-200 focus:border-blue-400 focus:ring-1 focus:ring-blue-400 focus:outline-none text-sm font-semibold text-slate-700 bg-white transition-all disabled:bg-slate-50 disabled:text-slate-500 disabled:cursor-not-allowed" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
@@ -589,6 +577,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@if($intern->status === 'pending')
|
||||||
<div class="relative border-2 border-dashed border-slate-200 hover:border-blue-400 rounded-2xl p-6 transition-all bg-white flex flex-col items-center justify-center text-center cursor-pointer group">
|
<div class="relative border-2 border-dashed border-slate-200 hover:border-blue-400 rounded-2xl p-6 transition-all bg-white flex flex-col items-center justify-center text-center cursor-pointer group">
|
||||||
<input type="file" name="internship_form" id="internship_form" accept=".pdf,.docx,.jpg,.png,.jpeg" onchange="handleFileSelected(this)" class="absolute inset-0 w-full h-full opacity-0 cursor-pointer z-10" />
|
<input type="file" name="internship_form" id="internship_form" accept=".pdf,.docx,.jpg,.png,.jpeg" onchange="handleFileSelected(this)" class="absolute inset-0 w-full h-full opacity-0 cursor-pointer z-10" />
|
||||||
<i class="uil uil-cloud-upload text-4xl text-slate-400 group-hover:text-blue-500 transition-colors mb-2"></i>
|
<i class="uil uil-cloud-upload text-4xl text-slate-400 group-hover:text-blue-500 transition-colors mb-2"></i>
|
||||||
@@ -603,9 +592,13 @@
|
|||||||
<span>Dosyayı Kaydet</span>
|
<span>Dosyayı Kaydet</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
@else
|
||||||
|
<div class="p-4 bg-slate-50 border border-slate-100 rounded-2xl text-center text-xs text-slate-500 font-semibold">
|
||||||
|
<i class="uil uil-lock-alt text-base mr-1"></i> Başvurunuz bekleme aşamasında (beklemede) olmadığı için staj bilgilerinizi ve dosyanızı güncelleyemezsiniz.
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Signed Internship Form Card -->
|
<!-- Signed Internship Form Card -->
|
||||||
|
|||||||
Reference in New Issue
Block a user