Dennyvik
Dennyvik
FFilament
Created by Dennyvik on 9/15/2024 in #❓┊help
Custom Filter Indicator removal to affect multiple fields removal
Hi, i have custom Filter with 3 fields related each other or dependent. From the filter drop down menu, if I am using field #1 and field #2, then remove #1, the other lower fields successfully resetting like what I intended. But, if I remove the filter from indicator, the lower field's filter persist and the table's data list not reset.
->query(function(Builder $query, array $data): Builder {
return $query
->when(
$data['Curriculum'],
fn (Builder $query, $value) => $query->whereHas('grade.level', fn($query) => $query->where('curriculum_id', $value))
)
->when(
$data['Level'],
fn (Builder $query, $value) => $query->whereHas('grade', fn($query) => $query->where('level_id', $value))
)
->when(
$data['Grade'],
fn (Builder $query, $value) => $query->where('grade_id', $value)
);
})
->indicateUsing(function(array $data): array {
if (empty($data)) {
return null;
}
$indicators = [];
if($data['Curriculum']) {
$indicators[] = Indicator::make('Curriculum : ' . Curriculum::find($data['Curriculum'])->name)
->removeField('Curriculum');
if($data['Level']){
$indicators[] = Indicator::make('Level : ' . Level::find($data['Level'])->name)
->removeField('Level');
if($data['Grade']){
$indicators[] = Indicator::make('Grade : ' . Grade::find($data['Grade'])->name)
->removeField('Grade');
}
}
}
return $indicators;;
})
->query(function(Builder $query, array $data): Builder {
return $query
->when(
$data['Curriculum'],
fn (Builder $query, $value) => $query->whereHas('grade.level', fn($query) => $query->where('curriculum_id', $value))
)
->when(
$data['Level'],
fn (Builder $query, $value) => $query->whereHas('grade', fn($query) => $query->where('level_id', $value))
)
->when(
$data['Grade'],
fn (Builder $query, $value) => $query->where('grade_id', $value)
);
})
->indicateUsing(function(array $data): array {
if (empty($data)) {
return null;
}
$indicators = [];
if($data['Curriculum']) {
$indicators[] = Indicator::make('Curriculum : ' . Curriculum::find($data['Curriculum'])->name)
->removeField('Curriculum');
if($data['Level']){
$indicators[] = Indicator::make('Level : ' . Level::find($data['Level'])->name)
->removeField('Level');
if($data['Grade']){
$indicators[] = Indicator::make('Grade : ' . Grade::find($data['Grade'])->name)
->removeField('Grade');
}
}
}
return $indicators;;
})
3 replies
FFilament
Created by Dennyvik on 9/14/2024 in #❓┊help
Reordering new item on Repeater relationship throw error
When I add new item to the repeater and reordering, it throw error. This is not happened to existing item.
Repeater::make('shifts')
->relationship('shifts')
->orderColumn('sort')
->reorderable(true)
->schema([
TimePicker::make('start_time')
->required()
->native(false)
->seconds(false)
->minutesStep(30)
->live('onBlur')
->afterStateUpdated(function (Get $get, Set $set) {
$duration = $get('../../duration') ?? 0;
$time=Carbon::createFromFormat('Y-m-d H:i:s', $get('start_time'))->addMinute($duration);
$set('end_time', $time);
}),
TimePicker::make('end_time')
->required()
->native(false)
->seconds(false)
->minutesStep(30)
->rule('after:start_time'),
])
->addAction(function (FormAction $action) {
return $action
->label('Add Shift')
->action(function (Get $get, Set $set) {
$shifts = $get('shifts') ?? [];
if(count($shifts) > 0) {
$last = end($shifts);
$duration = $get('duration') ?? 0;
($last) ? $start = $last['end_time'] : $start = null;
$shifts[] = [
'start_time' => $start,
'end_time' => Carbon::createFromFormat('Y-m-d H:i:s', $last['end_time'])->addMinute($duration),
];
$set('shifts', $shifts);
} else {
$shifts[] = [
'start_time' => null,
'end_time' => null,
];
$set('shifts', $shifts);
}
});
}),
Repeater::make('shifts')
->relationship('shifts')
->orderColumn('sort')
->reorderable(true)
->schema([
TimePicker::make('start_time')
->required()
->native(false)
->seconds(false)
->minutesStep(30)
->live('onBlur')
->afterStateUpdated(function (Get $get, Set $set) {
$duration = $get('../../duration') ?? 0;
$time=Carbon::createFromFormat('Y-m-d H:i:s', $get('start_time'))->addMinute($duration);
$set('end_time', $time);
}),
TimePicker::make('end_time')
->required()
->native(false)
->seconds(false)
->minutesStep(30)
->rule('after:start_time'),
])
->addAction(function (FormAction $action) {
return $action
->label('Add Shift')
->action(function (Get $get, Set $set) {
$shifts = $get('shifts') ?? [];
if(count($shifts) > 0) {
$last = end($shifts);
$duration = $get('duration') ?? 0;
($last) ? $start = $last['end_time'] : $start = null;
$shifts[] = [
'start_time' => $start,
'end_time' => Carbon::createFromFormat('Y-m-d H:i:s', $last['end_time'])->addMinute($duration),
];
$set('shifts', $shifts);
} else {
$shifts[] = [
'start_time' => null,
'end_time' => null,
];
$set('shifts', $shifts);
}
});
}),
The error : Filament\Forms\ComponentContainer::getRawState(): Return value must be of type Illuminate\Contracts\Support\Arrayable|array, int returned
4 replies
FFilament
Created by Dennyvik on 9/6/2024 in #❓┊help
Database Notification error "operator does not exist: json ->> unknown"
Can anyone help making Database Notification works in PostgreSQL 9.2.4 ?
4 replies
FFilament
Created by Dennyvik on 1/31/2024 in #❓┊help
summarize Count icons take all icons as false
Hi All, i am making a list of data with a column that display icon which shown file exists or not.
Tables\Columns\IconColumn::make('pdf_filename')
->label('PDF File')
->true('heroicon-o-document-check','indigo')
->false('heroicon-o-x-circle','danger')
->boolean()->getStateUsing(function (TempInvoiceList $record) : bool {
return
$record->pdf_filename
&&
File::exists(storage_path('app/public/pdf/' . $this->getPeriod($record) . '/' . $record->pdf_filename))
? true : false;
})
->summarize(Count::make()->icons())
->url(fn (TempInvoiceList $record): ?string =>
$record->pdf_filename && $record->status_file === 'GENERATED'
? route('invoice', ['period' => $this->getPeriod($record) ,'name' => $record->pdf_filename])
: null,
shouldOpenInNewTab: true)
->alignCenter(),
Tables\Columns\IconColumn::make('pdf_filename')
->label('PDF File')
->true('heroicon-o-document-check','indigo')
->false('heroicon-o-x-circle','danger')
->boolean()->getStateUsing(function (TempInvoiceList $record) : bool {
return
$record->pdf_filename
&&
File::exists(storage_path('app/public/pdf/' . $this->getPeriod($record) . '/' . $record->pdf_filename))
? true : false;
})
->summarize(Count::make()->icons())
->url(fn (TempInvoiceList $record): ?string =>
$record->pdf_filename && $record->status_file === 'GENERATED'
? route('invoice', ['period' => $this->getPeriod($record) ,'name' => $record->pdf_filename])
: null,
shouldOpenInNewTab: true)
->alignCenter(),
The icon displayed correctly as intended. But, the summarize won't work. It counted all rows with the icon for false condition. Can someone help me? Thanks before.
3 replies