StationCacheShelfGrid.php 897 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  5. use App\Traits\ModelLogChanging;
  6. class StationCacheShelfGrid extends Model
  7. {
  8. use ModelLogChanging;
  9. protected $fillable = ['station_id','material_box_id','grid_id','status'];
  10. public static $status = [
  11. '0' => '无',
  12. '1' => '待处理',
  13. ];
  14. public function station(): BelongsTo
  15. {
  16. return $this->belongsTo(Station::class);
  17. }
  18. public function materialBox(): BelongsTo
  19. {
  20. return $this->belongsTo(MaterialBox::class);
  21. }
  22. public static function getLocation(Station $station,StationCacheShelfGrid $grid)
  23. {
  24. $code = $station['code'];
  25. $grid_id = $grid['grid_id'];
  26. $row = 2- ($grid_id / 3) +1;
  27. $col = 2- ($grid_id % 3) +1;
  28. return 'HAI'.$code.'-0'.$row.'-0'.$col;
  29. }
  30. }