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 charset = utf-8
end_of_line = lf end_of_line = lf
insert_final_newline = true insert_final_newline = true
indent_style = space indent_style = tabs
indent_size = 4
trim_trailing_whitespace = true trim_trailing_whitespace = true
[*.md] [*.md]
trim_trailing_whitespace = false 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]); //return view("product/view", ["product" => $product]);
} }
public function addToCart(Product $product) { public function addToCart(Product $product)
{
$user = Auth::user(); $user = Auth::user();
$user->cart()->syncWithoutDetaching([$product->uuid]); $user->cart()->syncWithoutDetaching([$product->uuid]);
return back(); return back();
} }
public function removeFromCart(Product $product) { public function removeFromCart(Product $product)
{
$user = Auth::user(); $user = Auth::user();
$user->cart()->detach($product); $user->cart()->detach($product);
return back(); return back();

View File

@ -7,7 +7,8 @@ use Illuminate\Http\Request;
class MainPageController extends Controller class MainPageController extends Controller
{ {
public function index() { public function index()
{
$products = Product::query()->latest()->limit(100)->get(); $products = Product::query()->latest()->limit(100)->get();
return view("index", ["products" => $products]); return view("index", ["products" => $products]);
} }

View File

@ -11,7 +11,8 @@ class Product extends Model
use HasUUID; use HasUUID;
public $primaryKey = "uuid"; public $primaryKey = "uuid";
public function images() { public function images()
{
return $this->hasMany(Image::class, "product_uuid", "uuid"); return $this->hasMany(Image::class, "product_uuid", "uuid");
} }

View File

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

View File

@ -5,6 +5,12 @@
box-sizing: border-box; box-sizing: border-box;
} }
a {
color: inherit;
text-decoration: inherit;
}
body { body {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -22,10 +28,12 @@ nav, footer {
nav { nav {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between;
padding: 1em;
} }
nav .fa { nav .fa {
font-size: 2em; font-size: 4vh;
} }
main { main {

View File

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

View File

@ -1,13 +1,8 @@
<!DOCTYPE html> @extends('layouts.app')
<html lang="en">
<head> @section('title', "Sklep")
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> @section('main')
<title>Document</title>
<style>
</style>
</head>
<body>
@if(Session::has('success')) @if(Session::has('success'))
<div class="alert alert-success"> <div class="alert alert-success">
{{ Session::get('success') }} {{ Session::get('success') }}
@ -34,3 +29,4 @@
</div> </div>
</body> </body>
</html> </html>
@endsection()