Test Failed
Push — master ( dd54f9...1129de )
by Gianluca
05:44
created

Product   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 7
eloc 10
c 4
b 0
f 0
dl 0
loc 32
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A items() 0 2 1
A category() 0 2 1
A details() 0 2 1
A getPrice() 0 2 1
A getImage() 0 2 1
A getName() 0 2 1
A getDescription() 0 2 1
1
<?php
2
3
4
namespace Mongi\Mongicommerce\Models;
5
6
7
use Illuminate\Database\Eloquent\Model;
8
use Mongi\Mongicommerce\Models\Category;
9
use Mongi\Mongicommerce\Models\ProductItem;
10
use Mongi\Mongicommerce\Models\ProductItemDetail;
11
use Illuminate\Database\Eloquent\Factories\HasFactory;
12
13
class Product extends Model
14
{
15
    use HasFactory;
16
17
    protected $dates = ["created_at","updated_at"];
18
19
    public function items(){
20
        return $this->hasMany(ProductItem::class);
21
    }
22
23
    public function category(){
24
        return $this->belongsTo(Category::class);
25
    }
26
27
    public function details(){
28
        return $this->hasManyThrough(ProductItemDetail::class,ProductItem::class);
29
    }
30
31
    public static function getPrice($product_item_id){
32
        return ProductItem::find($product_item_id)->price;
33
    }
34
35
    public static function getImage($product_item_id){
36
        return ProductItem::find($product_item_id)->image;
37
    }
38
39
    public static function getDescription($product_item_id){
40
        return ProductItem::find($product_item_id)->description;
41
    }
42
43
    public static function getName($product_item_id){
44
        return ProductItem::find($product_item_id)->name;
45
    }
46
47
48
49
}
50