ConsumableTrack.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace App\Models;
  3. use Dcat\Admin\Traits\HasDateTimeFormatter;
  4. use Illuminate\Database\Eloquent\Model;
  5. use Illuminate\Database\Eloquent\Relations\HasOne;
  6. use Illuminate\Database\Eloquent\SoftDeletes;
  7. use Illuminate\Support\Facades\Date;
  8. /**
  9. * @method static where(string $key, string $value1, string $value2 = null)
  10. *
  11. * @property int consumable_id
  12. * @property string operator
  13. * @property float number
  14. * @property float change
  15. * @property Date|null purchased
  16. * @property Date|null expired
  17. * @property string|null description
  18. */
  19. class ConsumableTrack extends Model
  20. {
  21. use HasDateTimeFormatter;
  22. use SoftDeletes;
  23. protected $table = 'consumable_tracks';
  24. /**
  25. * 耗材追踪有一个耗材记录.
  26. *
  27. * @return HasOne
  28. */
  29. public function consumable(): HasOne
  30. {
  31. return $this->hasOne(ConsumableRecord::class, 'id', 'consumable_id');
  32. }
  33. /**
  34. * 耗材追踪有一个用户.
  35. *
  36. * @return HasOne
  37. */
  38. public function user(): HasOne
  39. {
  40. return $this->hasOne(User::class, 'id', 'user_id');
  41. }
  42. }