Browse Source

Edit ages pruduct SimplePages

Azam Rezayi 4 years ago
parent
commit
46d9c462b4

+ 8 - 51
packages/product/src/Http/Controllers/ProductController.php

@@ -51,76 +51,33 @@ class ProductController extends Controller
 //**************************************************** page create products *****************
     public function create(Request $request)
     {
-        $categories = Category::orderBy('parent_id')->where('parent_id', 0)->get();
-        $uploads = Upload::orderBy('id')->get()->first();
-        if (!$request->has('draft_id')) {
-            $draft = new Draft();
-            $draft->object_type = 'Packages\Product\Draft';
-            $draft->delete();
-            $draft->save();
-            return redirect()->route('products.create', ['draft_id' => $draft->id]);
-        } else {
-            $draft = Draft::find($request->draft_id);
-            if (is_null($draft)) {
-                return redirect()->route('products.create');
-            }
-        }
-        $args = [
-            'draft' => $draft
-        ];
-       $product= Product:: orderBy('id', 'DESC');
-        return view('product::product.create', $args, compact('categories', 'product', 'uploads'));
+        return view('product::product.create');
     }
 
 // *********************************************************save products ******************
-    public function store(ProductRequest $request)
+    public function store(Request $request)
     {
-//       dd($request->all());
-        $request->merge([
-            'price' => preg_replace('/[^0-9]+/', '', $request->price),
-            'sale_price' => preg_replace('/[^0-9]+/', '', $request->sale_price),
-        ]);
-        if (!$request->has('draft_id')) {
-            return abort(403, 'دسترسی به این صفحه ممکن نیست ؛ لطفا مجددا تلاش کنید.');
-        }
-        $draft = Draft::findOrFail($request->draft_id);
-//        $info = $request->only(['featureDescription', 'featureCaption']);
         $data = [
             'title' => $request->title,
             'slug' => $request->slug,
             'sku' => $request->sku,
             'ReleaseStatus' => $request->ReleaseStatus,
-            'price' => $request->price,
-            'sale_price' => $request->sale_price,
             'type' => $request->type,
-            'status' => $request->status,
             'discription' => $request->discription,
             'creator_id' => auth()->user()->id,
-//            'descriptionImg' => $request->featureDescription,
-//                'caption' => $request->featureCaption,
+
         ];
-//        if( $draft->attachments->count() == 0 ){
-//            return redirect()->back()
-//                ->withErrors( ['error_message' => 'حتما باید یک فایل آپلود شود.'] )
-//                ->withInput( $request->all() );
-//        }
-//        dd($draft->attachments->count() == 0);
         $product = Product::create($data);
-        $product->categories()->sync($request->categories);
-
-       Upload::where('parent_type', 'Packages\Product')->where('uploadable_id', $draft->id)->where('uploadable_id', $draft->id)
-            ->update(['parent_type' => 'image\Product', 'uploadable_id' => $product->id]);
-        $draft->delete();
-//        $uploaded = Upload::create();
-
-
+        if ( 'type'=== 0){
+            $msg = 'ذخیره محصول با موفقیت انجام شد ';
+            return redirect(route('products.index', $product->id))->with('success', $msg);
+        }
         $msg = 'ذخیره محصول با موفقیت انجام شد ';
-        return redirect(route('products.edit', $product->id))->with('success', $msg);
+        return redirect(route('products.index', $product->id))->with('success', $msg);
     }
     // ******************************************************edit page product*********************************************
     public function edit(Product $product)
     {
-        $categories = Category::where('parent_id', 0)->orderBy('title')->get();
         return view('product::product.edit', compact('product', 'categories'));
     }
 

+ 318 - 0
packages/product/src/Http/Controllers/ProductControllerCop.php

@@ -0,0 +1,318 @@
+<?php
+
+namespace Packages\Product\Http\Controllers;
+
+use Illuminate\Support\Facades\Auth;
+use App\Http\Controllers\Controller;
+use Facade\Ignition\Support\Packagist\Package;
+use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Support\Facades\Facade;
+use Illuminate\Support\Facades\File;
+use Illuminate\Support\Facades\Storage;
+use Illuminate\Support\Str;
+use Packages\Product\Models\Draft;
+use Packages\Product\Http\Requests\ProductRequest;
+use Packages\Product\Http\Requests\ProductRequestEdit;
+use Packages\Product\Models\Product;
+use Illuminate\Http\Request;
+use App\Models\Category;
+use App\Models\Upload;
+use phpDocumentor\Reflection\Types\Compound;
+
+class ProductController extends Controller
+{
+    public function __construct()
+    {
+    }
+
+//  *******************************************show  page product ************
+    public function index()
+    {
+        $categories = Category::orderBy('id', 'DESC')->get();
+        $draft = Draft::orderBy('id', 'DESC')->first();
+        $products = Product::query()->orderBy('id', 'DESC');
+
+        if (request()->has('productCategory') && request('productCategory') != '')
+            $products = $products->whereHas('categories', function (Builder $query) {
+                $query->whereRaw('id = ?', [request('productCategory')]);
+            });
+        if (request()->has('productStatus') && request('productStatus') != '')
+            $products = $products->whereRaw('status = ?', [request('productStatus')]);
+        if (request()->has('productName') && request('productName') != '')
+            $products = $products->whereRaw('title = ?', [request('productName')]);
+        if (request()->has('creatorId') && request('creatorId') != '')
+            $products = $products->whereHas('user', function (Builder $query) {
+                $query->whereRaw('name= ?', [request('creatorId')]);
+            });
+        $products = $products->paginate();
+        return view('product::index', compact('products', 'categories', 'draft'));
+    }
+
+//**************************************************** page create products *****************
+    public function create(Request $request)
+    {
+        $categories = Category::orderBy('parent_id')->where('parent_id', 0)->get();
+        $uploads = Upload::orderBy('id')->get()->first();
+        if (!$request->has('draft_id')) {
+            $draft = new Draft();
+            $draft->object_type = 'Packages\Product\Draft';
+            $draft->delete();
+            $draft->save();
+            return redirect()->route('products.create', ['draft_id' => $draft->id]);
+        } else {
+            $draft = Draft::find($request->draft_id);
+            if (is_null($draft)) {
+                return redirect()->route('products.create');
+            }
+        }
+        $args = [
+            'draft' => $draft
+        ];
+       $product= Product:: orderBy('id', 'DESC');
+        return view('product::product.create', $args, compact('categories', 'product', 'uploads'));
+    }
+
+// *********************************************************save products ******************
+    public function store(ProductRequest $request)
+    {
+//       dd($request->all());
+        $request->merge([
+            'price' => preg_replace('/[^0-9]+/', '', $request->price),
+            'sale_price' => preg_replace('/[^0-9]+/', '', $request->sale_price),
+        ]);
+        if (!$request->has('draft_id')) {
+            return abort(403, 'دسترسی به این صفحه ممکن نیست ؛ لطفا مجددا تلاش کنید.');
+        }
+        $draft = Draft::findOrFail($request->draft_id);
+//        $info = $request->only(['featureDescription', 'featureCaption']);
+        $data = [
+            'title' => $request->title,
+            'slug' => $request->slug,
+            'sku' => $request->sku,
+            'ReleaseStatus' => $request->ReleaseStatus,
+            'price' => $request->price,
+            'sale_price' => $request->sale_price,
+            'type' => $request->type,
+            'status' => $request->status,
+            'discription' => $request->discription,
+            'creator_id' => auth()->user()->id,
+//            'descriptionImg' => $request->featureDescription,
+//                'caption' => $request->featureCaption,
+        ];
+//        if( $draft->attachments->count() == 0 ){
+//            return redirect()->back()
+//                ->withErrors( ['error_message' => 'حتما باید یک فایل آپلود شود.'] )
+//                ->withInput( $request->all() );
+//        }
+//        dd($draft->attachments->count() == 0);
+        $product = Product::create($data);
+        $product->categories()->sync($request->categories);
+
+       Upload::where('parent_type', 'Packages\Product')->where('uploadable_id', $draft->id)->where('uploadable_id', $draft->id)
+            ->update(['parent_type' => 'image\Product', 'uploadable_id' => $product->id]);
+        $draft->delete();
+//        $uploaded = Upload::create();
+
+
+        $msg = 'ذخیره محصول با موفقیت انجام شد ';
+        return redirect(route('products.edit', $product->id))->with('success', $msg);
+    }
+    // ******************************************************edit page product*********************************************
+    public function edit(Product $product)
+    {
+        $categories = Category::where('parent_id', 0)->orderBy('title')->get();
+        return view('product::product.edit', compact('product', 'categories'));
+    }
+
+// *******************************************update page product*****************************************
+    public function update(ProductRequestEdit $request, Product $product)
+    {
+        $request->merge([
+            'price' => preg_replace('/[^0-9]+/', '', $request->price),
+            'sale_price' => preg_replace('/[^0-9]+/', '', $request->sale_price),
+        ]);
+        $data = [
+            'title' => $request->title,
+            'slug' => $request->slug,
+            'sku' => $request->sku,
+            'price' => $request->price,
+            'sale_price' => $request->sale_price,
+            'type' => $request->type,
+            'ReleaseStatus' => $request->ReleaseStatus,
+            'status' => $request->status,
+            'discription' => $request->discription,
+            'creator_id' => auth()->user()->id,
+        ];
+
+
+        if ($request->has('gallery_image')) {
+            $file = $request->only('gallery_image', 'captionGallery', 'descriptionGallery');
+            $type = 'gallery_image';
+            $diskName = 'product';
+            $this->updateGallery($file, $diskName, $product, $type);
+        }
+        if ($request->has('featured_image')) {
+            $info = $request->only(['featureDescription', 'featureCaption']);
+            $file = $request->file('featured_image');
+            $type = 'featured_image';
+            $diskName = 'product';
+            $this->updateFeature($file, $diskName, $product, $type, $info);
+        }
+        $product->update($data);
+        $product->categories()->sync($request->categories);
+        $msg = 'ویرایش محصول با موفقیت انجام شد ';
+        return redirect(route('products.index'))->with('success', $msg);
+    }
+
+    //***************************** delete products*****************************************
+    public function destroy(Product $product)
+    {
+        $product->delete();
+        {
+            return back();
+        }
+    }
+//****************upload images in the product************************
+    public function uploadFeature(Request $request)
+    {
+        if ($request->has('featured_image')) {
+            $info = $request->only(['featureDescription', 'featureCaption']);
+            $file = $request->file('featured_image');
+            $type = 'featured_image';
+            $diskName = 'product';
+            $fileExtension = $file->getClientOriginalExtension();
+            $fileMimeType = $file->getMimeType();
+            $afterDiskRoot = '/' . jdate()->format('Y') . '/' . jdate()->format('m');
+            $fileName = jdate(time())->format('Ymd') . '_' . $file->getClientOriginalName();
+            $filePath = storage_path('app/public/' . $diskName . $afterDiskRoot . '/' . $fileName);
+
+            if (File::exists($filePath)) {
+                $fileName = time() . '_' . $fileName;
+            }
+            $draft = Draft::orderBy('id', 'Desc')->get()->first();
+            $upload = $file->storeAs($afterDiskRoot, $fileName, $diskName);
+
+            $uploadData = [
+                'name' => $fileName,
+                'path' => $upload,
+                'mime_type' => $fileMimeType,
+                'extension' => $fileExtension,
+                'parent_type' => 'packages\product',
+                'uploadable_type' => 'Packages\Product\Models\Product',
+                'uploadable_id' => $draft->id,
+                'type' => $type,
+                'descriptionImg' => $info['featureDescription'],
+                'caption' => $info['featureCaption'],
+            ];
+            $uploads = Upload::where('type', $type)->where('uploadable_id', $draft->id)->first();
+            if (empty($uploads)) {
+                $uploaded = Upload::create($uploadData);
+            } else {
+                $uploaded = $uploads->update($uploadData);
+            }
+        }
+    }
+
+
+    public function updateFeature($file, $diskName, $product, $type, $info)
+    {
+        $fileExtension = $file->getClientOriginalExtension();
+        $fileMimeType = $file->getMimeType();
+        $afterDiskRoot = '/' . jdate()->format('Y') . '/' . jdate()->format('m');
+        $fileName = jdate(time())->format('Ymd') . '_' . $file->getClientOriginalName();
+        $filePath = storage_path('app/public/' . $diskName . $afterDiskRoot . '/' . $fileName);
+
+        if (File::exists($filePath)) {
+            $fileName = time() . '_' . $fileName;
+        }
+
+        $upload = $file->storeAs($afterDiskRoot, $fileName, $diskName);
+        $uploadData = [
+            'name' => $fileName,
+            'path' => $upload,
+            'mime_type' => $fileMimeType,
+            'extension' => $fileExtension,
+            'type' => $type,
+            'descriptionImg' => $info['featureDescription'],
+            'caption' => $info['featureCaption'],
+        ];
+        $uploaded = $product->uploads()->update($uploadData);
+    }
+
+//************************delete image in the product**********************
+    public function destroyFile(Upload $upload)
+    {
+        $upload->delete();
+        $msg = 'حذف عکس محصول با موفقیت انجام شد ';
+        session()->flash('image_deleted', $msg);
+        return redirect()->back();
+    }
+
+//    ****************************uploadGallery********************
+    public function uploadGallery(Request $request)
+    {
+
+        if ($request->has('gallery_image')) {
+            $files = $request->only('gallery_image', 'captionGallery', 'descriptionGallery');
+            $type = 'gallery_image';
+            $diskName = 'product';
+//           dd($files);
+      foreach ($files['gallery_image'] as $key => $file) {
+            $fileExtension = $file->getClientOriginalExtension();
+            $fileMimeType = $file->getMimeType();
+            $afterDiskRoot = '/' . jdate()->format('Y') . '/' . jdate()->format('m');
+            $fileName = jdate(time())->format('Ymd') . '_' . $file->getClientOriginalName();
+            $filePath = storage_path('app/public/' . $diskName . $afterDiskRoot . '/' . $fileName);
+
+            if (File::exists($filePath)) {
+                $fileName = time() . '_' . $fileName;
+            }
+          $draft = Draft::orderBy('id', 'Desc')->get()->first();
+            $upload = $file->storeAs($afterDiskRoot, $fileName, $diskName);
+
+            $uploadData = [
+                'name' => $fileName,
+                'path' => $upload,
+                'mime_type' => $fileMimeType,
+                'extension' => $fileExtension,
+                'parent_type' => 'packages\product',
+                'uploadable_type' => 'Packages\Product\Models\Product',
+                'uploadable_id' => $draft->id,
+                'type' => $type,
+                'descriptionImg' => $files['descriptionGallery'][$key],
+                'caption' => $files['captionGallery'][$key],
+            ];
+//         dd($uploadData);
+//          $uploaded = Upload::where('uploadable_id', $draft->id)->update($uploadData);
+           $uploaded = Upload::create($uploadData);
+          dd($uploaded);
+
+        }
+      }
+    }
+
+    public function updateGallery($files, $diskName, $product, $type)
+    {
+        foreach ($files['gallery_image'] as $key => $file) {
+            $fileExtension = $file->getClientOriginalExtension();
+            $fileMimeType = $file->getMimeType();
+            $afterDiskRoot = '/' . jdate()->format('Y') . '/' . jdate()->format('m');
+            $fileName = jdate(time())->format('Ymd') . '_' . $file->getClientOriginalName();
+            $filePath = storage_path('app/public/' . $diskName . $afterDiskRoot . '/' . $fileName);
+            if (File::exists($filePath)) {
+                $fileName = time() . '_' . $fileName;
+            }
+            $upload = $file->storeAs($afterDiskRoot, $fileName, $diskName);
+            $uploadData = [
+                'name' => $fileName,
+                'path' => $upload,
+                'mime_type' => $fileMimeType,
+                'extension' => $fileExtension,
+                'type' => $type,
+                'descriptionImg' => $files['descriptionGallery'][$key],
+                'caption' => $files['captionGallery'][$key],
+            ];
+            $uploaded = $product->uploads()->update($uploadData);
+        }
+    }
+}

+ 1 - 16
packages/product/src/Http/Requests/ProductRequest.php

@@ -15,7 +15,6 @@ class ProductRequest extends FormRequest
     {
         return true;
     }
-
     /**
      * Get the validation rules that apply to the request.
      *
@@ -23,26 +22,12 @@ class ProductRequest extends FormRequest
      */
     public function rules()
     {
-//        dd(request()->all());
         return [
             'title' => ['required','max:100'],
-            'price' => ['required'],
             'slug' => ['unique:products'],
             'type' => ['required'],
-            'status' => ['required'],
+            'ReleaseStatus' => ['nullable'],
             'discription' => ['required'],
-            'categories' => ['required'],
-            'featureDescription' => ['nullable'],
-            'featureCaption' => ['nullable'],
-            'descriptionImg' => ['nullable'],
-            'parent_type' =>['nullable'],
-            'caption' => ['nullable'],
-            'gallery_image' => ['nullable'],
-            'featured_image' => ['required', 'image', 'mimes:jpeg,jpg,png,gif', 'max:8000'],
-
-
         ];
-
     }
-
 }

+ 44 - 0
packages/product/src/Http/Requests/ProductRequestCopy.php

@@ -0,0 +1,44 @@
+<?php
+
+namespace Packages\Product\Http\Requests;
+use Illuminate\Foundation\Http\FormRequest;
+use Illuminate\Validation\Rule;
+
+class ProductRequest extends FormRequest
+{
+    /**
+     * Determine if the user is authorized to make this request.
+     *
+     * @return bool
+     */
+    public function authorize()
+    {
+        return true;
+    }
+
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array
+     */
+    public function rules()
+    {
+        return [
+            'title' => ['required','max:100'],
+            'price' => ['required'],
+            'slug' => ['unique:products'],
+            'type' => ['required'],
+            'status' => ['required'],
+            'discription' => ['required'],
+            'categories' => ['required'],
+            'featureDescription' => ['nullable'],
+            'featureCaption' => ['nullable'],
+            'descriptionImg' => ['nullable'],
+            'parent_type' =>['nullable'],
+
+
+        ];
+
+    }
+
+}

+ 1 - 1
packages/product/src/Models/Product.php

@@ -12,7 +12,7 @@ class Product extends Model
 {
     use Sluggable;
     use SoftDeletes;
-   protected $fillable = ['title', 'discription', 'price', 'creator_id', 'type', 'status', 'sale_price', 'sku', 'ReleaseStatus'];
+  protected $fillable = ['title', 'discription', 'price', 'creator_id', 'type', 'status', 'sale_price', 'sku', 'ReleaseStatus'];
 //    protected $guarded = [];
     public function user()
     {

+ 19 - 40
packages/product/src/sass/product.scss

@@ -1,30 +1,22 @@
-
 .card-header {
-        text-align: center !important;
+    text-align: center !important;
 }
-
 .form-control {
-
-         background-color: hsl(315, 22%, 86%);
+    background-color: hsl(315, 22%, 86%);
 }
-
 .required {
-      color: red;
+    color: red;
 }
-
 .py-5 {
-     padding: 0 !important;
+    padding: 0 !important;
 }
-
 .select2 {
     width: 100% !important;
 }
-
 .photo {
-     border: 0px;
-     background-color: #fff;
+    border: 0px;
+    background-color: #fff;
 }
-
 /* Fine Uploader Gallery View Styles
 /* ---------------------------------------*/
 .media {
@@ -36,19 +28,16 @@
     border: 2px solid #752360;
     align-items: flex-start;
 }
-
 #gallery img {
     width: 150px;
     margin-bottom: 10px;
     margin-right: 10px;
     vertical-align: middle;
 }
-
 .hide-element {
     display: none;
 }
 /* Feature Images*/
-
 .btn-file {
     position: relative;
     overflow: hidden;
@@ -68,7 +57,6 @@
     cursor: inherit;
     display: block;
 }
-
 .media-left {
     z-index: 1000;
     cursor: pointer;
@@ -78,19 +66,17 @@
     display: flex;
     padding: 10px;
 }
-
 .media-left img {
     z-index: 1000;
     cursor: pointer;
     display: flex;
 }
-
 .thumbnail {
     color: #006dcc;
     *color: #0044cc;
 }
 .media-body {
-flex: 1;
+    flex: 1;
     padding: 15px;
 }
 #delete {
@@ -98,62 +84,55 @@ flex: 1;
     margin-left: -40px;
     position: relative;
 }
-
 .label-tags i {
     cursor: pointer;
 }
-
 /*    *****************************/
-output span{
+output span {
     padding: 6px;
     text-align: center;
 }
-
-.GalleryImageChoice{
+.GalleryImageChoice {
     padding: 10px;
 }
-.DeleteImages{
-    border:2px solid #752360;
+.DeleteImages {
+    border: 2px solid #752360;
     margin: 5px;
     border-radius: 10px;
 }
-
 @media only screen and (min-width: 900px) {
-.b{
-    padding: 0 17px;
-    margin-top: 20px;
-}
+    .b {
+        padding: 0 17px;
+        margin-top: 20px;
+    }
 }
 .card-header {
     text-align: center !important;
 }
-
 .form-control {
     background-color: hsl(315, 22%, 86%);
+    height: calc(2.3em + 1rem + 5px);
 }
-
 .required {
     color: red;
 }
-
 .py-5 {
     padding-top: 0 !important;
 }
-#mceu_42{
+#mceu_42 {
     display: none;
 }
 .btnSearch {
     margin-top: 10px;
 }
-.searchNaum{
-
+.searchNaum {
     margin: 20px;
 }
 [dir=rtl] .btn .icon, [dir=rtl] .btn .fa, [dir=rtl] .treeview-item .icon {
     margin-right: 0;
     margin-left: 0px !important;
 }
-.message{
+.message {
     margin: auto;
 }
 

+ 124 - 0
packages/product/src/views/product/SimpleProduct.blade.php

@@ -0,0 +1,124 @@
+@component('panel.layouts.component', ['title' => 'ثبت محصول جدید'])
+
+    @slot('style')
+
+    @endslot
+    @slot('subject')
+        <h1><i class="fa fa-users"></i> ثبت محصول جدید </h1>
+        <p>ثبت محصول جدید در فروشگاه.</p>
+    @endslot
+    @slot('breadcrumb')
+        <li class="breadcrumb-item">محصولات</li>
+    @endslot
+
+    @slot('content')
+        <div class="auth-background h-auto py-5">
+            <div class="container py-5">
+                <div class="row align-items-center ">
+                    <div class="col-lg-12 col-md-12 mx-auto">
+                        <div class="card">
+                            <div class="card-header">
+                                <strong>{{ __('ثبت محصول جدید') }}</strong>
+                            </div>
+                            @component('product::components.message')
+                            @endcomponent
+                            <div class="card-body mx-lg-5 px-lg-3">
+                                <form method="POST" action="{{ route('products.store') }}" enctype="multipart/form-data" >
+                                    @csrf
+                                    <div class="form-group">
+                                         <label for="title">{{ __('product.title') }}</label><i class="required">&nbsp; *</i>
+                                         <input id="title" type="text" class="form-control @error('title') is-invalid @enderror" name="title" value="{{ old('title') }}" autocomplete="title" autofocus>
+                                         @error('title')
+                                                <span class="invalid-feedback" role="alert">
+                                                    <strong>{{ $message }}</strong>
+                                                </span>
+                                        @enderror
+                                    </div>
+
+                                    <div class="form-row">
+                                        <div class="form-group col-lg-4">
+                                            <label for="slug">{{ __('product.slug') }}</label>
+                                            <input type="text" name="slug" class="form-control @error('slug') is-invalid  @enderror" value="{{old('slug')}}" autocomplete="slug" autofocus>
+                                            @error('slug')
+                                                <div class="alert alert-danger">{{$message}}</div>
+                                            @enderror
+                                        </div>
+                                        <div class="form-group col-lg-4">
+                                            <label for="sku">{{ __('product.sku') }}</label>
+                                            <input id="sku" type="text" class="form-control @error('sku') is-invalid @enderror" name="sku"
+                                                   autocomplete="sku" value="{{ old('sku') }}" autofocus>
+                                            @error('sku')
+                                                <span class="invalid-feedback" role="alert">
+                                                     <strong>{{ $message }}</strong>
+                                                 </span>
+                                            @enderror
+                                        </div>
+                                        <div class="form-group col-lg-4">
+                                            <label for="type">{{ __('product.type') }}</label></label><i class="required"> *</i>
+                                            <select id="type" type="text" class="form-control @error('type') is-invalid @enderror" name="type" value="{{ old('type') }}" autocomplete="type">
+                                                <option value="">انتخاب کنید</option>
+                                                <option value="0" {{ (old('type') == '0') ? 'selected' : '' }}>ساده</option>
+                                                <option value="1" {{ (old('type') == '1') ? 'selected' : '' }}>متغیر</option>
+                                                <option value="2" {{ (old('type') == '2') ? 'selected' : '' }}>باندل</option>
+                                            </select>
+                                            @error('type')
+                                                <span class="invalid-feedback" role="alert">
+                                                    <strong>{{ $message }}</strong>
+                                                </span>
+                                            @enderror
+                                        </div>
+                                    </div>
+
+                                        <div class="form-group col-lg-4">
+                                            <label for="status">{{ __('product.ReleaseStatus') }}</label><i class="required">&nbsp; *</i>
+                                            <select id="ReleaseStatus" type="text" class="form-control @error('ReleaseStatus') is-invalid @enderror" name="ReleaseStatus"  value="{{ old('ReleaseStatus') }}" autocomplete="ReleaseStatus">
+
+                                                <option value="draft" {{ (old('ReleaseStatus') == 'draft') ? 'selected' : '' }}>پیشنویس</option>
+                                                <option value="pending" {{ (old('ReleaseStatus') == 'pending') ? 'selected' : '' }}>در انتظار انتشار</option>
+                                                <option value="published" {{ (old('ReleaseStatus') == 'published') ? 'selected' : '' }}>منتشر شده</option>
+                                            </select>
+                                            @error('ReleaseStatus')
+                                                 <span class="invalid-feedback" role="alert">
+                                                         <strong>{{ $message }}</strong>
+                                                 </span>
+                                            @enderror
+                                        </div>
+
+                                    <div class="form-group">
+                                        <label for="discription">{{ __('product.discription') }}</label></label><i class="required">&nbsp;*</i>
+                                        <textarea id="discription" type="text"class="form-control editor @error('discription') is-invalid @enderror" name="discription" autocomplete="discription" autofocus>
+                                            {{ old('discription') }}
+                                        </textarea>
+
+                                        @error('discription')
+                                            <span class="invalid-feedback" role="alert">
+                                                 <strong>{{ $message }}</strong>
+                                             </span>
+                                        @enderror
+                                    </div>
+                                    <div class="form-group mb-0">
+                                        <div class="">
+                                            <button type="submit" class="btn btn-primary" >
+                                                {{ __('ثبت محصول') }}
+                                            </button>
+                                            <a href="{{ route('products.index') }}" type="button" class="btn btn-warning" > انصراف</a>
+                                        </div>
+                                    </div>
+                                    </div>
+                                </form>
+                            </div>
+                            <div class="card-footer">
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    @endslot
+
+    @slot('script')
+
+    @endslot
+
+@endcomponent
+

+ 3 - 100
packages/product/src/views/product/create.blade.php

@@ -25,7 +25,6 @@
                             <div class="card-body mx-lg-5 px-lg-3">
                                 <form method="POST" action="{{ route('products.store') }}" enctype="multipart/form-data" >
                                     @csrf
-                                    <input type="hidden" name="draft_id" value="{{ $draft->id }}">
                                     <div class="form-group">
                                          <label for="title">{{ __('product.title') }}</label><i class="required">&nbsp; *</i>
                                          <input id="title" type="text" class="form-control @error('title') is-invalid @enderror" name="title" value="{{ old('title') }}" autocomplete="title" autofocus>
@@ -69,42 +68,11 @@
                                             @enderror
                                         </div>
                                     </div>
-                                    <div class="form-row ">
-                                        <div class="form-group col-lg-4">
-                                            <label for="title">{{ __('product.price') }}</label><i class="required">&nbsp;*</i>
-                                            <input id="input.price" type="text" class="form-control price @error('price') is-invalid @enderror" name="price" value="{{ old('price') }}" autocomplete="price" autofocus>
-                                            @error('price')
-                                                <span class="invalid-feedback" role="alert">
-                                                    <strong>{{ $message }}</strong>
-                                                </span>
-                                            @enderror
-                                        </div>
-                                        <div class="form-group col-lg-4">
-                                            <label for="sale_price">@lang('product.sale_price')</label>
-                                            <input id="sale_price" type="text" class="form-control price @error('sale_price') is-invalid @enderror" name="sale_price" value="{{ old('sale_price') }}" autocomplete="sale_price" autofocus>
-                                            @error('sale_price')
-                                                 <span class="invalid-feedback" role="alert">
-                                                     <strong>{{ $message }}</strong>
-                                                 </span>
-                                            @enderror
-                                        </div>
-                                        <div class="form-group col-lg-4">
-                                            <label for="status">{{ __('product.status') }}</label><i class="required">&nbsp;*</i>
-                                            <select id="status" type="text" class="form-control  @error('status') is-invalid @enderror" name="status" autocomplete="status">
-                                                <option value="">انتخاب کنید</option>
-                                                <option value="1" {{ (old('status') == '1') ? 'selected' : '' }}>موجود</option>
-                                                <option value="0" {{ (old('status') == '0') ? 'selected' : '' }}>ناموجود</option>
-                                            </select>
-                                            @error('status')
-                                                <span class="invalid-feedback" role="alert">
-                                                    <strong>{{ $message }}</strong>
-                                                </span>
-                                            @enderror
-                                        </div>
+
                                         <div class="form-group col-lg-4">
                                             <label for="status">{{ __('product.ReleaseStatus') }}</label><i class="required">&nbsp; *</i>
                                             <select id="ReleaseStatus" type="text" class="form-control @error('ReleaseStatus') is-invalid @enderror" name="ReleaseStatus"  value="{{ old('ReleaseStatus') }}" autocomplete="ReleaseStatus">
-{{--                                                <option value="">انتخاب کنید</option>--}}
+
                                                 <option value="draft" {{ (old('ReleaseStatus') == 'draft') ? 'selected' : '' }}>پیشنویس</option>
                                                 <option value="pending" {{ (old('ReleaseStatus') == 'pending') ? 'selected' : '' }}>در انتظار انتشار</option>
                                                 <option value="published" {{ (old('ReleaseStatus') == 'published') ? 'selected' : '' }}>منتشر شده</option>
@@ -115,7 +83,7 @@
                                                  </span>
                                             @enderror
                                         </div>
-                                    </div>
+
                                     <div class="form-group">
                                         <label for="discription">{{ __('product.discription') }}</label></label><i class="required">&nbsp;*</i>
                                         <textarea id="discription" type="text"class="form-control editor @error('discription') is-invalid @enderror" name="discription" autocomplete="discription" autofocus>
@@ -128,71 +96,6 @@
                                              </span>
                                         @enderror
                                     </div>
-                                    <div class="form-group">
-                                        <label for="categories">{{ __('product.categories') }}</label><i class="required">&nbsp;*</i>
-                                        <select name="categories[]" class="form-control select2 @error('categories[]') is-invalid @enderror" multiple>
-                                            <option value="0">--</option>
-                                            {!! category_select_options( $categories, old( 'categories[]' ) ) !!}
-                                        </select>
-                                        @error('categories')
-                                            <span class="invalid-feedback" role="alert">
-                                                 <strong>{{ $message }}</strong>
-                                             </span>
-                                        @enderror
-                                    </div>
-                                    <div class="">
-                                    <div class="form-group col-md-8 ">
-                                        <div class="attachment_upload">
-
-
-                                        <span class="btn btn-primary btn-file " >
-                                            <input type="file" id="uploadImages" name="featured_image" accept="image/*" class="form-control photo  browse  @error('featured_image') is-invalid  @enderror"  value="{{old('featured_image')}}" autocomplete="featured_image" autofocus>
-                                            <label for="title">{{ __('product.featured_image') }}</label> <i class="required">&nbsp;*</i>
-                                        </span>
-                                        <div class="hide-element" id="previewImages">
-                                            <div class="media">
-                                                <div class="media-left ">
-                                                    <a href="" role="button" class="btn btn-danger pull-right" id="delete">
-                                                        <i class="icon fa fa-close"></i>
-                                                    </a>
-                                                    <img class="media-object img-thumbnail" src="" alt="" id="0" title="" data-toggle="modal" data-target="#individualImagePreview" style="width: 250px; height: 150px;" >
-                                                </div>
-                                                <div class="media-body">
-                                                    <p>
-                                                        <label for="featureDescription">توضیحات: </label>
-                                                        <input type="text" class="form-control"  value="" name="featureDescription" id="featureDescription">
-                                                    </p>
-                                                    <p>
-                                                        <label for="featureCaption">عنوان: </label>
-                                                        <input type="text" class="form-control" value="" name="featureCaption" id="featureCaption">
-                                                    </p>
-                                                </div>
-                                            </div>
-                                            </div>
-                                        </div>
-                                        @error('featured_image')
-                                            <span class="invalid-feedback" role="alert">
-                                                 <strong>{{ $message }}</strong>
-                                            </span>
-                                        @enderror
-                                    </div>
-
-                                    <div class="form-row attachment_upload_gallery">
-                                        <div class="upload-widget GalleryImageChoice  ">
-                                            <div class="select ">
-                                                <span class="btn btn-primary btn-file">
-                                                    <input class="files attachment_upload_gallery" type="file" name="gallery_image[]" value="{{old('gallery_image[]')}}" multiple>
-                                                    <label for="title">
-                                                         {{ __('product.gallery_image') }}
-                                                    </label>
-                                                </span>
-                                                <output class="list row " >
-                                                </output>
-                                            </div>
-                                            <div class="dropZone col-3">
-                                            </div>
-                                        </div>
-                                    </div>
                                     <div class="form-group mb-0">
                                         <div class="">
                                             <button type="submit" class="btn btn-primary" >

+ 221 - 0
packages/product/src/views/product/createCopy.blade.php

@@ -0,0 +1,221 @@
+@component('panel.layouts.component', ['title' => 'ثبت محصول جدید'])
+
+    @slot('style')
+
+    @endslot
+    @slot('subject')
+        <h1><i class="fa fa-users"></i> ثبت محصول جدید </h1>
+        <p>ثبت محصول جدید در فروشگاه.</p>
+    @endslot
+    @slot('breadcrumb')
+        <li class="breadcrumb-item">محصولات</li>
+    @endslot
+
+    @slot('content')
+        <div class="auth-background h-auto py-5">
+            <div class="container py-5">
+                <div class="row align-items-center ">
+                    <div class="col-lg-12 col-md-12 mx-auto">
+                        <div class="card">
+                            <div class="card-header">
+                                <strong>{{ __('ثبت محصول جدید') }}</strong>
+                            </div>
+                            @component('product::components.message')
+                            @endcomponent
+                            <div class="card-body mx-lg-5 px-lg-3">
+                                <form method="POST" action="{{ route('products.store') }}" enctype="multipart/form-data" >
+                                    @csrf
+                                    <input type="hidden" name="draft_id" value="{{ $draft->id }}">
+                                    <div class="form-group">
+                                         <label for="title">{{ __('product.title') }}</label><i class="required">&nbsp; *</i>
+                                         <input id="title" type="text" class="form-control @error('title') is-invalid @enderror" name="title" value="{{ old('title') }}" autocomplete="title" autofocus>
+                                         @error('title')
+                                                <span class="invalid-feedback" role="alert">
+                                                    <strong>{{ $message }}</strong>
+                                                </span>
+                                        @enderror
+                                    </div>
+
+                                    <div class="form-row">
+                                        <div class="form-group col-lg-4">
+                                            <label for="slug">{{ __('product.slug') }}</label>
+                                            <input type="text" name="slug" class="form-control @error('slug') is-invalid  @enderror" value="{{old('slug')}}" autocomplete="slug" autofocus>
+                                            @error('slug')
+                                                <div class="alert alert-danger">{{$message}}</div>
+                                            @enderror
+                                        </div>
+                                        <div class="form-group col-lg-4">
+                                            <label for="sku">{{ __('product.sku') }}</label>
+                                            <input id="sku" type="text" class="form-control @error('sku') is-invalid @enderror" name="sku"
+                                                   autocomplete="sku" value="{{ old('sku') }}" autofocus>
+                                            @error('sku')
+                                                <span class="invalid-feedback" role="alert">
+                                                     <strong>{{ $message }}</strong>
+                                                 </span>
+                                            @enderror
+                                        </div>
+                                        <div class="form-group col-lg-4">
+                                            <label for="type">{{ __('product.type') }}</label></label><i class="required"> *</i>
+                                            <select id="type" type="text" class="form-control @error('type') is-invalid @enderror" name="type" value="{{ old('type') }}" autocomplete="type">
+                                                <option value="">انتخاب کنید</option>
+                                                <option value="0" {{ (old('type') == '0') ? 'selected' : '' }}>ساده</option>
+                                                <option value="1" {{ (old('type') == '1') ? 'selected' : '' }}>متغیر</option>
+                                                <option value="2" {{ (old('type') == '2') ? 'selected' : '' }}>باندل</option>
+                                            </select>
+                                            @error('type')
+                                                <span class="invalid-feedback" role="alert">
+                                                    <strong>{{ $message }}</strong>
+                                                </span>
+                                            @enderror
+                                        </div>
+                                    </div>
+                                    <div class="form-row ">
+                                        <div class="form-group col-lg-4">
+                                            <label for="title">{{ __('product.price') }}</label><i class="required">&nbsp;*</i>
+                                            <input id="input.price" type="text" class="form-control price @error('price') is-invalid @enderror" name="price" value="{{ old('price') }}" autocomplete="price" autofocus>
+                                            @error('price')
+                                                <span class="invalid-feedback" role="alert">
+                                                    <strong>{{ $message }}</strong>
+                                                </span>
+                                            @enderror
+                                        </div>
+                                        <div class="form-group col-lg-4">
+                                            <label for="sale_price">@lang('product.sale_price')</label>
+                                            <input id="sale_price" type="text" class="form-control price @error('sale_price') is-invalid @enderror" name="sale_price" value="{{ old('sale_price') }}" autocomplete="sale_price" autofocus>
+                                            @error('sale_price')
+                                                 <span class="invalid-feedback" role="alert">
+                                                     <strong>{{ $message }}</strong>
+                                                 </span>
+                                            @enderror
+                                        </div>
+                                        <div class="form-group col-lg-4">
+                                            <label for="status">{{ __('product.status') }}</label><i class="required">&nbsp;*</i>
+                                            <select id="status" type="text" class="form-control  @error('status') is-invalid @enderror" name="status" autocomplete="status">
+                                                <option value="">انتخاب کنید</option>
+                                                <option value="1" {{ (old('status') == '1') ? 'selected' : '' }}>موجود</option>
+                                                <option value="0" {{ (old('status') == '0') ? 'selected' : '' }}>ناموجود</option>
+                                            </select>
+                                            @error('status')
+                                                <span class="invalid-feedback" role="alert">
+                                                    <strong>{{ $message }}</strong>
+                                                </span>
+                                            @enderror
+                                        </div>
+                                        <div class="form-group col-lg-4">
+                                            <label for="status">{{ __('product.ReleaseStatus') }}</label><i class="required">&nbsp; *</i>
+                                            <select id="ReleaseStatus" type="text" class="form-control @error('ReleaseStatus') is-invalid @enderror" name="ReleaseStatus"  value="{{ old('ReleaseStatus') }}" autocomplete="ReleaseStatus">
+{{--                                                <option value="">انتخاب کنید</option>--}}
+                                                <option value="draft" {{ (old('ReleaseStatus') == 'draft') ? 'selected' : '' }}>پیشنویس</option>
+                                                <option value="pending" {{ (old('ReleaseStatus') == 'pending') ? 'selected' : '' }}>در انتظار انتشار</option>
+                                                <option value="published" {{ (old('ReleaseStatus') == 'published') ? 'selected' : '' }}>منتشر شده</option>
+                                            </select>
+                                            @error('ReleaseStatus')
+                                                 <span class="invalid-feedback" role="alert">
+                                                         <strong>{{ $message }}</strong>
+                                                 </span>
+                                            @enderror
+                                        </div>
+                                    </div>
+                                    <div class="form-group">
+                                        <label for="discription">{{ __('product.discription') }}</label></label><i class="required">&nbsp;*</i>
+                                        <textarea id="discription" type="text"class="form-control editor @error('discription') is-invalid @enderror" name="discription" autocomplete="discription" autofocus>
+                                            {{ old('discription') }}
+                                        </textarea>
+
+                                        @error('discription')
+                                            <span class="invalid-feedback" role="alert">
+                                                 <strong>{{ $message }}</strong>
+                                             </span>
+                                        @enderror
+                                    </div>
+                                    <div class="form-group">
+                                        <label for="categories">{{ __('product.categories') }}</label><i class="required">&nbsp;*</i>
+                                        <select name="categories[]" class="form-control select2 @error('categories[]') is-invalid @enderror" multiple>
+                                            <option value="0">--</option>
+                                            {!! category_select_options( $categories, old( 'categories[]' ) ) !!}
+                                        </select>
+                                        @error('categories')
+                                            <span class="invalid-feedback" role="alert">
+                                                 <strong>{{ $message }}</strong>
+                                             </span>
+                                        @enderror
+                                    </div>
+                                    <div class="">
+                                    <div class="form-group col-md-8 ">
+                                        <div class="attachment_upload">
+
+
+                                        <span class="btn btn-primary btn-file " >
+                                            <input type="file" id="uploadImages" name="featured_image" accept="image/*" class="form-control photo  browse  @error('featured_image') is-invalid  @enderror"  value="{{old('featured_image')}}" autocomplete="featured_image" autofocus>
+                                            <label for="title">{{ __('product.featured_image') }}</label> <i class="required">&nbsp;*</i>
+                                        </span>
+                                        <div class="hide-element" id="previewImages">
+                                            <div class="media">
+                                                <div class="media-left ">
+                                                    <a href="" role="button" class="btn btn-danger pull-right" id="delete">
+                                                        <i class="icon fa fa-close"></i>
+                                                    </a>
+                                                    <img class="media-object img-thumbnail" src="" alt="" id="0" title="" data-toggle="modal" data-target="#individualImagePreview" style="width: 250px; height: 150px;" >
+                                                </div>
+                                                <div class="media-body">
+                                                    <p>
+                                                        <label for="featureDescription">توضیحات: </label>
+                                                        <input type="text" class="form-control"  value="" name="featureDescription" id="featureDescription">
+                                                    </p>
+                                                    <p>
+                                                        <label for="featureCaption">عنوان: </label>
+                                                        <input type="text" class="form-control" value="" name="featureCaption" id="featureCaption">
+                                                    </p>
+                                                </div>
+                                            </div>
+                                            </div>
+                                        </div>
+                                        @error('featured_image')
+                                            <span class="invalid-feedback" role="alert">
+                                                 <strong>{{ $message }}</strong>
+                                            </span>
+                                        @enderror
+                                    </div>
+
+                                    <div class="form-row attachment_upload_gallery">
+                                        <div class="upload-widget GalleryImageChoice  ">
+                                            <div class="select ">
+                                                <span class="btn btn-primary btn-file">
+                                                    <input class="files attachment_upload_gallery" type="file" name="gallery_image[]" value="{{old('gallery_image[]')}}" multiple>
+                                                    <label for="title">
+                                                         {{ __('product.gallery_image') }}
+                                                    </label>
+                                                </span>
+                                                <output class="list row " >
+                                                </output>
+                                            </div>
+                                            <div class="dropZone col-3">
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="form-group mb-0">
+                                        <div class="">
+                                            <button type="submit" class="btn btn-primary" >
+                                                {{ __('ثبت محصول') }}
+                                            </button>
+                                            <a href="{{ route('products.index') }}" type="button" class="btn btn-warning" > انصراف</a>
+                                        </div>
+                                    </div>
+                                    </div>
+                                </form>
+                            </div>
+                            <div class="card-footer">
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    @endslot
+
+    @slot('script')
+
+    @endslot
+
+@endcomponent
+