Garbage commit, squash me
This commit is contained in:
parent
7ddc4f1458
commit
08ecbe31da
14 changed files with 46 additions and 41 deletions
|
@ -4,15 +4,8 @@ root = true
|
|||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
indent_style = tabs
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.{yml,yaml}]
|
||||
indent_size = 2
|
||||
|
||||
[docker-compose.yml]
|
||||
indent_size = 4
|
||||
|
|
|
@ -23,14 +23,16 @@ class CartController extends Controller
|
|||
//return view("product/view", ["product" => $product]);
|
||||
}
|
||||
|
||||
public function addToCart(Product $product) {
|
||||
public function addToCart(Product $product)
|
||||
{
|
||||
$user = Auth::user();
|
||||
$user->cart()->syncWithoutDetaching([$product->uuid]);
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
public function removeFromCart(Product $product) {
|
||||
public function removeFromCart(Product $product)
|
||||
{
|
||||
$user = Auth::user();
|
||||
$user->cart()->detach($product);
|
||||
return back();
|
||||
|
|
|
@ -7,7 +7,8 @@ use Illuminate\Http\Request;
|
|||
|
||||
class MainPageController extends Controller
|
||||
{
|
||||
public function index() {
|
||||
public function index()
|
||||
{
|
||||
$products = Product::query()->latest()->limit(100)->get();
|
||||
return view("index", ["products" => $products]);
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ class OrderController extends Controller
|
|||
$order = new Order($products);
|
||||
|
||||
$order->user()->associate($user);
|
||||
$order->cost = array_reduce($products,fn ($c, $i) => $c+=$i->price,0);
|
||||
$order->cost = array_reduce($products, fn ($c, $i) => $c+=$i->price, 0);
|
||||
|
||||
return $order->save();
|
||||
});
|
||||
|
@ -94,8 +94,8 @@ class OrderController extends Controller
|
|||
$validated = $request->validate([
|
||||
'address' => 'string',
|
||||
]);
|
||||
if(isset($validated["address"])) {
|
||||
$address = $order->address()->withDefault(fn() => new Addres($validated));
|
||||
if (isset($validated["address"])) {
|
||||
$address = $order->address()->withDefault(fn () => new Addres($validated));
|
||||
$address->address = $validated["address"];
|
||||
$order->save();
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class AdminAuth
|
|||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
$user = Auth::user();
|
||||
if($user && $user->isAdmin()) {
|
||||
if ($user && $user->isAdmin()) {
|
||||
return $next($request);
|
||||
}
|
||||
throw new AccessDeniedHttpException("You must be an admin to access this path");
|
||||
|
|
|
@ -23,6 +23,6 @@ class Order extends Model
|
|||
|
||||
public function products()
|
||||
{
|
||||
return $this->belongsToMany("App\Product", "orderProduct","productId", "orderId");
|
||||
return $this->belongsToMany("App\Product", "orderProduct", "productId", "orderId");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,8 @@ class Product extends Model
|
|||
use HasUUID;
|
||||
public $primaryKey = "uuid";
|
||||
|
||||
public function images() {
|
||||
public function images()
|
||||
{
|
||||
return $this->hasMany(Image::class, "product_uuid", "uuid");
|
||||
}
|
||||
|
||||
|
|
|
@ -45,11 +45,13 @@ class User extends Authenticatable
|
|||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function isAdmin() {
|
||||
return $this->admin;
|
||||
public function isAdmin()
|
||||
{
|
||||
return $this->admin;
|
||||
}
|
||||
|
||||
public function cart() {
|
||||
return $this->belongsToMany(Product::class, "cart_items", "userID", "productID");
|
||||
public function cart()
|
||||
{
|
||||
return $this->belongsToMany(Product::class, "cart_items", "userID", "productID");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ class ProductFactory extends Factory
|
|||
return [
|
||||
'uuid' => $this->faker->unique()->uuid(),
|
||||
'name' => $this->faker->productName(),
|
||||
'price' => $this->faker->numberBetween(1,32124),
|
||||
'price' => $this->faker->numberBetween(1, 32124),
|
||||
'description' => $this->faker->text(10000),
|
||||
];
|
||||
}
|
||||
|
|
10
resources/scss/app.scss
vendored
10
resources/scss/app.scss
vendored
|
@ -5,6 +5,12 @@
|
|||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
|
||||
a {
|
||||
color: inherit;
|
||||
text-decoration: inherit;
|
||||
}
|
||||
|
||||
body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
@ -22,10 +28,12 @@ nav, footer {
|
|||
nav {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
nav .fa {
|
||||
font-size: 2em;
|
||||
font-size: 4vh;
|
||||
}
|
||||
|
||||
main {
|
||||
|
|
|
@ -10,15 +10,17 @@
|
|||
<body>
|
||||
|
||||
<nav>
|
||||
<i class="fa fa-hamburger"></i>
|
||||
<i class="fa fa-hamburger"></i>
|
||||
<div>
|
||||
<a href="{{ route("login") }}">Login</a>
|
||||
</div>
|
||||
</nav>
|
||||
<main>
|
||||
@yield('main')
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
<h4>Copyright 2021 JA</h4>
|
||||
<h4>Copyright 2021 JA</h4>
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,16 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<style>
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('title', "Sklep")
|
||||
|
||||
@section('main')
|
||||
@if(Session::has('success'))
|
||||
<div class="alert alert-success">
|
||||
{{Session::get('success')}}
|
||||
{{ Session::get('success') }}
|
||||
</div>
|
||||
@endif
|
||||
<div>
|
||||
|
@ -34,3 +29,4 @@
|
|||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@endsection()
|
||||
|
|
Loading…
Reference in a new issue