-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProduct.php
71 lines (60 loc) · 1.4 KB
/
Product.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Product extends Model
{
/**
* Table associated with the model
*/
protected $table = 'products';
protected $fillable = ['title', 'description', 'quantity', 'unit_price', 'total_price', 'creation_data', 'category_id', 'subcategory_id', 'condition_id', 'state_id', 'user_id'];
/**
* Get the product details if is for sale
*/
public function productForSale()
{
return $this->hasOne(ProductForSale::class);
}
/**
* Get the images related to the product
*/
public function images()
{
return $this->hasMany(Image::class);
}
/**
* Get the user that owns the product
*/
public function user()
{
return $this->belongsTo(User::class);
}
/**
* Get the category of the product
*/
public function category()
{
return $this->belongsTo(Category::class);
}
/**
* Get the subcategory of the product
*/
public function subcategory()
{
return $this->belongsTo(Subcategory::class);
}
/**
* Get the condition of the product
*/
public function condition()
{
return $this->belongsTo(Condition::class);
}
/**
* Get the state of the product
*/
public function state()
{
return $this->belongsTo(State::class);
}
}