| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- use Illuminate\Database\Eloquent\Relations\BelongsToMany;
- 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',
- ];
- 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 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');
- }
- }
|