219 lines
8.0 KiB
PHP
219 lines
8.0 KiB
PHP
<?php
|
||
|
||
namespace App\Filament\Admin\Resources\JobApplications;
|
||
|
||
use App\Models\CareerApplication;
|
||
use Filament\Resources\Resource;
|
||
use Filament\Schemas\Schema;
|
||
use Filament\Tables\Table;
|
||
use Filament\Forms\Components\FileUpload;
|
||
use Filament\Forms\Components\Select;
|
||
use Filament\Forms\Components\Textarea;
|
||
use Filament\Forms\Components\TextInput;
|
||
use Filament\Forms\Components\Toggle;
|
||
use Filament\Tables\Columns\TextColumn;
|
||
use Filament\Tables\Filters\SelectFilter;
|
||
use Filament\Actions\Action;
|
||
use Filament\Actions\DeleteAction;
|
||
use Filament\Actions\BulkActionGroup;
|
||
use Filament\Actions\DeleteBulkAction;
|
||
use Illuminate\Support\Facades\Storage;
|
||
use Illuminate\Database\Eloquent\Builder;
|
||
|
||
class JobApplicationResource extends Resource
|
||
{
|
||
protected static ?string $model = CareerApplication::class;
|
||
|
||
protected static \BackedEnum|string|null $navigationIcon = 'heroicon-o-briefcase';
|
||
|
||
public static function getNavigationLabel(): string
|
||
{
|
||
return __('career.job_application_title', ['default' => 'İş Başvuruları']);
|
||
}
|
||
|
||
public static function getModelLabel(): string
|
||
{
|
||
return __('career.job', ['default' => 'İş Başvurusu']);
|
||
}
|
||
|
||
public static function getPluralModelLabel(): string
|
||
{
|
||
return __('career.job_application_title', ['default' => 'İş Başvuruları']);
|
||
}
|
||
|
||
public static function getEloquentQuery(): Builder
|
||
{
|
||
return parent::getEloquentQuery()->where('type', 'job');
|
||
}
|
||
|
||
public static function form(Schema $schema): Schema
|
||
{
|
||
return $schema
|
||
->components([
|
||
TextInput::make('name')
|
||
->label(__('career.name'))
|
||
->required()
|
||
->disabled(),
|
||
|
||
TextInput::make('email')
|
||
->label(__('career.email'))
|
||
->email()
|
||
->required()
|
||
->disabled(),
|
||
|
||
TextInput::make('phone')
|
||
->label(__('career.phone'))
|
||
->disabled(),
|
||
|
||
Select::make('status')
|
||
->label(__('career.status'))
|
||
->options([
|
||
'pending' => __('career.pending'),
|
||
'reviewed' => __('career.reviewed'),
|
||
'rejected' => __('career.rejected'),
|
||
'accepted' => __('career.accepted'),
|
||
'waiting_document' => __('career.waiting_document'),
|
||
])
|
||
->required(),
|
||
|
||
FileUpload::make('cv_path')
|
||
->label(__('career.cv'))
|
||
->disk('public')
|
||
->directory('cvs')
|
||
->required()
|
||
->disabled()
|
||
->downloadable(),
|
||
|
||
FileUpload::make('nda_path')
|
||
->label(__('career.nda'))
|
||
->disk('public')
|
||
->directory('ndas')
|
||
->disabled()
|
||
->downloadable(),
|
||
|
||
FileUpload::make('contract_path')
|
||
->label(__('career.contract'))
|
||
->disk('public')
|
||
->directory('contracts')
|
||
->disabled()
|
||
->downloadable(),
|
||
|
||
FileUpload::make('id_photocopy_path')
|
||
->label(__('career.id_photocopy', ['default' => 'Kimlik Fotokopisi']))
|
||
->disk('public')
|
||
->directory('id_photocopies')
|
||
->disabled()
|
||
->downloadable(),
|
||
|
||
Toggle::make('git_knowledge')
|
||
->label(__('career.git_knowledge'))
|
||
->disabled(),
|
||
|
||
Toggle::make('ai_usage')
|
||
->label(__('career.ai_usage'))
|
||
->disabled(),
|
||
|
||
Textarea::make('message')
|
||
->label(__('career.message'))
|
||
->disabled()
|
||
->columnSpanFull(),
|
||
]);
|
||
}
|
||
|
||
public static function table(Table $table): Table
|
||
{
|
||
return $table
|
||
->columns([
|
||
TextColumn::make('name')
|
||
->label(__('career.name'))
|
||
->searchable()
|
||
->sortable(),
|
||
|
||
TextColumn::make('email')
|
||
->label(__('career.email'))
|
||
->searchable()
|
||
->sortable(),
|
||
|
||
TextColumn::make('phone')
|
||
->label(__('career.phone'))
|
||
->searchable(),
|
||
|
||
TextColumn::make('status')
|
||
->label(__('career.status'))
|
||
->badge()
|
||
->color(fn (string $state): string => match ($state) {
|
||
'pending' => 'gray',
|
||
'reviewed' => 'info',
|
||
'rejected' => 'danger',
|
||
'accepted' => 'success',
|
||
'waiting_document' => 'warning',
|
||
default => 'gray',
|
||
})
|
||
->formatStateUsing(fn (string $state): string => __("career.{$state}")),
|
||
|
||
TextColumn::make('git_knowledge')
|
||
->label(__('career.git_knowledge'))
|
||
->badge()
|
||
->color(fn ($state) => $state ? 'success' : 'danger')
|
||
->formatStateUsing(fn ($state) => $state ? 'Evet' : 'Hayır'),
|
||
|
||
TextColumn::make('ai_usage')
|
||
->label(__('career.ai_usage'))
|
||
->badge()
|
||
->color(fn ($state) => $state ? 'success' : 'danger')
|
||
->formatStateUsing(fn ($state) => $state ? 'Evet' : 'Hayır'),
|
||
|
||
TextColumn::make('created_at')
|
||
->label(__('career.created_at'))
|
||
->dateTime('d.m.Y H:i')
|
||
->sortable(),
|
||
])
|
||
->filters([
|
||
SelectFilter::make('status')
|
||
->label(__('career.status'))
|
||
->options([
|
||
'pending' => __('career.pending'),
|
||
'reviewed' => __('career.reviewed'),
|
||
'rejected' => __('career.rejected'),
|
||
'accepted' => __('career.accepted'),
|
||
'waiting_document' => __('career.waiting_document'),
|
||
]),
|
||
])
|
||
->actions([
|
||
Action::make('download_cv')
|
||
->label(__('career.download_cv'))
|
||
->icon('heroicon-o-arrow-down-tray')
|
||
->url(fn ($record) => Storage::disk('public')->url($record->cv_path))
|
||
->openUrlInNewTab(),
|
||
Action::make('download_nda')
|
||
->label(__('career.nda'))
|
||
->icon('heroicon-o-shield-check')
|
||
->url(fn ($record) => $record->nda_path ? Storage::disk('public')->url($record->nda_path) : null)
|
||
->visible(fn ($record) => $record->nda_path !== null)
|
||
->openUrlInNewTab(),
|
||
Action::make('download_contract')
|
||
->label(__('career.contract'))
|
||
->icon('heroicon-o-document-text')
|
||
->url(fn ($record) => $record->contract_path ? Storage::disk('public')->url($record->contract_path) : null)
|
||
->visible(fn ($record) => $record->contract_path !== null)
|
||
->openUrlInNewTab(),
|
||
DeleteAction::make(),
|
||
])
|
||
->bulkActions([
|
||
BulkActionGroup::make([
|
||
DeleteBulkAction::make(),
|
||
]),
|
||
])
|
||
->defaultSort('created_at', 'desc');
|
||
}
|
||
|
||
public static function getPages(): array
|
||
{
|
||
return [
|
||
'index' => Pages\ListJobApplications::route('/'),
|
||
'create' => Pages\CreateJobApplication::route('/create'),
|
||
'edit' => Pages\EditJobApplication::route('/{record}/edit'),
|
||
];
|
||
}
|
||
}
|