ranjith-dev #733
@@ -187,6 +187,15 @@ class VisitorEntryResource extends Resource
|
||||
->numeric()
|
||||
->default(1)
|
||||
->required(),
|
||||
Forms\Components\Select::make('mode_of_travel')
|
||||
->label('Mode of Travel')
|
||||
->options([
|
||||
'Rental' => 'Rental',
|
||||
'Car' => 'Car',
|
||||
'Bike' => 'Bike',
|
||||
])
|
||||
->reactive()
|
||||
->placeholder('Select Mode of Travel'),
|
||||
Forms\Components\DateTimePicker::make('in_time')
|
||||
->label('In Time')
|
||||
->required()
|
||||
@@ -214,6 +223,7 @@ class VisitorEntryResource extends Resource
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
// ->modifyQueryUsing(fn (Builder $query) => $query->whereDate('created_at', today()))
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('NO')
|
||||
@@ -290,6 +300,11 @@ class VisitorEntryResource extends Resource
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('mode_of_travel')
|
||||
->label('Mode of Travel')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('in_time')
|
||||
->label('In Time')
|
||||
->searchable()
|
||||
@@ -420,9 +435,23 @@ class VisitorEntryResource extends Resource
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['register_id']) && empty($data['type']) && empty($data['name']) && empty($data['company']) && empty($data['employee_master_id']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
$query->where(function ($q) {
|
||||
});
|
||||
// if (empty($data['register_id']) && empty($data['type']) && empty($data['name']) && empty($data['company']) && empty($data['employee_master_id']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
// $query->where(function ($q) {
|
||||
// });
|
||||
// }
|
||||
|
||||
$hasAnyFilter = !empty($data['register_id'])
|
||||
|| !empty($data['type'])
|
||||
|| !empty($data['name'])
|
||||
|| !empty($data['company'])
|
||||
|| !empty($data['employee_master_id'])
|
||||
|| !empty($data['employee_department'])
|
||||
|| !empty($data['created_from'])
|
||||
|| !empty($data['created_to']);
|
||||
|
||||
if (!$hasAnyFilter) {
|
||||
$query->whereDate('created_at', today());
|
||||
return;
|
||||
}
|
||||
|
||||
if (! empty($data['register_id'])) {
|
||||
|
||||
Reference in New Issue
Block a user