| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- namespace App;
- use Illuminate\Database\Eloquent\Model;
- use App\Traits\ModelTimeFormat;
- use App\Traits\ModelLogChanging;
- use Illuminate\Database\Eloquent\Relations\HasMany;
- class Warehouse extends Model
- {
- use ModelLogChanging;
- use ModelTimeFormat;
- protected $fillable=['name','code',"production_capacity","reduced_production_capacity_coefficient","address","principal","phone","province_id","city_id","county_id"];
- public function userWorkgroups(){
- return $this->hasMany('App\UserWorkgroup');
- }
- public function province()
- { //省
- return $this->belongsTo(Region::class)->where("type",1);
- }
- public function city()
- { //市
- return $this->belongsTo(Region::class)->where("type",2);
- }
- public function county()
- { //区县
- return $this->belongsTo(Region::class)->where("type",3);
- }
- /**
- * @return HasMany
- */
- public function laborCompanies(): HasMany
- {
- return $this->hasMany(LaborCompany::class,'warehouse_id','id');
- }
- }
|