Hi Darius,
You will need to add a route to your web.php file have a read through this page which explains what to do https://laravel.com/docs/5.8/routing
the link you created is pointing to a named route so make sure you read about how to create one of those or adjust your link accordingly
I'm confused here. I already have the following route defined in web.php
;
Route::resource('cashbooktransactions', 'CashbookTransactionController');
As I understand it, route('cashbooktransactions.apply',$transaction->id)
should just point to the apply function in the corresponding controller class, correct? Or do I need to create a route for every class function that I would like to use? I mean, the edit
and destroy
functions also do not have a separate route defined, so why should a "custom" defined function have one?
TIA!
I'm completely lost I'm afraid. I added the following to web.php
;
Route::get('cashbooktransactions/apply', 'CashbookTransactionController@apply');
Route::resource('cashbooktransactions', 'CashbookTransactionController');
The second line was already there, I just pasted it in to demonstrate I put it before Router::resource
. And still I get a route not defined
message.
Found it! I'm posting the solution here for anyone else struggling with this.
I found the problem by checking the output from php artisan route:list
. This showed me that I was not using the transaction ID in the route and that the route was not properly named. Here is the solution.
Route::get('cashbooktransactions/{cashbooktransaction}/apply', 'CashbookTransactionController@apply')->name('cashbooktransactions.apply');
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community