Browse Source

Record simple to variable

Azam Rezayi 4 years ago
parent
commit
b60dff78be

+ 61 - 7
packages/product/src/Http/Controllers/ProductController.php

@@ -65,20 +65,74 @@ class ProductController extends Controller
             'creator_id' => auth()->user()->id,
         ];
         $product = Product::create($data);
-        if ( 'type'== 0){
+        $view = 'create';
+        if ('type' == 0){
+            $view = 'saveProductStepTwo';
+        }elseif ('type' == 1){
+            $view = 'productStepVariable';
+        }elseif ('type' == 2){
+            $view = 'saveProductStepTwoTS';
+        }
+        return redirect()->route($view, $product->id);
+    }
+    public function productStepTwo($id)
+    {
+        $product = $this->productChecker($id);
+        if ($product != false){
+            $msg = 'ذخیره محصول با موفقیت انجام شد ';
+            return view('product::product.simpleProduct', compact('product'))->with('success', $msg);
+        }else{
+            return abort(419);
+        }
+    }
+
+    public function productStepVariable($id)
+    {
+        $product = $this->productChecker($id);
+        if ($product != false){
             $msg = 'ذخیره محصول با موفقیت انجام شد ';
-            return view('product::product.simpleProduct')->with('success', $msg);
-//            return view('product::product.SimpleProduct', $product->id)->with('success', $msg);
+            return view('product::product.variableProduct', compact('product'))->with('success', $msg);
+        }else{
+            return abort(419);
+        }
+    }
+
+    public function productStepThree(Request $request)
+    {
+//        dd($request->all());
+        $product = $this->productChecker($request->product_id);
+        if ($product != false){
+            $request->validate([
+                'sku' => 'required',
+                'status' => 'required',
+                'price' => 'required',
+                'sale_price' => 'required',
+            ]);
+            /**
+             * update product
+             */
             $data = [
-                'status' => $request->status,
                 'sku' => $request->sku,
+                'status' => $request->status,
                 'price' => $request->price,
                 'sale_price' => $request->sale_price,
             ];
-            $product = Product::update($data);
+            $product->update($data);
+            $msg = 'ذخیره محصول با موفقیت انجام شد ';
+            return redirect(route('products.index'))->with('success', $msg);
+        }else{
+            return abort(419);
+        }
+    }
+
+    public function productChecker($id)
+    {
+        $product = Product::where('id', $id)->where('creator_id', Auth::user()->id)->first();
+        if (!empty($product)){
+            return $product;
+        }else{
+            return false;
         }
-        $msg = 'ذخیره محصول با موفقیت انجام شد ';
-        return redirect(route('products.index', $product->id))->with('success', $msg);
     }
     // ******************************************************edit page product*********************************************
     public function edit(Product $product)

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

@@ -23,12 +23,17 @@ class ProductRequest extends FormRequest
      */
     public function rules()
     {
+//        dd(request()->all());
         return [
             'title' => ['required','max:100'],
             'slug' => ['unique:products'],
             'type' => ['required'],
-           'ReleaseStatus' => ['required'],
             'discription' => ['required'],
+
+            'sale_price' => ['nullable'],
+            'sku' => ['nullable'],
+            'status' => ['nullable'],
+            'ReleaseStatus' => ['required'],
         ];
 
     }

+ 7 - 0
packages/product/src/routes/web.php

@@ -5,6 +5,13 @@ Route::group([
     'prefix' => 'panel'
 ], function () {
     Route::resource('products', 'ProductController');
+    Route::get('product/simple-product/{id}', 'ProductController@productStepTwo')->name('saveProductStepTwo');
+    Route::post('product/simple/update', 'ProductController@productStepThree')->name('saveProductStepThree');
+
+    Route::get('product/product-variable/{id}', 'ProductController@productStepVariable')->name('productStepVariable');
+
+
+//upload*****************************
     Route::get('uploads/{upload}', 'ProductController@destroyFile')->name('uploads.destroyFile');
     Route::post('product_uploads/FeaturedImage', 'ProductController@uploadFeature')->name('FeaturedImage');
     Route::post('product_uploads/GalleryImage', 'ProductController@uploadGallery')->name('GalleryImage');

+ 132 - 0
packages/product/src/views/attributes/createggg.blade.php

@@ -0,0 +1,132 @@
+<!doctype html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport"
+          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
+    <meta http-equiv="X-UA-Compatible" content="ie=edge">
+    <title>Document</title>
+</head>
+<body>
+<div></div>
+<header></header>
+<footer></footer>
+<button></button>
+<h1 class="class1"></h1>
+<button class="btn btn-primary"></button>
+<div class="hfgt"></div>
+<div class="class1 class2"></div>
+<div id="id"></div>
+<h1>salam</h1>
+<h1 class="red">hi</h1>
+<div>
+    <ul>
+        <li></li>
+    </ul>
+</div>
+<div>
+    <ul>
+        <li>hi</li>
+    </ul>
+</div>
+<div>
+    <ul>
+        <li>hi</li>
+        <li>hi</li>
+        <li>hi</li>
+        <li>hi</li>
+        <li>hi</li>
+    </ul>
+</div>
+<div>
+    <ul>
+        <li>hi</li>
+        <li>hi</li>
+        <li>hi</li>
+        <li>hi</li>
+        <li>hi</li>
+    </ul>
+</div>
+<div>
+    <ul>
+        <li class="f">f</li>
+        <li class="f">f</li>
+        <li class="f">f</li>
+        <li class="f">f</li>
+        <li class="f">f</li>
+    </ul>
+</div>
+<div></div>
+<ul></ul>
+<li></li>
+<h1 class="gh"></h1>
+<p class="btn"></p>
+<div>
+    <header>
+        <ul>
+            <li></li>
+            <li></li>
+            <li></li>
+            <li></li>
+            <li></li>
+        </ul>
+    </header>
+    <footer>
+        <p>hi</p>
+    </footer>
+    <form action="" method="get"></form>
+    <form action="" method="post"></form>
+    <labale></labale>
+    <input type="text">
+    <input type="text" name="" id="">
+    <input type="email" name="" id="">
+    <input type="submit" value="">
+    <select name="" id=""></select>
+    <select name="" id="">
+        <option value=""></option>
+    </select>
+    <table>
+        <tr>
+            <td></td>
+        </tr>
+    </table>
+    <ol>
+        <li></li>
+    </ol>
+    <div>
+        <ul>
+            <li></li>
+        </ul>
+    </div>
+    <!doctype html>
+    <html lang="en">
+    <head>
+        <meta charset="UTF-8">
+        <meta name="viewport"
+              content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
+        <meta http-equiv="X-UA-Compatible" content="ie=edge">
+        <title>Document</title>
+    </head>
+    <body>
+
+    </body>
+    </html>
+    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ab assumenda commodi culpa delectus dicta distinctio dolores et fugiat, id inventore iure maxime modi neque, non obcaecati quidem quos repellat, sunt.
+    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti, quis!
+    <ul class="bv">
+        <li class="tr">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi, velit!</li>
+        <li class="tr">Aliquid at ea eaque eos, est explicabo quae quisquam veritatis.</li>
+        <li class="tr">Architecto autem excepturi expedita ipsum itaque quae, quas rerum vitae.</li>
+        <li class="tr">Dolore eaque iste laborum magni nam obcaecati reprehenderit tempora voluptate.</li>
+        <li class="tr">Alias autem blanditiis doloribus eos necessitatibus officia placeat sunt ut?</li>
+    </ul>
+    <div>
+        <ul>
+            <li></li>
+        </ul>
+    </div>
+</div>
+
+
+</body>
+</html>

+ 1 - 0
packages/product/src/views/product/create.blade.php

@@ -86,6 +86,7 @@
                                     </div>
                                     <div class="form-group mb-0">
                                         <div class="">
+
                                             <button type="submit" class="btn btn-primary" >
                                                 {{ __('ثبت محصول') }}
                                             </button>

+ 8 - 7
packages/product/src/views/product/simpleProduct.blade.php

@@ -18,18 +18,19 @@
                     <div class="col-lg-12 col-md-12 mx-auto">
                         <div class="card">
                             <div class="card-header">
-                                <strong>{{ __('ثبت محصول ساده') }}</strong>
+                                <strong>{{ __('ثبت محصول ساده') }}-{{$product->id}}</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" >
+                                <form method="POST" action="{{ route('saveProductStepThree') }}" enctype="multipart/form-data" >
                                     @csrf
                                     <div class="form-row ">
+                                        <input type="hidden" value="{{$product->id}}" name="product_id">
                                     <div class="form-group col-lg-3">
                                         <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>
+                                               autocomplete="sku" value="{{$product->sku}}" autofocus>
                                         @error('sku')
                                         <span class="invalid-feedback" role="alert">
                                                      <strong>{{ $message }}</strong>
@@ -40,8 +41,8 @@
                                         <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>
+                                            <option value="0" {{ (old('status') == '1') ? 'selected' : '' }}>ناموجود</option>
+                                            <option value="1" @if ($product->status === 'موجود')  selected='selected'@endif>موجود</option>
                                         </select>
                                         @error('status')
                                         <span class="invalid-feedback" role="alert">
@@ -51,7 +52,7 @@
                                     </div>
                                         <div class="form-group col-lg-3">
                                             <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>
+                                            <input id="input.price" type="text" class="form-control price @error('price') is-invalid @enderror" name="price" value="{{$product->price}}" autocomplete="price" autofocus>
                                             @error('price')
                                             <span class="invalid-feedback" role="alert">
                                                     <strong>{{ $message }}</strong>
@@ -60,7 +61,7 @@
                                         </div>
                                         <div class="form-group col-lg-3">
                                             <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>
+                                            <input id="sale_price" type="text" class="form-control price @error('sale_price') is-invalid @enderror" name="sale_price" value="{{$product->sale_price}}" autocomplete="sale_price" autofocus>
                                             @error('sale_price')
                                             <span class="invalid-feedback" role="alert">
                                                      <strong>{{ $message }}</strong>

+ 2 - 2
packages/product/src/views/product/variableProduct.blade.php

@@ -14,12 +14,12 @@
         <div class="col-lg-12 col-md-12 mx-auto">
             <div class="card">
                 <div class="card-header">
-                    <strong>{{ __('ثبت محصول متغییر') }}</strong>
+                    <strong>{{ __('ثبت محصول متغییر') }}</strong><i class="required">{{$product->id}}</i>
                 </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" >
+                    <form method="POST" action="{{ route('products.store',$product->id) }}" enctype="multipart/form-data" >
                         @csrf
                         <div class="form-row ">
                             <div class="form-group col-lg-7">