|
@@ -52,7 +52,7 @@ class ProductController extends Controller
|
|
|
//**************************************************** page create products *****************
|
|
|
public function create(Request $request)
|
|
|
{
|
|
|
- return view('product::product.create');
|
|
|
+ return view('product::product.create',compact('attributes'));
|
|
|
}
|
|
|
// *********************************************************save products ******************
|
|
|
public function store(ProductRequest $request)
|
|
@@ -205,72 +205,6 @@ class ProductController extends Controller
|
|
|
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)
|
|
@@ -282,70 +216,22 @@ class ProductController extends Controller
|
|
|
}
|
|
|
|
|
|
// ****************************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);
|
|
|
+ public function uploadValAttribute(Request $request)
|
|
|
+ {
|
|
|
+ $attributes = Attribute::orderBy('id')->where('use_in_veriation', 1)->get();
|
|
|
+ $product = Product::where('id')->get();
|
|
|
+//dd($request);
|
|
|
|
|
|
- if (File::exists($filePath)) {
|
|
|
- $fileName = time() . '_' . $fileName;
|
|
|
- }
|
|
|
- $draft = Draft::orderBy('id', 'Desc')->get()->first();
|
|
|
- $upload = $file->storeAs($afterDiskRoot, $fileName, $diskName);
|
|
|
+ $data = [
|
|
|
+ 'val_attribute' => $request->val_attribute,
|
|
|
+ 'attribute_id' => $attributes->id,
|
|
|
+ 'attributable_id' => $product->id,
|
|
|
+ 'attributable_type' => 'products',
|
|
|
|
|
|
- $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);
|
|
|
-
|
|
|
+ $uploaded = $product->attributes()->save($data);
|
|
|
+ return redirect(route('productStepVariable'));
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- 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);
|
|
|
- }
|
|
|
- }
|
|
|
}
|