Monday, May 22, 2017

Laravel, routing

This is my routing:

Route::get('/', 'StoreController@mainSite');

Route::get('/product/{id_product}', 'StoreController@showProduct');
Route::get('/kontact', 'StoreController@showContaktForm');


Route::get('/login', 'AuthController@formView')
Route::post('/login', 'AuthController@login');
Route::get('/logout', 'AuthController@logout');

Route::get('/register', 'RegisterController@formView');
Route::post('/register', 'RegisterController@register');

Route::get('/panel', 'PanelController@mainSite');
Route::get('/panel/data', 'PanelController@formView');
Route::post('/panel/data', 'PanelController@updateData');


Route::get('/panel/orders', 'OrderController@showOrders');
Route::post('/panel/orders/add', 'OrderController@addOrder');

Route::post('/cart/add', 'CartController@addItem');
Route::post('/cart/remove', 'CartController@removeItem');
Route::get('/cart', 'CartController@showItems');


Route::get('/{categoryName}', 'StoreController@showCategory');
Route::get('/{categoryName}/{subcategoryName}','StoreController@showSubcategory');

Now i have in my view code link to add item to my cart :

<h4><a class="shopBtn" href="/cart/add" title="add to cart"> Add to cart </a> </h4>

But, when I clic on this, then I gave alert :

ErrorException in Category.php line 16:
Trying to get property of non-object

And I think, that Category is not need in this and I supose, that this a href is going into one his route :

Route::get('/{categoryName}', 'StoreController@showCategory'); 

Is there a possibility to fix it? Maybe add action to a href? I'm pretty sure that this Model which is called in my error is not connected with thing I want to do now.



via wenus

Advertisement