Need a help in custom page with table
I created a ViewDayBookDetails custom page :
class ViewDayBookDetails extends Page implements HasTable
{
use HasPageShield;
use InteractsWithTable;
use Concerns\Component\SerialNumber;
protected static string $view = 'filament.pages.view-day-book-details';
public function mount() {
if (! request()->has('date') && ! request()->filled('date')) {
Toast::error(title: ('custom_pages.view_day_book_details.error_message.date_required'));
return back()->withInput();
}
}
public function getTitle(): string
{
return ('custom_pages.view_day_book_details.title', ['date', request('date')]);
}
public static function table(Table $table): Table
{
return $table
->query(static::getEloquentQuery())
->columns([
static::serialNumberColumnComponent(),
]);
}
public static function getEloquentQuery(): Builder
{
$date = Carbon::parse(request('date'))->toDateString();
return TransactionDetail::query()
->with(['modelable'])
->whereDate('created_at', $date);
}
}
From Another Resource Table Action:
TableActions\Action::make('view_day_book_details')
->label(__('day_book.table.action_buttons.view_day_book_details'))
->icon('heroicon-m-eye')
->url(fn(Model $record) => ViewDayBookDetails::getUrl(parameters: ['date' => $record->created_at->format('Y-m-d')]))
In ViewDayBookDetails custom page request('date') return null , I inspect the network tab the filament triggers two xhr request for the first request getTitle() shows the date but the second request removes the date
class ViewDayBookDetails extends Page implements HasTable
{
use HasPageShield;
use InteractsWithTable;
use Concerns\Component\SerialNumber;
protected static string $view = 'filament.pages.view-day-book-details';
public function mount() {
if (! request()->has('date') && ! request()->filled('date')) {
Toast::error(title: ('custom_pages.view_day_book_details.error_message.date_required'));
return back()->withInput();
}
}
public function getTitle(): string
{
return ('custom_pages.view_day_book_details.title', ['date', request('date')]);
}
public static function table(Table $table): Table
{
return $table
->query(static::getEloquentQuery())
->columns([
static::serialNumberColumnComponent(),
]);
}
public static function getEloquentQuery(): Builder
{
$date = Carbon::parse(request('date'))->toDateString();
return TransactionDetail::query()
->with(['modelable'])
->whereDate('created_at', $date);
}
}
From Another Resource Table Action:
TableActions\Action::make('view_day_book_details')
->label(__('day_book.table.action_buttons.view_day_book_details'))
->icon('heroicon-m-eye')
->url(fn(Model $record) => ViewDayBookDetails::getUrl(parameters: ['date' => $record->created_at->format('Y-m-d')]))
In ViewDayBookDetails custom page request('date') return null , I inspect the network tab the filament triggers two xhr request for the first request getTitle() shows the date but the second request removes the date