Support the ongoing development of Laravel.io →
posted 5 years ago
Laravel
Last updated 2 years ago.
0

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

0

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!

Last updated 5 years ago.
0

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 5 years ago.
0
Solution

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');
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Darius Blaszyk daar Joined 21 Aug 2019

Moderators

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

Your logo here?

Laravel.io

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

© 2024 Laravel.io - All rights reserved.