Appointment.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace App\Models;
  3. use App\Enums\AppointmentStatusEnum;
  4. use Illuminate\Database\Eloquent\Model;
  5. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  6. use Illuminate\Database\Eloquent\SoftDeletes;
  7. class Appointment extends Model
  8. {
  9. use SoftDeletes;
  10. protected $guarded = ['id'];
  11. protected function casts(): array
  12. {
  13. return [
  14. 'date' => 'date',
  15. 'requested_at' => 'datetime',
  16. 'status' => AppointmentStatusEnum::class,
  17. 'auto_approved' => 'boolean',
  18. ];
  19. }
  20. public function user(): BelongsTo
  21. {
  22. return $this->belongsTo(User::class);
  23. }
  24. public function approvedByUser(): BelongsTo
  25. {
  26. return $this->belongsTo(User::class, 'approved_by_user_id');
  27. }
  28. public function partnerAgreement(): BelongsTo
  29. {
  30. return $this->belongsTo(PartnerAgreement::class);
  31. }
  32. public function partnerAgreementService(): BelongsTo
  33. {
  34. return $this->belongsTo(PartnerAgreementService::class);
  35. }
  36. }