pai-sklep/routes/web.php

47 lines
1.9 KiB
PHP
Raw 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-09-05 02:22:17 +02:00
use App\Http\Controllers\LoginController;
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-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;
/*
|--------------------------------------------------------------------------
| 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!
|
*/
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-09-05 02:22:17 +02:00
Route::view("/login", "login");
Route::post('/login', [LoginController::class, "authenticate"])->name("login");
Route::post('/register', [LoginController::class, "register"])->name("register");
Route::any("/logout", [LoginController::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-11-20 22:12:35 +01:00
Route::resource("image", ImageController::class)->only(["store", "delete", "create"])->middleware("auth.admin");