172 lines
9.7 KiB
PHP
172 lines
9.7 KiB
PHP
@extends('admin.layouts.app')
|
||
|
||
@section('content')
|
||
<div class="main-content app-content">
|
||
<div class="container-fluid pt-4">
|
||
|
||
<div class="row">
|
||
<div class="col-xl-12">
|
||
@error('error')
|
||
<span class="text-danger">{{ $message }}</span>
|
||
@enderror
|
||
<form action="{{ route('admin.product.update', $product) }}" method="POST" enctype="multipart/form-data">
|
||
@csrf
|
||
@method('put')
|
||
<div class="card custom-card">
|
||
<div class="card-header">
|
||
<div class="card-title">
|
||
ویرایش محصول
|
||
</div>
|
||
</div>
|
||
|
||
<div class="card-body pt-0">
|
||
|
||
|
||
<div class="row gy-3">
|
||
<!-- Name -->
|
||
<div class="col-xl-6">
|
||
<label class="form-label">نام فارسی</label>
|
||
<input
|
||
type="text"
|
||
class="form-control" name="name"
|
||
placeholder="نام فارسی را وارد کنید"
|
||
value="{{ old('name', $product->name) }} "
|
||
/>
|
||
@error('name')
|
||
<span class="text-danger">{{ $message }}</span>
|
||
@enderror
|
||
</div>
|
||
|
||
<!-- Name -->
|
||
<div class="col-xl-6">
|
||
<label class="form-label">نام انگلیسی</label>
|
||
<input type="text" class="form-control" name="en_name"
|
||
placeholder="نام انگلیسی را وارد کنید"
|
||
value="{{ old('en_name', $product->en_name) }}">
|
||
@error('en_name')
|
||
<span class="text-danger">{{ $message }}</span>
|
||
@enderror
|
||
</div>
|
||
|
||
<!-- Category -->
|
||
<div class="col-xl-6">
|
||
<label class="form-label">دسته بندی</label>
|
||
<select class="form-control" name="category_id">
|
||
<option>یک دسته بندی انتخاب کنید</option>
|
||
@foreach($productCategories as $productCategory)
|
||
<option
|
||
value="{{ $productCategory->id }}"
|
||
@selected(old('category_id', $product->product_category_id) == $productCategory->id)
|
||
>
|
||
{{ $productCategory->name }}
|
||
</option>
|
||
@endforeach
|
||
</select>
|
||
@error('category_id')
|
||
<span class="text-danger">{{ $message }}</span>
|
||
@enderror
|
||
</div>
|
||
|
||
<!-- Price -->
|
||
<div class="col-xl-6">
|
||
<label class="form-label">قیمت</label>
|
||
<input type="number" class="form-control" name="price"
|
||
placeholder="قیمت را وارد کنید"
|
||
value="{{ old('price',$product->price) }}">
|
||
@error('price')
|
||
<span class="text-danger">{{ $message }}</span>
|
||
@enderror
|
||
</div>
|
||
|
||
<!-- Discount Price -->
|
||
<div class="col-xl-6">
|
||
<label class="form-label">تخفیف</label>
|
||
<input type="number" class="form-control" name="discount"
|
||
placeholder="تخفیف را وارد کنید"
|
||
value="{{ old('discount', $product->discount) }}">
|
||
@error('discount')
|
||
<span class="text-danger">{{ $message }}</span>
|
||
@enderror
|
||
</div>
|
||
|
||
<!-- Stock -->
|
||
<div class="col-xl-6">
|
||
<label class="form-label">موجودی</label>
|
||
<input type="number" class="form-control" name="qty"
|
||
placeholder="تعداد موجودی را وارد کنید"
|
||
value="{{ old('qty', $product->qty) }}">
|
||
@error('qty')
|
||
<span class="text-danger">{{ $message }}</span>
|
||
@enderror
|
||
</div>
|
||
|
||
<!-- Description -->
|
||
<div class="col-xl-12">
|
||
<label class="form-label">توضیحات</label>
|
||
<textarea class="form-control"
|
||
name="description"
|
||
rows="4"
|
||
placeholder="توضیحات را وارد کنید">{{ old('description', $product->description) }}</textarea>
|
||
|
||
@error('description')
|
||
<span class="text-danger">{{ $message }}</span>
|
||
@enderror
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Product Images -->
|
||
<div
|
||
class="image-upload-wrapper d-flex flex-wrap gap-2 px-0 pt-0 mt-3"
|
||
id="imagePreviewContainer"
|
||
style=" border-radius: 8px; padding: 10px;"
|
||
>
|
||
@foreach($product->productImages as $image)
|
||
|
||
<div class="position-relative" style="width:150px;height:150px;">
|
||
<img src="{{ asset('storage/'.$image->file->path) }}"
|
||
class="img-fluid rounded"
|
||
style="width:100%;height:100%;object-fit:cover;"
|
||
alt="{{ $product->name }}">
|
||
|
||
<a href="{{ route('admin.product.remove-image', [$product, $image]) }}"
|
||
class="remove-btn btn btn-sm btn-danger position-absolute top-0 end-0 delete-image">
|
||
×
|
||
</a>
|
||
</div>
|
||
|
||
@endforeach
|
||
|
||
<label
|
||
id="uploadPlaceholder"
|
||
class="upload-placeholder"
|
||
for="imageInput"
|
||
style="cursor: pointer; width:150px; height:150px; display: flex; justify-content: center; align-items: center; border: 2px dashed #ccc; border-radius: 8px; padding: 20px; text-align: center;"
|
||
>
|
||
<div>📷<br><strong>آپلود یا کشیدن</strong></div>
|
||
<small style="color:#999;">JPG / PNG / JPEG / WEBP</small>
|
||
</label>
|
||
<input
|
||
id="imageInput"
|
||
name="images[]"
|
||
type="file"
|
||
accept=".jpg,.png,.jpeg,.webp"
|
||
multiple
|
||
style="display:none"
|
||
/>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<div class="card-footer text-end">
|
||
<button type="submit" class="btn btn-primary">ذخیره تغییرات</button>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
@endsection
|