@@ -14,33 +14,33 @@ |
||
| 14 | 14 | { |
| 15 | 15 | use HasFactory; |
| 16 | 16 | |
| 17 | - protected $dates = ["created_at","updated_at"]; |
|
| 17 | + protected $dates = ["created_at", "updated_at"]; |
|
| 18 | 18 | |
| 19 | - public function items(){ |
|
| 19 | + public function items() { |
|
| 20 | 20 | return $this->hasMany(ProductItem::class); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - public function category(){ |
|
| 23 | + public function category() { |
|
| 24 | 24 | return $this->belongsTo(Category::class); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public function details(){ |
|
| 28 | - return $this->hasManyThrough(ProductItemDetail::class,ProductItem::class); |
|
| 27 | + public function details() { |
|
| 28 | + return $this->hasManyThrough(ProductItemDetail::class, ProductItem::class); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public static function getPrice($product_item_id){ |
|
| 31 | + public static function getPrice($product_item_id) { |
|
| 32 | 32 | return ProductItem::find($product_item_id)->price; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - public static function getImage($product_item_id){ |
|
| 35 | + public static function getImage($product_item_id) { |
|
| 36 | 36 | return ProductItem::find($product_item_id)->image; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - public static function getDescription($product_item_id){ |
|
| 39 | + public static function getDescription($product_item_id) { |
|
| 40 | 40 | return ProductItem::find($product_item_id)->description; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - public static function getName($product_item_id){ |
|
| 43 | + public static function getName($product_item_id) { |
|
| 44 | 44 | return ProductItem::find($product_item_id)->name; |
| 45 | 45 | } |
| 46 | 46 | |
@@ -7,20 +7,20 @@ |
||
| 7 | 7 | |
| 8 | 8 | class ShopSingleProductController extends Controller |
| 9 | 9 | { |
| 10 | - public function page($id,$product_item_id = null){ |
|
| 11 | - $product = Product::find($id); |
|
| 12 | - if($product_item_id == null){ |
|
| 13 | - return redirect()->route('shop.single.product',[$product->id,$product->items->first()->id]); |
|
| 14 | - } |
|
| 10 | + public function page($id,$product_item_id = null){ |
|
| 11 | + $product = Product::find($id); |
|
| 12 | + if($product_item_id == null){ |
|
| 13 | + return redirect()->route('shop.single.product',[$product->id,$product->items->first()->id]); |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | - $details_fields = Template::getDetailsFields($product,$product_item_id); |
|
| 17 | - $configuration_fields = Template::getConfigurationFields($product_item_id); |
|
| 18 | - $btn_cart = Template::buttonCart($product_item_id); |
|
| 19 | - $price = Product::getPrice($product_item_id); |
|
| 20 | - $image = Product::getImage($product_item_id); |
|
| 21 | - $description = Product::getDescription($product_item_id); |
|
| 22 | - $name = Product::getName($product_item_id); |
|
| 16 | + $details_fields = Template::getDetailsFields($product,$product_item_id); |
|
| 17 | + $configuration_fields = Template::getConfigurationFields($product_item_id); |
|
| 18 | + $btn_cart = Template::buttonCart($product_item_id); |
|
| 19 | + $price = Product::getPrice($product_item_id); |
|
| 20 | + $image = Product::getImage($product_item_id); |
|
| 21 | + $description = Product::getDescription($product_item_id); |
|
| 22 | + $name = Product::getName($product_item_id); |
|
| 23 | 23 | |
| 24 | - return view('mongicommerce.pages.single-product',compact('product','details_fields','configuration_fields','btn_cart','price','image','description','name')); |
|
| 25 | - } |
|
| 24 | + return view('mongicommerce.pages.single-product',compact('product','details_fields','configuration_fields','btn_cart','price','image','description','name')); |
|
| 25 | + } |
|
| 26 | 26 | } |
@@ -7,13 +7,13 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | class ShopSingleProductController extends Controller |
| 9 | 9 | { |
| 10 | - public function page($id,$product_item_id = null){ |
|
| 10 | + public function page($id, $product_item_id = null) { |
|
| 11 | 11 | $product = Product::find($id); |
| 12 | - if($product_item_id == null){ |
|
| 13 | - return redirect()->route('shop.single.product',[$product->id,$product->items->first()->id]); |
|
| 12 | + if ($product_item_id == null) { |
|
| 13 | + return redirect()->route('shop.single.product', [$product->id, $product->items->first()->id]); |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | - $details_fields = Template::getDetailsFields($product,$product_item_id); |
|
| 16 | + $details_fields = Template::getDetailsFields($product, $product_item_id); |
|
| 17 | 17 | $configuration_fields = Template::getConfigurationFields($product_item_id); |
| 18 | 18 | $btn_cart = Template::buttonCart($product_item_id); |
| 19 | 19 | $price = Product::getPrice($product_item_id); |
@@ -21,6 +21,6 @@ discard block |
||
| 21 | 21 | $description = Product::getDescription($product_item_id); |
| 22 | 22 | $name = Product::getName($product_item_id); |
| 23 | 23 | |
| 24 | - return view('mongicommerce.pages.single-product',compact('product','details_fields','configuration_fields','btn_cart','price','image','description','name')); |
|
| 24 | + return view('mongicommerce.pages.single-product', compact('product', 'details_fields', 'configuration_fields', 'btn_cart', 'price', 'image', 'description', 'name')); |
|
| 25 | 25 | } |
| 26 | 26 | } |