Garbage commit, squash me

This commit is contained in:
bad 2021-11-24 11:34:46 +01:00
parent 7ddc4f1458
commit 08ecbe31da
14 changed files with 46 additions and 41 deletions

View File

@ -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

View File

@ -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();

View File

@ -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]);
}

View File

@ -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");
}

View File

@ -45,11 +45,13 @@ class User extends Authenticatable
'email_verified_at' => 'datetime',
];
public function isAdmin() {
public function isAdmin()
{
return $this->admin;
}
public function cart() {
public function cart()
{
return $this->belongsToMany(Product::class, "cart_items", "userID", "productID");
}
}

View File

@ -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 {

View File

@ -11,6 +11,9 @@
<nav>
<i class="fa fa-hamburger"></i>
<div>
<a href="{{ route("login") }}">Login</a>
</div>
</nav>
<main>
@yield('main')
@ -19,6 +22,5 @@
<footer>
<h4>Copyright 2021 JA</h4>
</footer>
</body>
</html>

View File

@ -1,13 +1,8 @@
<!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') }}
@ -34,3 +29,4 @@
</div>
</body>
</html>
@endsection()