| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- namespace App\Models;
- class SparePartsView extends SparePart
- {
- protected $table = 'spare_parts_view';
- public $timestamps = false;
- public function pricingCodes(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
- {
- return $this->belongsToMany(PricingCode::class, 'spare_part_pricing_code', 'spare_part_id', 'pricing_code_id')
- ->withTimestamps();
- }
- public function getQuantityWithoutDocsAttribute(): int
- {
- if (array_key_exists('quantity_without_docs', $this->attributes)) {
- return (int) $this->attributes['quantity_without_docs'];
- }
- return parent::getQuantityWithoutDocsAttribute();
- }
- public function getQuantityWithDocsAttribute(): int
- {
- if (array_key_exists('quantity_with_docs', $this->attributes)) {
- return (int) $this->attributes['quantity_with_docs'];
- }
- return parent::getQuantityWithDocsAttribute();
- }
- public function getTotalQuantityAttribute(): int
- {
- if (array_key_exists('total_quantity', $this->attributes)) {
- return (int) $this->attributes['total_quantity'];
- }
- return parent::getTotalQuantityAttribute();
- }
- }
|