|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace Packages\Product\Http\Controllers;
|
|
|
|
|
|
+use Carbon\Carbon;
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
use App\Http\Controllers\Controller;
|
|
|
use Facade\Ignition\Support\Packagist\Package;
|
|
@@ -18,6 +19,7 @@ use Packages\Product\Models\Product;
|
|
|
use Illuminate\Http\Request;
|
|
|
use App\Models\Category;
|
|
|
use App\Models\Upload;
|
|
|
+use Packages\Product\Models\Temp;
|
|
|
use phpDocumentor\Reflection\Types\Compound;
|
|
|
|
|
|
class ProductController extends Controller
|
|
@@ -52,7 +54,7 @@ class ProductController extends Controller
|
|
|
//**************************************************** page create products *****************
|
|
|
public function create(Request $request)
|
|
|
{
|
|
|
- return view('product::product.create',compact('attributes'));
|
|
|
+ return view('product::product.create');
|
|
|
}
|
|
|
// *********************************************************save products ******************
|
|
|
public function store(ProductRequest $request)
|
|
@@ -219,19 +221,34 @@ class ProductController extends Controller
|
|
|
|
|
|
public function uploadValAttribute(Request $request)
|
|
|
{
|
|
|
- $attributes = Attribute::orderBy('id')->where('use_in_veriation', 1)->get();
|
|
|
- $product = Product::where('id')->get();
|
|
|
-//dd($request);
|
|
|
-
|
|
|
- $data = [
|
|
|
- 'val_attribute' => $request->val_attribute,
|
|
|
- 'attribute_id' => $attributes->id,
|
|
|
- 'attributable_id' => $product->id,
|
|
|
- 'attributable_type' => 'products',
|
|
|
-
|
|
|
- ];
|
|
|
- $uploaded = $product->attributes()->save($data);
|
|
|
- return redirect(route('productStepVariable'));
|
|
|
+// $attributes = Attribute::orderBy('id')->where('use_in_veriation', 1)->get();
|
|
|
+ $productID = $request->productID;
|
|
|
+ $product = Product::where('id', $productID)->first();
|
|
|
+ $info = json_decode($request->info);
|
|
|
+ $type = json_decode($request->type);
|
|
|
+ $attributables = $product->attributes()->where($info,'val_attribute');
|
|
|
+// dd($attributables);
|
|
|
+ dd($type);
|
|
|
+ if (($attributables)){
|
|
|
+ foreach ($info as $item){
|
|
|
+ $data = [
|
|
|
+ 'val_attribute' => $item,
|
|
|
+ 'attribute_id' => $type,
|
|
|
+ 'attributable_id' => $productID,
|
|
|
+ 'attributable_type' => 'products',
|
|
|
+ 'created_at' => Carbon::now(),
|
|
|
+ 'updated_at' => Carbon::now(),
|
|
|
+ ];
|
|
|
+
|
|
|
+ \DB::table('attributables')->insert($data);
|
|
|
+ }
|
|
|
+ $operate['status'] = 200;
|
|
|
+ $operate['msg'] = 'با موفقیت ذخیره شد !';
|
|
|
+ }else{
|
|
|
+ $operate['status'] = 500;
|
|
|
+ $operate['msg'] = 'اطلاعات قبلا ذخیره شده';
|
|
|
+ }
|
|
|
+ return $operate;
|
|
|
}
|
|
|
|
|
|
}
|