| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- use Illuminate\Database\Eloquent\Relations\BelongsToMany;
- use Illuminate\Database\Eloquent\Relations\HasMany;
- class Reclamation extends Model
- {
- const DEFAULT_SORT_BY = 'created_at';
- const STATUS_NEW = 1;
- const STATUS_IN_WORK = 2;
- const STATUS_SUBSCRIBE_ACT = 3;
- const STATUS_DONE = 4;
- const STATUS_SENT = 5;
- const STATUS_DO_DOCS = 6;
- const STATUS_HANDOVER_TO_CHECK = 7;
- const STATUS_PAID = 8;
- const STATUS_CLOSED_NO_PAY = 9;
- const STATUS_NAMES = [
- self::STATUS_NEW => 'Новая',
- self::STATUS_IN_WORK => 'В работе',
- self::STATUS_SUBSCRIBE_ACT => 'Подпись акта',
- self::STATUS_DONE => 'Исправлена',
- self::STATUS_SENT => 'Отправлена',
- self::STATUS_DO_DOCS => 'Подготовка документов',
- self::STATUS_HANDOVER_TO_CHECK => 'Передана на проверку',
- self::STATUS_PAID => 'Оплачена',
- self::STATUS_CLOSED_NO_PAY => 'Закрыта, не оплачивается',
- ];
- protected $fillable = [
- 'order_id',
- 'user_id',
- 'status_id',
- 'reason',
- 'guarantee',
- 'whats_done',
- 'create_date',
- 'finish_date',
- 'start_work_date',
- 'work_days',
- 'brigadier_id',
- ];
- public function order(): BelongsTo
- {
- return $this->belongsTo(Order::class)->withoutGlobalScopes();
- }
- public function status(): BelongsTo
- {
- return $this->belongsTo(ReclamationStatus::class);
- }
- public function skus(): BelongsToMany
- {
- return $this->belongsToMany(
- ProductSKU::class,
- 'reclamation_product_sku',
- 'reclamation_id',
- 'product_sku_id')
- ->withoutGlobalScopes();
- }
- public function user(): BelongsTo
- {
- return $this->belongsTo(User::class);
- }
- public function brigadier(): BelongsTo
- {
- return $this->belongsTo(User::class, 'brigadier_id', 'id');
- }
- public function photos_before(): BelongsToMany
- {
- return $this->belongsToMany(File::class, 'reclamation_photo_before');
- }
- public function photos_after(): BelongsToMany
- {
- return $this->belongsToMany(File::class, 'reclamation_photo_after');
- }
- public function documents(): BelongsToMany
- {
- return $this->belongsToMany(File::class, 'reclamation_document');
- }
- public function acts(): BelongsToMany
- {
- return $this->belongsToMany(File::class, 'reclamation_act');
- }
- public function details(): HasMany
- {
- return $this->hasMany(ReclamationDetail::class);
- }
- }
|