Warehouse.php 830 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. use App\Traits\ModelTimeFormat;
  5. use App\Traits\ModelLogChanging;
  6. class Warehouse extends Model
  7. {
  8. use ModelLogChanging;
  9. use ModelTimeFormat;
  10. protected $fillable=['name','code',"production_capacity","reduced_production_capacity_coefficient","address","principal","phone","province_id","city_id","county_id"];
  11. public function userWorkgroups(){
  12. return $this->hasMany('App\UserWorkgroup');
  13. }
  14. public function province()
  15. { //省
  16. return $this->belongsTo(Region::class)->where("type",1);
  17. }
  18. public function city()
  19. { //市
  20. return $this->belongsTo(Region::class)->where("type",2);
  21. }
  22. public function county()
  23. { //区县
  24. return $this->belongsTo(Region::class)->where("type",3);
  25. }
  26. }