<?php
use App\Product;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    $products = Product::all();
    return view('home',compact('products'));
});
Route::post('/cart/add',[
    'uses'=> 'ShopController@add_to_cart',
    'as' => 'cart.add'
]);
Route::get('/cart',[
    'uses'=> 'ShopController@cart',
    'as' => 'cart.index'
]);
Route::get('/cart/remove/{id}',[
    'uses'=> 'ShopController@cart_delete',
    'as' => 'cart.delete'
]);
Route::get('/cart/dec/{id}/{qte}',[
    'uses'=> 'ShopController@cart_dec',
    'as' => 'cart.decrease'
]);
Route::get('/cart/inc/{id}/{qte}',[
    'uses'=> 'ShopController@cart_inc',
    'as' => 'cart.increase'
]);
Route::get('/cart/checkout',[
    'uses'=> 'CheckoutController@index',
    'as' => 'cart.checkout'
]);
Route::post('/cart/pay',[
    'uses'=> 'CheckoutController@pay',
    'as' => 'cart.pay'
]);
Route::get('/products/add',[
    'uses'=> 'ProductsController@create',
    'as' => 'product.create'
]);
Route::post('/products/update/{id}',[
    'uses'=> 'ProductsController@update',
    'as' => 'product.update'
]);
Route::get('/products/{id}/delete',[
    'uses'=> 'ProductsController@destroy',
    'as' => 'product.delete'
]);
Route::get('/users/login',[
    'uses'=> 'UsersController@login',
    'as' => 'users.login'
]);
Route::get('/users/logout',[
    'uses'=> 'UsersController@logout',
    'as' => 'users.logout'
]);
Route::post('/users/auth',[
    'uses'=> 'UsersController@auth',
    'as' => 'users.auth'
]);
Route::resource('/products','ProductsController');
Route::resource('/users','UsersController');