Skip to content

Commit

Permalink
push the work of product page connect to database
Browse files Browse the repository at this point in the history
Vishal-sarkar committed Sep 28, 2022
1 parent 430d427 commit bace17e
Showing 17 changed files with 137 additions and 24 deletions.
63 changes: 62 additions & 1 deletion app/Http/Controllers/Backend/ProductController.php
Original file line number Diff line number Diff line change
@@ -9,6 +9,9 @@
use App\Models\SubSubCategory;
use App\Models\Brand;
use App\Models\Product;
use App\Models\Multiimg;
use Carbon\Carbon;
use Image;

class ProductController extends Controller
{
@@ -17,4 +20,62 @@ public function AddProduct(){
$brands = Brand::latest()->get();
return view('backend.product.product_add', compact('categories', 'brands'));
}
}

public function StoreProduct(Request $request){
$image = $request->file('product_thambnail');
$name_gen = hexdec(uniqid()).'.'.$image->getClientOriginalExtension();
Image::make($image)->resize(917,1000)->save('upload/products/thambnail/'.$name_gen);
$save_url = 'upload/brand/products/thambnail/'.$name_gen;
$product_id = Product::insertGetId([
'brand_id' => $request->brand_id,
'category_id' => $request->category_id,
'subcategory_id' => $request->subcategory_id,
'subsubcategory_id' => $request->subsubcategory_id,
'product_name_en' => $request->product_name_en,
'product_name_hin' => $request->product_name_hin,
'product_slug_en' => strtolower(str_replace(' ','-',$request->product_name_en)),
'product_slug_hin' => str_replace(' ','-',$request->product_name_hin),
'product_code' => $request->product_code,
'product_qty' => $request->product_qty,
'product_tags_en' => $request->product_tags_en,
'product_tags_hin' => $request->product_tags_hin,
'product_size_en' => $request->product_size_en,
'product_size_hin' => $request->product_size_hin,
'product_color_en' => $request->product_color_en,
'product_color_hin' => $request->product_color_hin,
'selling_price' => $request->selling_price,
'discount_price' => $request->discount_price,
'short_descp_en' => $request->short_descp_en,
'short_descp_hin' => $request->short_descp_hin,
'long_descp_en' => $request->long_descp_en,
'long_descp_hin' => $request->long_descp_hin,
'product_thambnail' => $save_url,
'hot_deals' => $request->hot_deals,
'featured' => $request->featured,
'special_offer' => $request->special_offer,
'special_deals' => $request->special_deals,
'status' => 1,
'created_at' => Carbon::now(),
]);

////////// Multi Image Upload Start ///////////
$images = $request->file('multi_img');
foreach($images as $img){
$make_name = hexdec(uniqid()).'.'.$img->getClientOriginalExtension();
Image::make($img)->resize(917,1000)->save('upload/products/multi-image/'.$make_name);
$uploadpath = 'upload/brand/products/multi-image/'.$make_name;

Multiimg::insert([
'product_id' => $product_id,
'photo_name' => $uploadpath,
'created_at' => Carbon::now(),
]);
}
$notification = array(
'message' => 'Product inserted successfully',
'alert-type' => 'success'
);
return redirect()->back()->with($notification);

}
}
Binary file added public/upload/brand/1745227537452118.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/upload/brand/1745227563227531.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/upload/brand/1745227618679009.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
95 changes: 72 additions & 23 deletions resources/views/backend/product/product_add.blade.php

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
@@ -101,4 +101,7 @@
// Admin Products All Routes
Route::prefix('product')->group(function(){
Route::get('/view', [ProductController::class, 'AddProduct'])->name('add-product');
Route::post('/store', [ProductController::class, 'StoreProduct'])->name('product.store');


});

0 comments on commit bace17e

Please sign in to comment.