95 lines
2.5 KiB
PHP
95 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\OrderStatusEnum;
|
|
use App\Enums\OrderType;
|
|
use App\Traits\SelfReferenceTraits;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
|
|
|
/**
|
|
* @method static find(int $orderId)
|
|
* @method static where($column, $operator = null, $value = null, $boolean = 'and')
|
|
* @method children()
|
|
*
|
|
* @property Collection<OrderArchivesItem> items
|
|
* @property Attachment attachment
|
|
* @property Supplier supplier
|
|
* @property ProfitCenter profitCenter
|
|
* @property HasMany children
|
|
* @property OrderStatusEnum orderStatus
|
|
* @property int|null parent_id
|
|
* @property OrderType orderType
|
|
*/
|
|
class OrderArchive extends BaseAuditable
|
|
{
|
|
use SelfReferenceTraits;
|
|
|
|
/**
|
|
* The items that belong to the OrderArchive.
|
|
*/
|
|
public function items(): HasMany
|
|
{
|
|
return $this->hasMany(OrderArchivesItem::class);
|
|
}
|
|
|
|
public function attachment(): MorphOne
|
|
{
|
|
return $this->morphOne(Attachment::class, 'attachable');
|
|
}
|
|
|
|
public function supplier(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Supplier::class);
|
|
}
|
|
|
|
public function profitCenter(): BelongsTo
|
|
{
|
|
return $this->belongsTo(ProfitCenter::class);
|
|
}
|
|
|
|
public function supplierNotifier(): HasMany
|
|
{
|
|
return $this->hasMany(SupplierNotifier::class);
|
|
}
|
|
|
|
public function itemsAPISpecial(): HasMany
|
|
{
|
|
return $this->hasMany(OrderArchivesItem::class);
|
|
// ->with(['ProductGroup']);
|
|
}
|
|
|
|
public function specialApiData()
|
|
{
|
|
/*
|
|
* 'supplier','profitCenter','itemsx'
|
|
* Rendelő felületről adatok biztosítása
|
|
- szállító kódja supplier.hooreycaId
|
|
- Szállítási dátum deliveryDate
|
|
- Üzlet kódja profit_center.hooreycaId
|
|
|
|
- Cikk kódja
|
|
- Mennyiségi egység (árlista L oszlop)
|
|
- Mértékegység (árlista H oszlop)
|
|
- Kiszerelés (árlista F oszlop)
|
|
- Súly/Űrtartalom (árlista G oszlop)
|
|
- Egységszorzó (árlista K oszlop)
|
|
- Rendelt mennyiség
|
|
- Megrendelt cikk nettó értéke
|
|
|
|
*/
|
|
$ret = $this->query();
|
|
// $ret=$ret->select('supplier_id');
|
|
// $ret=$ret->with(['supplier'=>function($query){$query->select('hooreycaId');}]);
|
|
$ret = $ret->with(['supplier' => function ($query) {
|
|
$query->select('id', 'hooreycaId');
|
|
}, 'profitCenter', 'itemsAPISpecial']);
|
|
|
|
// dd($ret->first());
|
|
return $ret;
|
|
|
|
}
|
|
}
|