Test Failed
Push — master ( 7e98c1...89c50d )
by Gianluca
06:24
created

Product   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

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

4 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
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
36
37
}
38