Commit 6aeaacdf authored by Vasko Mitevski's avatar Vasko Mitevski
Browse files

Merge branch 'product_handle_finishing' into 'dev'

Product handle finishing

See merge request !7
2 merge requests!14in the middle of product creating, request done without error messages,...,!7Product handle finishing
Showing with 536 additions and 133 deletions
+536 -133
......@@ -4,6 +4,12 @@
- Прво би те замолил да ги игнорираш дел од коментарите низ кодот. Голем дел од нив се оставани од мене за мене.
- Второ би те замолил да ги испишеш следните две команди во конзола, за да се аплицират сликите кои што ги имам за почеток за продукти и брендови, како би можел/а да имаш некој почетен интерфејс со сите функционалности:
двете битни команди за правилно стартување на апликацијата (заради сликите кои што ги имам за почетно стартување на апликацијата)
би те замолил да ги run-уваш следните две команди:
----- mkdir -p storage/app/public/images/products && cp -r public/images/products/* storage/app/public/images/products/
----- php artisan storage:link
- Можеби во иднина би било подобро при внесување на нов продукт, ако количината би била повеќе од 1 парче, овде во овој момент да има админот можност да одбере боја и величина соодветно за сите парчиња, затоа што вака како што е креиран FrontEnd Админ панелот, админот ќе мора засебно да ги внесува продуктите (величина и боја)
Пр:
треба да внесе 3 нови парчиња од истиот продукт
......@@ -12,10 +18,6 @@
- Кај внесување односно одбирање на боја, намерно ги направив така хард-кодирани бои, пошто очигледно ќе има одредени бои од кои ќе бира админот која ќе ја има на лагер.
двете битни команди за правилно стартување на апликацијата (заради сликите кои што ги имам за почетно стартување на апликацијата)
би те замолил да ги run-уваш следните две команди:
mkdir -p storage/app/public/images/products && cp -r public/images/products/* storage/app/public/images/products/
php artisan storage:link
......@@ -2,6 +2,9 @@
namespace App\Http\Controllers;
use App\Http\Requests\DiscountRequest;
use App\Models\Product;
use App\Models\Category;
use App\Models\Discount;
use Illuminate\Http\Request;
......@@ -12,7 +15,10 @@ class DiscountController extends Controller
*/
public function index()
{
//
$activeDiscounts = Discount::where('status', 'active')->get();
$archivedDiscounts = Discount::where('status', 'archived')->get();
return view('discounts.index', compact('activeDiscounts', 'archivedDiscounts'));
}
/**
......@@ -20,23 +26,43 @@ public function index()
*/
public function create()
{
//
$categories = Discount::pluck('category');
$products = Product::all();
return view('discounts.create', compact('categories', 'products'));
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
public function store(DiscountRequest $request)
{
//
}
$validatedData = $request->validated();
/**
* Display the specified resource.
*/
public function show(Discount $discount)
{
//
$discountData = [
'name' => $validatedData['name'],
'percentage' => $validatedData['percentage'],
'category' => $validatedData['category'],
'status' => 'active', // Default status
];
//ако е селектиран статус, да го земе
if ($request->has('status')) {
$discountData['status'] = $request->input('status');
}
$discount = Discount::create($discountData);
//за аплицирање на попуст на одредени продукти
if ($request->filled('products')) {
$productIds = explode('#', $request->input('products'));
$productIds = array_filter(array_map('trim', $productIds));
Product::whereIn('id', $productIds)->update(['discount_id' => $discount->id]);
}
return redirect()->route('discounts.index')->with('success', 'Попустот е успешно креиран');
}
/**
......@@ -44,22 +70,33 @@ public function show(Discount $discount)
*/
public function edit(Discount $discount)
{
//
$discountCategories = Discount::pluck('category')->unique();
return view('discounts.edit', compact('discount', 'discountCategories'));
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, Discount $discount)
public function update(DiscountRequest $request, Discount $discount)
{
//
}
$validatedData = $request->validated();
/**
* Remove the specified resource from storage.
*/
public function destroy(Discount $discount)
{
//
$discount->update([
'name' => $validatedData['name'],
'percentage' => $validatedData['percentage'],
'category' => $validatedData['category'],
'status' => $request->input('status', 'active'),
]);
if ($request->filled('products')) {
$productIds = explode('#', $request->input('products'));
$productIds = array_filter(array_map('trim', $productIds));
Product::whereIn('id', $productIds)->update(['discount_id' => $discount->id]);
}
return redirect()->route('discounts.index')->with('success', 'Попустот е успешно ажуриран');
}
}
......@@ -19,7 +19,7 @@ class ProductController extends Controller
*/
public function index()
{
$products = Product::with('productColors')->get();
$products = Product::with('productColors')->paginate(10);
return view('products.index', compact('products'));
}
......@@ -32,10 +32,7 @@ public function create()
$brands = Brand::all();
$discounts = Discount::where('status', 'active')->get();
// Retrieve old images from the session
$oldImages = session()->hasOldInput('images') ? session('images') : [];
return view('products.create', compact('categories', 'brands', 'discounts', 'oldImages'));
return view('products.create', compact('categories', 'brands', 'discounts'));
}
/**
......@@ -59,9 +56,6 @@ public function store(ProductRequest $request)
]);
}
//нешто не ми успева тука, ќе се врнам..
session()->flashInput(['images' => $request->old('images', [])]);
$images = $request->file('images');
if ($images) {
foreach ($images as $image) {
......@@ -85,9 +79,8 @@ public function edit(Product $product)
{
$categories = Category::all();
$brands = Brand::all();
$product->load('productColors'); // Load product colors relationship
$product->load('productColors');
// Trim and explode the colors from the product
$productColors = $product->productColors->pluck('color_name')->map(function ($color) {
return trim($color);
})->toArray();
......
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class DiscountRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' => 'required|string|max:50',
'percentage' => 'required|numeric|between:1,100',
'category' => 'required|exists:discounts,category',
'products' => 'nullable|string',
];
}
public function messages()
{
return [
'name.required' => 'Името на попустот е задолжително.',
'name.string' => 'Името на попустот мора да биде текст.',
'name.max' => 'Името на попустот не може да биде подолго од 50 карактери.',
'percentage.required' => 'Процентот на попустот е задолжителен.',
'percentage.numeric' => 'Процентот на попустот мора да биде број.',
'percentage.between' => 'Процентот на попустот мора да биде помеѓу 1 и 100.',
'category.required' => 'Категоријата на попустот е задолжителна.',
'category.exists' => 'Избраната категорија не постои.',
'products.string' => 'Полето за продукти мора да биде текст.',
];
}
}
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Color extends Model
{
use HasFactory;
protected $fillable = ['name'];
}
......@@ -10,4 +10,9 @@ class Discount extends Model
use HasFactory;
protected $fillable = ['name', 'percentage', 'category', 'status'];
public function products()
{
return $this->hasMany(Product::class);
}
}
......@@ -40,4 +40,9 @@ public function productColors()
{
return $this->hasMany(ProductColor::class);
}
public function discount()
{
return $this->belongsTo(Discount::class);
}
}
......@@ -14,8 +14,8 @@ public function up(): void
Schema::create('discounts', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->decimal('percentage');
$table->enum('category', ['nedelen', 'mesecen', 'novogodisen', 'veligdenski']);
$table->integer('percentage');
$table->string('category');
$table->enum('status', ['active', 'archived'])->default('active');
$table->timestamps();
});
......
......@@ -23,5 +23,6 @@ public function run(): void
$this->call(CategorySeeder::class);
$this->call(BrandsTableSeeder::class);
$this->call(ProductSeeder::class);
$this->call(DiscountSeeder::class);
}
}
<?php
namespace Database\Seeders;
use App\Models\Discount;
use Illuminate\Database\Seeder;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
class DiscountSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$discounts = [
['name' => 'Weekend Sale', 'percentage' => 20, 'category' => 'Викенд Попуст', 'status' => 'active'],
['name' => 'Summer Discount', 'percentage' => 30, 'category' => 'Летен Попуст', 'status' => 'active'],
['name' => 'Christmas Sale', 'percentage' => 25, 'category' => 'Божиќен Попуст', 'status' => 'archived'],
['name' => 'Spring Clearance', 'percentage' => 40, 'category' => 'Пролетно Чистење', 'status' => 'archived'],
['name' => 'Week Sale', 'percentage' => 15, 'category' => 'Неделен Попуст', 'status' => 'active'],
['name' => 'Easter Sale', 'percentage' => 35, 'category' => 'Велигденски Попуст', 'status' => 'archived'],
];
foreach ($discounts as $discountData) {
Discount::create($discountData);
}
}
}
......@@ -23,12 +23,10 @@ public function run()
{
$faker = Faker::create();
// Create brands, categories, and colors
$brands = Brand::all()->pluck('id')->toArray();
$categories = Category::all()->pluck('id')->toArray();
$colors = ['black', 'white', 'yellow', 'blue', 'green', 'red', 'pink'];
// Generate fake products
foreach (range(1, 20) as $index) {
$product = new Product();
$product->name = $faker->sentence(2);
......@@ -58,7 +56,6 @@ public function run()
]);
}
// Generate fake images for the product
$this->generateProductImages($product);
}
}
......@@ -71,26 +68,18 @@ public function run()
*/
private function generateProductImages(Product $product)
{
// Get the path to your images folder
$imagePath = storage_path('app/public/images/products');
// Get all files in the folder
$images = glob($imagePath . '/*');
// Check if there are any images
if (count($images) > 0) {
// Choose a random number of images between 1 and 3
$numImages = rand(1, 3);
// Shuffle the images array to randomize the selection
shuffle($images);
// Loop through the selected number of images
for ($i = 0; $i < $numImages; $i++) {
// Get the image filename
$imageName = basename($images[$i]);
// Save the image to the ProductImage model
ProductImage::create([
'product_id' => $product->id,
'image' => 'images/products/' . $imageName,
......@@ -99,12 +88,3 @@ private function generateProductImages(Product $product)
}
}
}
// the original images seeder
// for ($i = 0; $i < $imageCount; $i++) {
// $path = $faker->imageUrl();
// ProductImage::create([
// 'product_id' => $product->id,
// 'image' => $path,
// ]);
\ No newline at end of file
......@@ -95,3 +95,11 @@ #sidebar.expanded #closeSidebarBtn {
display: inline-block;
top: 0;
}
.pagination {
font-size: 0.875rem; /* Adjust the font size as needed */
}
.pagination .page-link {
padding: 0.25rem 0.5rem; /* Adjust padding as needed */
}
document.addEventListener("DOMContentLoaded", function () {
document.getElementById("cancel").addEventListener("click", function () {
const form = document.getElementById("create_discount");
form.querySelectorAll(
'input[type="text"], input[type="number"], textarea, select'
).forEach(function (input) {
if (input.tagName.toLowerCase() === "select") {
input.selectedIndex = 0; // Reset select dropdown to the default option
} else {
input.value = "";
}
});
window.scrollTo({ top: 0, behavior: "smooth" });
document.getElementById("name").focus();
});
});
\ No newline at end of file
......@@ -8,6 +8,8 @@ document.addEventListener("DOMContentLoaded", function () {
if (!isNaN(value) && value > 0) {
input.value = value - 1;
}
updateColorCheckboxValidity();
updateCheckboxValidity();
});
document.getElementById("plus-btn").addEventListener("click", function () {
......@@ -16,6 +18,8 @@ document.addEventListener("DOMContentLoaded", function () {
if (!isNaN(value)) {
input.value = value + 1;
}
updateColorCheckboxValidity();
updateCheckboxValidity();
});
// чек боксовите за боја
......@@ -28,88 +32,163 @@ document.addEventListener("DOMContentLoaded", function () {
} else {
label.classList.remove("checked");
}
updateColorCheckboxValidity();
updateCheckboxValidity();
});
});
// споредба на тоа колку бои ќе одбереме со колку парчиња на лагер сме одбрале
// не може админот да одбере повеќе врсти на бои од количината на лагер.
const stockQuantityInput = document.getElementById("stock_quantity");
stockQuantityInput.addEventListener("input", function () {
const maxColors = parseInt(this.value);
updateColorCheckboxValidity(maxColors);
});
colorCheckboxes.forEach(function (checkbox) {
const sizeCheckboxes = document.querySelectorAll(".size-checkbox-input");
sizeCheckboxes.forEach(function (checkbox) {
checkbox.addEventListener("change", function () {
updateColorCheckboxValidity(parseInt(stockQuantityInput.value));
updateCheckboxValidity();
});
});
function updateColorCheckboxValidity(maxColors) {
function updateCheckboxValidity() {
const stockQuantity = parseInt(
document.getElementById("stock_quantity").value
);
// Проверка за боите
const checkedColorCheckboxes = document.querySelectorAll(
".color-checkbox-input:checked"
);
const uncheckedColorCheckboxes = document.querySelectorAll(
'.color-checkbox-input[type="checkbox"]:not(:checked)'
);
if (checkedColorCheckboxes.length > stockQuantity) {
checkedColorCheckboxes.forEach(function (checkbox) {
checkbox.checked = false;
checkbox.nextElementSibling.classList.remove("checked");
});
}
if (checkedColorCheckboxes.length > maxColors) {
alert(
"Не може да се селектират повеќе бои отколку што има парчиња на магацин"
);
uncheckedColorCheckboxes.forEach(function (checkbox) {
if (confirm) {
const lastCheckedCheckbox =
checkedColorCheckboxes[
checkedColorCheckboxes.length - 1
];
lastCheckedCheckbox.checked = false;
const label = lastCheckedCheckbox.nextElementSibling;
label.classList.remove("checked");
}
checkbox.disabled = true;
// Проверка за величините
const checkedSizeCheckboxes = document.querySelectorAll(
".size-checkbox-input:checked"
);
if (checkedSizeCheckboxes.length > stockQuantity) {
checkedSizeCheckboxes.forEach(function (checkbox) {
checkbox.checked = false;
checkbox.nextElementSibling.classList.remove("checked");
});
} else {
uncheckedColorCheckboxes.forEach(function (checkbox) {
checkbox.disabled = false;
}
const uncheckedSizeCheckboxes = document.querySelectorAll(
".size-checkbox-input:not(:checked)"
);
uncheckedSizeCheckboxes.forEach(function (checkbox) {
checkbox.disabled = checkedSizeCheckboxes.length >= stockQuantity;
if (checkbox.disabled) {
const messageElement = document.querySelector(
".stock_quantity_exceeded_for_sizes"
);
messageElement.innerText = `Максимален број на различни величини е достигнат. (Количина ${
document.getElementById("stock_quantity").value
})`;
} else {
checkbox.nextElementSibling.style.backgroundColor = "";
document.querySelector(
".stock_quantity_exceeded_for_sizes"
).innerText = "";
}
});
}
function updateColorCheckboxValidity() {
const stockQuantity = parseInt(
document.getElementById("stock_quantity").value
);
const checkedColorCheckboxes = document.querySelectorAll(
".color-checkbox-input:checked"
);
if (checkedColorCheckboxes.length > stockQuantity) {
const excessCheckedCheckboxes = Array.from(
checkedColorCheckboxes
).slice(stockQuantity);
excessCheckedCheckboxes.forEach(function (checkbox) {
checkbox.checked = false;
checkbox.nextElementSibling.classList.remove("checked");
});
}
const uncheckedColorCheckboxes = document.querySelectorAll(
".color-checkbox-input:not(:checked)"
);
uncheckedColorCheckboxes.forEach(function (checkbox) {
checkbox.disabled = checkedColorCheckboxes.length >= stockQuantity;
if (checkbox.disabled) {
checkbox.nextElementSibling.style.backgroundColor = "white";
const messageElement = document.querySelector(
".stock_quantity_exceeded_for_colors"
);
messageElement.innerText =`Максимален број на различни бои е достигнат. (Количина ${
document.getElementById("stock_quantity").value
})`;
} else {
checkbox.nextElementSibling.style.backgroundColor = "";
// Remove the message when the checkbox is enabled
document.querySelector(
".stock_quantity_exceeded_for_colors"
).innerText = "";
}
});
}
// делот со 4-те слики
const imageInputs = document.querySelectorAll(
'.image-upload-box input[type="file"]'
);
imageInputs.forEach(function (input) {
input.addEventListener("change", function (event) {
const file = event.target.files[0];
const reader = new FileReader();
reader.onload = function (e) {
const img =
input.parentElement.querySelector(".uploaded-image");
img.src = e.target.result;
document
.querySelectorAll('.image-upload-box input[type="file"]')
.forEach(function (input) {
input.addEventListener("change", function () {
const reader = new FileReader();
const imageContainer = this.parentNode.querySelector(
".image-container img"
);
reader.onload = function (e) {
imageContainer.src = e.target.result;
};
input.parentElement.querySelector(
".image-container + i"
).style.display = "none";
};
reader.readAsDataURL(file);
reader.readAsDataURL(this.files[0]);
});
});
});
//копчето -откажи- на крајо од формата
document.getElementById("cancel").addEventListener("click", function () {
document.getElementById("create_product").reset();
const colorCheckboxes = document.querySelectorAll(
".color-checkbox-input"
);
const form = document.getElementById("create_product");
form.querySelectorAll(
'input[type="text"], input[type="number"], input[type="checkbox"], textarea'
).forEach(function (input) {
if (input.type === "checkbox") {
input.checked = false;
} else {
input.value = "";
}
});
document.getElementById("stock_quantity").value = 1;
const colorCheckboxes = form.querySelectorAll(".color-checkbox-input");
colorCheckboxes.forEach(function (checkbox) {
checkbox.checked = false;
const label = checkbox.nextElementSibling;
label.classList.remove("checked");
});
form.querySelectorAll(".text-danger").forEach(function (error) {
error.textContent = "";
});
form.querySelectorAll('input[type="file"]').forEach(function (input) {
input.value = "";
const imageContainer = input.parentNode.querySelector(
".image-container img"
);
imageContainer.src = "";
});
window.scrollTo({ top: 0, behavior: "smooth" });
document.getElementById("name").focus();
});
......
@extends('layouts.create-edit')
@section('content')
<div class="container px-2 py-5">
<div class="row">
<div class="col-md-8 offset-md-2">
<form id="create_discount" method="POST" action="{{ route('discounts.store') }}">
@csrf
<div class="row mb-3">
<div class="col d-flex align-center">
<a href="{{ route('products.index') }}" class="text-secondary"><i class="fa-solid fa-left-long fa-2x"></i></a>
<span class="product h5 px-3">Попуст / Промо код</span>
</div>
<div class="col">
<div class="mb-3 d-flex justify-content-end">
<select class="form-select w-50 " id="status" name="status">
<option disabled selected>Статус</option>
<option value="active">Активен</option>
<option value="archived">Архивиран</option>
</select>
</div>
</div>
</div>
<div class="mb-3">
<label for="name" class="form-label">Име на попуст</label>
<input type="text" class="form-control" id="name" name="name" value="{{ old('name') }}">
@error('name')
<span class="text-danger">{{ $message }}</span>
@enderror
</div>
<div class="mb-3 w-50">
<label for="percentage" class="form-label">Попуст во проценти</label>
<input type="number" class="form-control" id="percentage" name="percentage" value="{{ old('percentage') }}">
@error('percentage')
<span class="text-danger">{{ $message }}</span>
@enderror
</div>
<div class="mb-3">
<label for="category" class="form-label">Категорија</label>
<select class="form-select" id="category" name="category">
<option disabled selected>Избери категорија</option>
@foreach($categories as $category)
<option value="{{ $category }}" {{ old('category') == $category ? 'selected' : '' }}>{{ $category }}</option>
@endforeach
</select>
@error('category')
<span class="text-danger">{{ $message }}</span>
@enderror
</div>
<div class="mb-3">
<label for="products" class="form-label">Постави попуст на:</label>
<input type="text" class="form-control" id="products" name="products" value="{{ old('products') }}">
<small class="form-text text-muted">Внеси 'id' на продукт/продукти одделени со '#' (пример, #1#3#5).</small>
@error('products')
<span class="text-danger">{{ $message }}</span>
@enderror
</div>
<div class="mb-3">
<button type="submit" class="btn btn-dark w-50">Зачувај</button>
<a id="cancel" class="cancel btn w-25">Откажи</a>
</div>
</form>
</div>
</div>
</div>
@endsection
@extends('layouts.create-edit')
@section('content')
<div class="container px-2 py-5">
<div class="row">
<div class="col-md-8 offset-md-2">
<form id="edit_discount" method="POST" action="{{ route('discounts.update', $discount->id) }}">
@csrf
@method('PUT')
<div class="row mb-3">
<div class="col d-flex align-center">
<a href="{{ route('discounts.index') }}" class="text-secondary"><i class="fa-solid fa-left-long fa-2x"></i></a>
<span class="product h5 px-3">Попуст / Промо Код</span>
</div>
<div class="col">
<div class="mb-3 d-flex justify-content-end">
<select class="form-select w-50 " id="status" name="status">
<option disabled selected>Статус</option>
<option value="active" {{ $discount->status === 'active' ? 'selected' : '' }}>Активен</option>
<option value="archived" {{ $discount->status === 'archived' ? 'selected' : '' }}>Архивиран</option>
</select>
</div>
</div>
</div>
<div class="mb-3">
<label for="name" class="form-label">Име на попуст</label>
<input type="text" class="form-control" id="name" name="name" value="{{ $discount->name }}">
@error('name')
<span class="text-danger">{{ $message }}</span>
@enderror
</div>
<div class="mb-3">
<label for="percentage" class="form-label">Процент</label>
<input type="number" class="form-control" id="percentage" name="percentage" value="{{ $discount->percentage }}">
@error('percentage')
<span class="text-danger">{{ $message }}</span>
@enderror
</div>
<div class="mb-3">
<label for="category" class="form-label">Категорија</label>
<select class="form-select" id="category" name="category">
<option disabled selected>Избери категорија</option>
@foreach($discountCategories as $category)
<option value="{{ $category }}" {{ $discount->category === $category ? 'selected' : '' }}>{{ $category }}</option>
@endforeach
</select>
@error('category')
<span class="text-danger">{{ $message }}</span>
@enderror
</div>
<div class="mb-3">
<label for="products" class="form-label">Постави попуст на:</label>
<input type="text" class="form-control" id="products" name="products" value="{{ old('products', $discount->products->pluck('id')->implode('#')) }}">
<small class="text-muted">Внеси 'id' на продукт/продукти одделени со '#' (пример, #1#3#5).</small>
@error('products')
<span class="text-danger">{{ $message }}</span>
@enderror
</div>
<div class="row mb-3 d-flex justify-center">
<button type="submit" class="btn btn-dark w-50">Зачувај</button>
<a href="{{ route('discounts.index') }}" class="cancel w-25">Откажи</a>
</div>
</form>
</div>
</div>
</div>
@endsection
\ No newline at end of file
@extends('layouts.app')
@section('content')
<div class="container container-fluid">
<div class="row">
<div class="col-12 text-right mt-5">
@if(session('success'))
<div class="alert alert-success text-center" role="alert">
{{ session('success') }}
</div>
@endif
<div class="mb-3">
<input type="text" id="searchInput" placeholder="Пребарувај...">
</div>
<div id="add-discount">
Додај нов попуст / промо код<a href="{{ route('discounts.create') }}" class="m-2 btn btn-secondary">
+</a>
</div>
</div>
</div>
<div class="row mt-5">
<div class="col-12">
<h4 class="font-weight-bold">Активни</h4>
@foreach($activeDiscounts as $discount)
<div class="card p-3 mb-3">
<div class="row d-flex align-items-center">
<div class="col col-2 font-weight-bold small">#{{ $discount->id }}</div>
<div class="col col-2 font-weight-bold">{{ $discount->percentage }}%</div>
<div class="col col-6 font-weight-bold">{{ $discount->name }}</div>
<div class="col col-2 text-right">
<a href="{{ route('discounts.edit', $discount) }}" class="btn border rounded-circle"><i class="fas fa-edit"></i></a>
</div>
</div>
</div>
@endforeach
</div>
</div>
<div class="row mt-5">
<div class="col-12">
<h4 class="font-weight-bold">Активни</h4>
@foreach($archivedDiscounts as $discount)
<div class="card p-3 mb-3">
<div class="row d-flex align-items-center">
<div class="col col-2 text-secondary small">#{{ $discount->id }}</div>
<div class="col col-2 text-secondary">{{ $discount->percentage }}%</div>
<div class="col col-6 text-secondary">{{ $discount->name }}</div>
<div class="col col-2 text-right">
<a href="{{ route('discounts.edit', $discount) }}" class="btn border rounded-circle"><i class="fas fa-edit"></i></a>
</div>
</div>
</div>
@endforeach
</div>
</div>
</div>
@endsection
......@@ -19,11 +19,14 @@
<!-- Scripts -->
@vite(['resources/sass/app.scss', 'resources/js/app.js'])
</head>
<body>
<div class="container">
@yield('content')
</div>
<script src="{{ asset('js/product.js') }}"></script>
<script src="{{ asset('js/discount.js') }}"></script>
</body>
</html>
\ No newline at end of file
......@@ -28,7 +28,7 @@
</a>
</li>
<li class="nav-item mt-2" id="menu-item-3">
<a href="#" class="nav-link align-middle px-0">
<a href="{{ route('discounts.index') }}" class="nav-link align-middle px-0">
<div class="sidebar-expanded-text-container">
<span class="ms-1 d-sm-inline"><i class="fa-sharp fa-solid fa-percent fa-2x"></i></span>
<span class="h3 sidebar-expanded-text"> Попусти / Промо</span>
......
......@@ -63,27 +63,28 @@
<div class="mb-3">
<label for="size" class="form-label">Величина</label><br>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="size_xs" name="sizes[]" value="xs" {{ in_array('xs', old('sizes', [])) ? 'checked' : '' }}>
<input class="form-check-input size-checkbox-input" type="checkbox" id="size_xs" name="sizes[]" value="xs" {{ in_array('xs', old('sizes', [])) ? 'checked' : '' }}>
<label class="form-check-label" for="size_xs">XS</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="size_s" name="sizes[]" value="s" {{ in_array('s', old('sizes', [])) ? 'checked' : '' }}>
<input class="form-check-input size-checkbox-input" type="checkbox" id="size_s" name="sizes[]" value="s" {{ in_array('s', old('sizes', [])) ? 'checked' : '' }}>
<label class="form-check-label" for="size_s">S</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="size_m" name="sizes[]" value="m" {{ in_array('m', old('sizes', [])) ? 'checked' : '' }}>
<input class="form-check-input size-checkbox-input" type="checkbox" id="size_m" name="sizes[]" value="m" {{ in_array('m', old('sizes', [])) ? 'checked' : '' }}>
<label class="form-check-label" for="size_m">M</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="size_l" name="sizes[]" value="l" {{ in_array('l', old('sizes', [])) ? 'checked' : '' }}>
<input class="form-check-input size-checkbox-input" type="checkbox" id="size_l" name="sizes[]" value="l" {{ in_array('l', old('sizes', [])) ? 'checked' : '' }}>
<label class="form-check-label" for="size_l">L</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="size_xl" name="sizes[]" value="xl" {{ in_array('xl', old('sizes', [])) ? 'checked' : '' }}>
<input class="form-check-input size-checkbox-input" type="checkbox" id="size_xl" name="sizes[]" value="xl" {{ in_array('xl', old('sizes', [])) ? 'checked' : '' }}>
<label class="form-check-label" for="size_xl">XL</label>
</div> <br>
<span class="text-danger stock_quantity_exceeded_for_sizes p2"></span>
@if ($errors->has('size'))
<span class="text-danger">{{ $errors->first('size') }}</span>
<span class="text-danger stock_quantity_exceeded">{{ $errors->first('size') }}</span>
@endif
</div>
......@@ -125,6 +126,7 @@
<input class="form-check-input color-checkbox-input" type="checkbox" id="color_pink" name="colors[]" value="pink" {{ in_array('pink', old('colors', [])) ? 'checked' : '' }}>
<label class="pink color-checkbox" for="color_pink"></label>
</div>
<span class="text-danger stock_quantity_exceeded_for_colors"></span>
@if ($errors->has('colors'))
<span class="text-danger">{{ $errors->first('colors') }}</span>
@endif
......@@ -153,8 +155,8 @@
<div class="image-upload-box">
<input type="file" class="form-control" accept="image/*" name="images[]">
<div class="image-container">
@if (old('images.' . $i))
<img src="{{ old('images.' . $i) }}" class="uploaded-image">
@if(Session::has('uploaded_image'))
<img src="{{ asset(Session::get('uploaded_image')) }}" class="uploaded-image">
@else
<img src="{{ $oldImages[$i] ?? '' }}" class="uploaded-image">
@endif
......@@ -177,7 +179,7 @@
<option value="{{ $category->id }}">{{ $category->name }}</option>
@endforeach
</select>
@if ($errors->has('category'))
@if ($errors->has('category_id'))
<span class="text-danger">{{ $errors->first('category') }}</span>
@endif
</div>
......@@ -204,7 +206,7 @@
</button>
</div>
<!-- модал за попуст -->
<div class="modal fade" id="discountModal" tabindex="-1" aria-labelledby="discountModalLabel" aria-hidden="true">
<div class="modal fade" id="discountModal" tabindex="-1" aria-labelledby="discountModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment