Laravel custom routes

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
MirkoPinna
Posts: 16
Joined: 04 Sep 2017, 12:35

Laravel custom routes

Post by MirkoPinna » 15 Sep 2017, 12:34

I am trying to add a custom middleware in the /checkout route but seems like it doesn't want to work.
I followed the steps at https://aimeos.org/docs/Laravel/Custom_routes
So i added this piece of code to /app/Http/routes.php :

Code: Select all

Route::match( array( 'GET', 'POST' ), 'checkout', array(
		'as' => 'aimeos_shop_checkout',
		'uses' => 'Aimeos\Shop\Controller\CheckoutController@indexAction',
    'middleware' => 'hasPaymentSet',
	));
but nothing happens, i also put this line of code in /config/shop.php :

Code: Select all

'checkout' => ['middleware' => ['auth', 'hasMangopay']],


I run

Code: Select all

php artisan aimeos:cache

and

Code: Select all

php artisan cache:clear
every time but nothing changes.

if i do

Code: Select all

php artisan route:list

i don't see the "checkout" URI listed.

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Laravel custom routes

Post by aimeos » 15 Sep 2017, 17:02

Can you try to put your route into "./routes/web.php"?
The location of the file changed between Laravel 5.2 and 5.3
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

MirkoPinna
Posts: 16
Joined: 04 Sep 2017, 12:35

Re: Laravel custom routes

Post by MirkoPinna » 18 Sep 2017, 07:05

Gives me an error:

Code: Select all

[ReflectionException]                                                                
  Class App\Http\Controllers\Aimeos\Shop\Controller\CheckoutController does not exist 
and if i try to remove this part:

Code: Select all

'uses' => 'Aimeos\Shop\Controller\CheckoutController@indexAction',
it shows in the routes list as follow:

Code: Select all

|        | GET|POST|HEAD | checkout                                                                  | aimeos_shop_checkout         | Closure                                                                | web,hasPaymentSet |
but i go to mywebsite/checkout nothing happens.
I think none of my routes in routes.php is working.

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Laravel custom routes

Post by aimeos » 18 Sep 2017, 08:02

Seem that Laravel uses a namespace relative to "App\Http\Controllers". Can you add a backslash in front of your controller@action: "\Aimeos\Shop\Controller\CheckoutController@indexAction"?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

MirkoPinna
Posts: 16
Joined: 04 Sep 2017, 12:35

Re: Laravel custom routes

Post by MirkoPinna » 18 Sep 2017, 08:09

Now it finds the controller but nothing happens if i go to mywebsite/checkout, this is the routes list:

Code: Select all

|        | GET|POST|HEAD | checkout                                                                  | aimeos_shop_checkout         | \Aimeos\Shop\Controller\CheckoutController@indexAction                 | web,hasPaymentSet |

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Laravel custom routes

Post by aimeos » 18 Sep 2017, 09:13

Might be a problem of your "hasPaymentSet" middleware
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply