Help for integrating the Laravel package
Forum rules: Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
#4601 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 allRoute::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 allphp artisan aimeos:cache

and
Code: Select allphp artisan cache:clear

every time but nothing changes.

if i do
Code: Select allphp artisan route:list

i don't see the "checkout" URI listed.
#4602 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
#4606 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.
#4607 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"?
#4609 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 |
#4611 by aimeos
18 Sep 2017, 09:13
Might be a problem of your "hasPaymentSet" middleware