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

Product::getPrice()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 2
rs 10
cc 1
nc 1
nop 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