Reclamation.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  5. use Illuminate\Database\Eloquent\Relations\BelongsToMany;
  6. class Reclamation extends Model
  7. {
  8. protected $fillable = [
  9. 'order_id',
  10. 'user_id',
  11. 'reason',
  12. 'guarantee',
  13. 'whats_done',
  14. 'create_date',
  15. 'finish_date',
  16. ];
  17. public function order(): BelongsTo
  18. {
  19. return $this->belongsTo(Order::class);
  20. }
  21. public function user(): BelongsTo
  22. {
  23. return $this->belongsTo(User::class);
  24. }
  25. public function photos_before(): BelongsToMany
  26. {
  27. return $this->belongsToMany(File::class, 'reclamation_photo_before');
  28. }
  29. public function photos_after(): BelongsToMany
  30. {
  31. return $this->belongsToMany(File::class, 'reclamation_photo_after');
  32. }
  33. public function documents(): BelongsToMany
  34. {
  35. return $this->belongsToMany(File::class, 'reclamation_document');
  36. }
  37. public function acts(): BelongsToMany
  38. {
  39. return $this->belongsToMany(File::class, 'reclamation_act');
  40. }
  41. }