49 lines
2.3 KiB
PHP
49 lines
2.3 KiB
PHP
<?php
|
|
|
|
use App\Http\Controllers\ImageController;
|
|
use App\Http\Controllers\UserController;
|
|
use App\Http\Controllers\MainPageController;
|
|
use App\Http\Controllers\CartController;
|
|
use App\Http\Controllers\CategoryController;
|
|
use App\Http\Controllers\OrderController;
|
|
use App\Http\Controllers\ProductController;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\Route;
|
|
|
|
/*
|
|
|-------------------------------------------------------------------------- | 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('/', [MainPageController::class, "index"])->name("main");
|
|
|
|
Route::get('/user', function () {
|
|
$user = Auth::user();
|
|
return view("user", ["user"=>$user]);
|
|
})->middleware("auth")->name("user");
|
|
Route::post('/user', [UserController::class, "update"])->name("user.update");
|
|
Route::post('/user/password', [UserController::class, "updatePassword"])->name("user.updatepassword");
|
|
|
|
Route::view("/login", "login");
|
|
|
|
Route::post('/login', [UserController::class, "authenticate"])->name("login");
|
|
Route::post('/register', [UserController::class, "register"])->name("register");
|
|
Route::any("/logout", [UserController::class, "logout"])->name("logout");
|
|
|
|
Route::get("/cart", [CartController::class, "show"])->name("cart")->middleware("auth");
|
|
Route::post("/product/{product}/addToCart", [CartController::class, "addToCart"])->name("addToCart")->middleware("auth");
|
|
Route::post("/product/{product}/removeFromCart", [CartController::class, "removeFromCart"])->name("removeFromCart")->middleware("auth");
|
|
|
|
Route::resource("product", ProductController::class)->middleware("auth.admin");
|
|
Route::resource("product", ProductController::class)->only(["show"]);
|
|
|
|
Route::resource("order", OrderController::class)->middleware("auth");
|
|
Route::post('/order/create', [OrderController::class, "create"])->name("order.create");
|
|
|
|
Route::resource("image", ImageController::class)->only(["store", "destroy", "create"])->middleware("auth.admin");
|
|
Route::resource("category", CategoryController::class)->only(["index","destroy","edit", "store"])->middleware("auth.admin");
|