From 931b8dea5a3c2c2f5983b1049d06f4b45b0735f4 Mon Sep 17 00:00:00 2001 From: bad Date: Sun, 5 Dec 2021 22:01:53 +0100 Subject: [PATCH] Product view --- .../2021_10_28_093227_create_images_table.php | 2 +- resources/scss/product.scss | 44 ++++++++++ resources/views/product/view.blade.php | 87 ++++++++++++------- resources/views/user.blade.php | 4 +- webpack.mix.js | 5 +- 5 files changed, 106 insertions(+), 36 deletions(-) create mode 100644 resources/scss/product.scss diff --git a/database/migrations/2021_10_28_093227_create_images_table.php b/database/migrations/2021_10_28_093227_create_images_table.php index bdc5888..198cdfa 100644 --- a/database/migrations/2021_10_28_093227_create_images_table.php +++ b/database/migrations/2021_10_28_093227_create_images_table.php @@ -15,7 +15,7 @@ class CreateImagesTable extends Migration { Schema::create('images', function (Blueprint $table) { $table->uuid("uuid")->unique()->primary; - $table->foreignUuid("product_uuid")->references("uuid")->on("products"); + $table->foreignUuid("product_uuid")->nullable()->references("uuid")->on("products")->nullOnDelete(); $table->string('path')->unique(); $table->timestamps(); }); diff --git a/resources/scss/product.scss b/resources/scss/product.scss new file mode 100644 index 0000000..ca62984 --- /dev/null +++ b/resources/scss/product.scss @@ -0,0 +1,44 @@ +.product-container { + display: flex; + + flex-wrap: wrap; + & > div { + width: 49%; + padding: 1em; + } +} + +.product-image { + width: 100%; +} + +.name-price-container { + display: flex; + justify-content: space-between; + align-items: flex-end; +} + +.price-currency { + font-size: 0.85em; + opacity: 0.55; + font-weight: normal; +} + +.product-commands { + &, button { + width: 100%; + } + +} + +.admin-menu { + display: flex; + width: 100%; + & * { + width: 100%; + } +} + +.admin-menu-button { + width: 100%; +} diff --git a/resources/views/product/view.blade.php b/resources/views/product/view.blade.php index fc8fa97..6647e35 100644 --- a/resources/views/product/view.blade.php +++ b/resources/views/product/view.blade.php @@ -1,31 +1,56 @@ - - - - - - Document - - - -
-

- {{ $product }} -

-
- - @method('DELETE') - @csrf -
-
- - @csrf -
- -
- - @csrf -
-
- - +@push('head') + +@endpush + +@extends('layouts.app') + +@section('title', $product->name) + +@push('head') + +@endpush + +@section('main') +
+
+ +
+

{{ $product->name }}

+

{{ ($product->price) }}

+
+
+ @auth + @if(!Auth::user()->cart()->find($product)) +
+ + @csrf +
+ @else +
+ + @csrf +
+ @endif + @if(Auth::user()->isAdmin()) +
+ + + +
+ + @method('DELETE') + @csrf +
+
+ @endif + @endauth +
+
+
+

+ {{ $product->description }} +

+
+
+ +@endsection() diff --git a/resources/views/user.blade.php b/resources/views/user.blade.php index 1bfbee8..ff2b9cd 100644 --- a/resources/views/user.blade.php +++ b/resources/views/user.blade.php @@ -18,11 +18,9 @@
@csrf -
@endforeach() @endsection() - - diff --git a/webpack.mix.js b/webpack.mix.js index dba5061..4b251f0 100644 --- a/webpack.mix.js +++ b/webpack.mix.js @@ -17,4 +17,7 @@ mix.js("resources/js/app.js", "public/js").sass( ).sass( "resources/scss/login.scss", "public/css" -); +).sass( + "resources/scss/product.scss", + "public/css" +);;