149 lines
5.2 KiB
PHP
149 lines
5.2 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources;
|
|
|
|
use App\Filament\Resources\AlertMailRuleResource\Pages;
|
|
use App\Filament\Resources\AlertMailRuleResource\RelationManagers;
|
|
use App\Models\AlertMailRule;
|
|
use Filament\Facades\Filament;
|
|
use Filament\Forms;
|
|
use Filament\Forms\Form;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Table;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
|
use Filament\Forms\Components\Section;
|
|
|
|
class AlertMailRuleResource extends Resource
|
|
{
|
|
protected static ?string $model = AlertMailRule::class;
|
|
|
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
|
|
|
protected static ?string $navigationGroup = 'Alert Mail';
|
|
|
|
public static function form(Form $form): Form
|
|
{
|
|
return $form
|
|
->schema([
|
|
Section::make('')
|
|
->schema([
|
|
Forms\Components\Select::make('module')
|
|
->label('Module')
|
|
->required()
|
|
->options([
|
|
'InvoiceValidation' => 'InvoiceValidation',
|
|
'QualityValidation' => 'QualityValidation',
|
|
'ProductionQuantities' => 'ProductionQuantities',
|
|
]),
|
|
Forms\Components\Select::make('rule_name')
|
|
->label('Rule Name')
|
|
->options([
|
|
'InvoiceMail' => 'Invoice Mail',
|
|
'SerialInvoiceMail' => 'Serial Invoice Mail',
|
|
'MaterialInvoiceMail' => 'Material Invoice Mail',
|
|
'ProductionMail' => 'Production Mail',
|
|
])
|
|
->required(),
|
|
Forms\Components\TextInput::make('email')
|
|
->label('Email')
|
|
->required(),
|
|
Forms\Components\Select::make('schedule_type')
|
|
->label('Schedule Type')
|
|
->required()
|
|
->options([
|
|
'Live' => 'Live',
|
|
'Hourly' => 'Hourly',
|
|
'Daily' => 'Daily',
|
|
]),
|
|
Forms\Components\Hidden::make('created_by')
|
|
->default(fn () => Filament::auth()->user()?->name),
|
|
Forms\Components\Hidden::make('updated_by')
|
|
->default(fn () => Filament::auth()->user()?->name),
|
|
])
|
|
->columns(4),
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
Tables\Columns\TextColumn::make('id')
|
|
->label('ID')
|
|
->numeric()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('module')
|
|
->label('Module')
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('rule_name')
|
|
->label('Rule Name')
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('email')
|
|
->label('Email')
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('schedule_type')
|
|
->label('Schedule Type')
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('created_at')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
Tables\Columns\TextColumn::make('created_by')
|
|
->label('Created By')
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('updated_at')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
Tables\Columns\TextColumn::make('updated_by')
|
|
->label('Updated By')
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('deleted_at')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
])
|
|
->filters([
|
|
Tables\Filters\TrashedFilter::make(),
|
|
])
|
|
->actions([
|
|
Tables\Actions\ViewAction::make(),
|
|
Tables\Actions\EditAction::make(),
|
|
])
|
|
->bulkActions([
|
|
Tables\Actions\BulkActionGroup::make([
|
|
Tables\Actions\DeleteBulkAction::make(),
|
|
Tables\Actions\ForceDeleteBulkAction::make(),
|
|
Tables\Actions\RestoreBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public static function getRelations(): array
|
|
{
|
|
return [
|
|
//
|
|
];
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => Pages\ListAlertMailRules::route('/'),
|
|
'create' => Pages\CreateAlertMailRule::route('/create'),
|
|
'view' => Pages\ViewAlertMailRule::route('/{record}'),
|
|
'edit' => Pages\EditAlertMailRule::route('/{record}/edit'),
|
|
];
|
|
}
|
|
|
|
public static function getEloquentQuery(): Builder
|
|
{
|
|
return parent::getEloquentQuery()
|
|
->withoutGlobalScopes([
|
|
SoftDeletingScope::class,
|
|
]);
|
|
}
|
|
}
|