Alarm.php 964 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace App\Models;
  3. use DateTimeInterface;
  4. use Illuminate\Database\Eloquent\Factories\HasFactory;
  5. use Illuminate\Database\Eloquent\Model;
  6. use Illuminate\Database\Eloquent\SoftDeletes;
  7. class Alarm extends Model
  8. {
  9. use HasFactory,SoftDeletes;
  10. protected $table = 'js_call';
  11. protected $hidden = [
  12. //
  13. ];
  14. public $timestamps = FALSE;
  15. const DELETED_AT = 'delete_time';
  16. protected $dateFormat = 'U';
  17. protected $appends = [];
  18. protected function serializeDate(DateTimeInterface $date): string
  19. {
  20. return $date->format('Y-m-d H:i:s');
  21. }
  22. public function getIsBusyAttribute()
  23. {
  24. return Order::where(['jiedan_js_id' => $this->id, 'status' => 6])->count();
  25. }
  26. public function getSiteAttribute()
  27. {
  28. return ArtificerSite::where(['js_id' => $this->id])->first();
  29. }
  30. public function order()
  31. {
  32. return $this->hasOne(Order::class, 'id', 'order_id');
  33. }
  34. }