For a custom filament page to edit a specific eloquent model, what is the URL of that page?

I haven't found any explanation how to find out the URL of a custom edit page of an Eloquent model. Is the URL based on the namespace and class name and panel?
<?php

namespace App\Filament\Investigador\Pages\Proyectos;

use ...

class ConfirmarFechas extends Page implements HasForms
{
use InteractsWithFormActions;

protected static string $view = 'filament.investigador.pages.proyectos.confirmar-fechas';
protected static ?string $title = 'Confirmar fechas';

/** columns*/
public ?string $fecha_inicio = null;
public ?string $fecha_termino = null;

public function mount(Proyecto $proyecto): void
{
$this->form->fill($proyecto->toArray());
}
public function form(Form $form): Form
{
return $form
->schema([
DatePicker::make('fecha_inicio')->label('Fecha de inicio')
->required()
->closeOnDateSelection()
->reactive()
,
DatePicker::make('fecha_termino')->label('Fecha de término')
->required()
->closeOnDateSelection()
//Que la fecha mínima sea la elegida en la fecha de inicio: https://discord.com/channels/883083792112300104/1247978059743756329/1247990543187968142
->minDate(function (Get $get) {
return $get('fecha_inicio');
})
,
]);
}

public function getFormActions(): array
{
return [
Action::make('save')->action(
function (): void {
$this->update();
}
),
];
}

public function update()
{
dd('update the dates here');
}
}
<?php

namespace App\Filament\Investigador\Pages\Proyectos;

use ...

class ConfirmarFechas extends Page implements HasForms
{
use InteractsWithFormActions;

protected static string $view = 'filament.investigador.pages.proyectos.confirmar-fechas';
protected static ?string $title = 'Confirmar fechas';

/** columns*/
public ?string $fecha_inicio = null;
public ?string $fecha_termino = null;

public function mount(Proyecto $proyecto): void
{
$this->form->fill($proyecto->toArray());
}
public function form(Form $form): Form
{
return $form
->schema([
DatePicker::make('fecha_inicio')->label('Fecha de inicio')
->required()
->closeOnDateSelection()
->reactive()
,
DatePicker::make('fecha_termino')->label('Fecha de término')
->required()
->closeOnDateSelection()
//Que la fecha mínima sea la elegida en la fecha de inicio: https://discord.com/channels/883083792112300104/1247978059743756329/1247990543187968142
->minDate(function (Get $get) {
return $get('fecha_inicio');
})
,
]);
}

public function getFormActions(): array
{
return [
Action::make('save')->action(
function (): void {
$this->update();
}
),
];
}

public function update()
{
dd('update the dates here');
}
}
this is what I got, but I haven't been able to figure out how to view my page by using the URL. The id of the resource I want to test is 2. How do I find out the URL?
6 Replies
Pathros
Pathros3mo ago
well, I have found out:
php artisan route:list --name=filament
php artisan route:list --name=filament
But the page does not expect /{record}/ . How do I enable the edit page?
awcodes
awcodes3mo ago
Is this page part of a resource?
Pathros
Pathros3mo ago
I don't know what went wrong during the development phase, that I have tried to install a new fresh Laravel app with filament. As you suggest, I have added that page into the resource getPages()method:
public static function getPages(): array
{
return [
'index' => Pages\ListProyectos::route('/'),
'create' => Pages\CreateProyecto::route('/create'),
'view' => Pages\ViewProyecto::route('/{record}'),
'edit' => Pages\EditProyecto::route('/{record}/edit'),
'fechas-confirmar' => ConfirmarFechas::route('/{record}/fechas-confirmar'),//THIS ONE
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListProyectos::route('/'),
'create' => Pages\CreateProyecto::route('/create'),
'view' => Pages\ViewProyecto::route('/{record}'),
'edit' => Pages\EditProyecto::route('/{record}/edit'),
'fechas-confirmar' => ConfirmarFechas::route('/{record}/fechas-confirmar'),//THIS ONE
];
}
and now I can see it registered inside the laravel routes: /.../projects/{record}/fechas-confirmar Then, how do I get the {record} in the custom page to fill the values in the form, so that the user can edit that record?
Dennis Koch
Dennis Koch3mo ago
You need to define the $slug property
Then, how do I get the {record} in the custom page to fill the values in the form, so that the user can edit that record?
This part public function mount(Proyecto $proyecto): should be public function mount(Proyecto $record): because the route has {record}.
Pathros
Pathros3mo ago
Thanks. Looks like I can get it from the route name list. The protected $slug property inside the custom page doesn't take effect but it does right from the getPages() array of the Resource.
Dennis Koch
Dennis Koch3mo ago
The protected $slug property inside the custom page doesn't take effect
Yes, it's used for pages. But since you register it via the resource it isn't I thought it's a non-resource page
Want results from more Discord servers?
Add your server