Support the ongoing development of →
posted 4 years ago
Last updated 2 years ago.

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

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?


Last updated 4 years ago.

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.

Last updated 4 years ago.

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!


Your banner here too?

Darius Blaszyk daar Joined 21 Aug 2019


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.