-
Notifications
You must be signed in to change notification settings - Fork 2
/
Commodity.php
43 lines (34 loc) · 893 Bytes
/
Commodity.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
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Commodity extends Model
{
protected $fillable = ['name'];
public function reserves()
{
return $this->hasMany('App\Models\Reserve');
}
public function commoditystat()
{
return $this->hasOne('App\Models\Commoditystat');
}
public function baselinestocks()
{
return $this->hasMany('App\Models\Baselinestock');
}
public function effects()
{
return $this->hasMany('App\Models\Effect');
}
public function displayName()
{
if ($this->description) {
return $this->description;
}
return preg_replace("/([a-z])([A-Z])/",'$1 $2',$this->name);
}
public function effectForStateID($stateid)
{
return $this->effects->where('state_id', $stateid)->first();
}
}