Added Row Number, label, alignment on filter report and view rights for Importer and Exporter
This commit is contained in:
@@ -2,11 +2,13 @@
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\ShiftExporter;
|
||||
use App\Filament\Imports\ShiftImporter;
|
||||
use App\Filament\Resources\ShiftResource\Pages;
|
||||
use App\Models\Plant;
|
||||
use App\Models\Shift;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
@@ -17,6 +19,7 @@ use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class ShiftResource extends Resource
|
||||
@@ -265,34 +268,59 @@ class ShiftResource extends Resource
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id')
|
||||
->label('ID')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
// Tables\Columns\TextColumn::make('id')
|
||||
// ->label('ID')
|
||||
// ->numeric()
|
||||
// ->sortable(),
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->label('Shift')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('start_time')
|
||||
->label('Start Time')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('duration')
|
||||
->label('Duration')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('end_time'),
|
||||
Tables\Columns\TextColumn::make('end_time')
|
||||
->label('End Time')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('block.name')
|
||||
->label('Block')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
@@ -312,7 +340,15 @@ class ShiftResource extends Resource
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->importer(ShiftImporter::class),
|
||||
->importer(ShiftImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import shift');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(ShiftExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export shift');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user