I can serve the page using inertia
like this:
Route::inertia('/home', 'home');
To load a page containing database data I have to do this:
Route::get('/terms', [LegalPageController::class, 'index']);
In controller:
class LegalPageController extends Controller { public function index() { $record = Terms::first(); return inertia('terms', compact('record')); } }
Is there any way to shorten it to:
Route::inertia('/home', 'home', [Controller::class, 'index']);
P粉2933419692024-03-29 09:23:19
You can’t do this
Route::inertia('/home', 'home', [Controller::class, 'index']);
Use this method instead
#routes/web.php Route::get('home', [Controller::class, 'index']); #App\Http\COntrollers\Controller.php namespace App\Http\Controllers class Controller extends Controller { # ... Inertia::render('home'); }