F
Filament2y ago
John

What's the most convenient or recommended way to organise routes and Livewire components?

I want to use Tables and Forms for flexibility. Therefor I need my own routes. I'm using this now:
Route::get('schools', Livewire\SchoolTable::class)->name('schools.index');
Route::get('schools/{record}/edit', Livewire\SchoolForm::class)->name('schools.edit');
Route::get('schools', Livewire\SchoolTable::class)->name('schools.index');
Route::get('schools/{record}/edit', Livewire\SchoolForm::class)->name('schools.edit');
It mimics this: https://laravel.com/docs/master/controllers#actions-handled-by-resource-controller Is this the way to go? Is there a controller resource shortcut I'm missing?
Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
4 Replies
Dennis Koch
Dennis Koch2y ago
Nah, that looks fine.
John
JohnOP2y ago
K thanks! I've extended the question a bit... Is it typical / common practice to use a separate Edit and Create component? Could you merge them with some conditional parts? Or the other way around where you reuse some common parts like (most?) fields?
Dan Harrin
Dan Harrin2y ago
you could create a separate class that returns the array of form fields and then use that in both the pages to avoid repeating code
John
JohnOP2y ago
Ok thanks!
Want results from more Discord servers?
Add your server