ShopSingleProductController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 12
c 1
b 0
f 0
dl 0
loc 17
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A page() 0 15 2
1
<?php
2
namespace Mongi\Mongicommerce\Http\Controllers\shop;
3
4
use Mongi\Mongicommerce\Http\Controllers\Controller;
5
use Mongi\Mongicommerce\Libraries\Template;
6
use Mongi\Mongicommerce\Models\Product;
7
8
class ShopSingleProductController extends Controller
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
         }
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);
23
24
         return view('mongicommerce.pages.single-product',compact('product','details_fields','configuration_fields','btn_cart','price','image','description','name'));
25
     }
26
}
27