When using wp acorn make:middleware
or make:controller
these only seems to make “sense” / work, when having defined a routes/web.php
file, where you define your routes the typical laravel way. (From acorn routing documentation)
Route::get('/your-route', [YourController::class, 'yourMethod'])
->middleware('yourMiddleware');
Is it possible to have to have Controller for the template hierarchy?
Meaning: When i have a Custom Post Type called Books i could catch a POST
request for a single-book.blade.php
without defining a dynamic route in the routes/web.php (or not even defining routes/web.php in the first place) and just using a “SingleBookController.php” that targets the templates directly.
As of now my approach is to either put the logic responsible for handling the POST
request into the Blade Template with @php {code} @endphp itself or defining it via a hook in the setup.php
file.