pai-sklep/routes/web.php

50 lines
2.3 KiB
PHP
Raw Permalink Normal View History

2021-09-05 02:22:17 +02:00
<?php
2021-11-14 14:51:49 +01:00
use App\Http\Controllers\ImageController;
2021-12-16 21:58:10 +01:00
use App\Http\Controllers\UserController;
2021-11-14 20:44:10 +01:00
use App\Http\Controllers\MainPageController;
2021-11-19 08:04:04 +01:00
use App\Http\Controllers\CartController;
2021-12-16 11:51:47 +01:00
use App\Http\Controllers\CategoryController;
2021-11-14 14:51:49 +01:00
use App\Http\Controllers\OrderController;
2021-10-28 11:19:42 +02:00
use App\Http\Controllers\ProductController;
2021-09-05 02:22:17 +02:00
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;
/*
2021-12-16 11:51:47 +01:00
|-------------------------------------------------------------------------- | Web Routes
2021-09-05 02:22:17 +02:00
|--------------------------------------------------------------------------
|
| 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!
|
*/
2021-11-14 20:44:10 +01:00
Route::get('/', [MainPageController::class, "index"])->name("main");
2021-09-05 02:22:17 +02:00
Route::get('/user', function () {
2021-11-14 14:51:49 +01:00
$user = Auth::user();
2021-09-05 02:22:17 +02:00
return view("user", ["user"=>$user]);
2021-11-26 11:23:50 +01:00
})->middleware("auth")->name("user");
2021-12-16 21:58:10 +01:00
Route::post('/user', [UserController::class, "update"])->name("user.update");
Route::post('/user/password', [UserController::class, "updatePassword"])->name("user.updatepassword");
2021-09-05 02:22:17 +02:00
Route::view("/login", "login");
2021-12-16 21:58:10 +01:00
Route::post('/login', [UserController::class, "authenticate"])->name("login");
Route::post('/register', [UserController::class, "register"])->name("register");
Route::any("/logout", [UserController::class, "logout"])->name("logout");
2021-10-28 11:19:42 +02:00
2021-12-08 16:39:56 +01:00
Route::get("/cart", [CartController::class, "show"])->name("cart")->middleware("auth");
2021-11-29 15:46:16 +01:00
Route::post("/product/{product}/addToCart", [CartController::class, "addToCart"])->name("addToCart")->middleware("auth");
Route::post("/product/{product}/removeFromCart", [CartController::class, "removeFromCart"])->name("removeFromCart")->middleware("auth");
2021-11-19 08:04:04 +01:00
2021-12-05 19:22:52 +01:00
Route::resource("product", ProductController::class)->middleware("auth.admin");
Route::resource("product", ProductController::class)->only(["show"]);
2021-12-07 12:22:46 +01:00
2021-11-29 15:46:16 +01:00
Route::resource("order", OrderController::class)->middleware("auth");
2021-12-07 12:22:46 +01:00
Route::post('/order/create', [OrderController::class, "create"])->name("order.create");
2021-12-08 18:25:48 +01:00
Route::resource("image", ImageController::class)->only(["store", "destroy", "create"])->middleware("auth.admin");
2021-12-16 11:51:47 +01:00
Route::resource("category", CategoryController::class)->only(["index","destroy","edit", "store"])->middleware("auth.admin");