|
@@ -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)
|