| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Model;
- class SparePartOrdersView extends Model
- {
- protected $table = 'spare_part_orders_view';
- public $timestamps = false;
- const DEFAULT_SORT_BY = 'created_at';
- const STATUS_NAMES = [
- 'ordered' => 'Заказано',
- 'in_stock' => 'На складе',
- 'shipped' => 'Отгружено',
- ];
- protected $casts = [
- 'with_documents' => 'boolean',
- 'ordered_quantity' => 'integer',
- 'available_qty' => 'integer',
- ];
- /**
- * Статус на русском языке
- */
- public function getStatusNameAttribute(): string
- {
- return self::STATUS_NAMES[$this->status] ?? $this->status;
- }
- /**
- * С документами - да/нет
- */
- public function getWithDocumentsTextAttribute(): string
- {
- return $this->with_documents ? 'Да' : 'Нет';
- }
- /**
- * @deprecated Используйте available_qty
- */
- public function getRemainingQuantityAttribute(): int
- {
- return $this->available_qty ?? 0;
- }
- }
|