mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
add invoice in order resources
This commit is contained in:
@@ -46,6 +46,7 @@ class OrderResource extends JsonResource
|
||||
'received_packages' => PackingListResource::collection($this->packingLists()->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('packages')->get()),
|
||||
];
|
||||
}),
|
||||
'invoices' => TransactionResource::collection($this->transactions),
|
||||
'remarks' => RemarkResource::collection($this->remarks),
|
||||
'created_at' => $this->created_at->format('d-m-Y')
|
||||
];
|
||||
|
||||
@@ -16,10 +16,13 @@ use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
|
||||
class Order extends AbstractModel implements Addressable, Packable, Remarkable, Notifiable
|
||||
{
|
||||
use SoftDeletes;
|
||||
use HasRelationships;
|
||||
|
||||
protected $table = 'orders';
|
||||
|
||||
@@ -160,10 +163,10 @@ class Order extends AbstractModel implements Addressable, Packable, Remarkable,
|
||||
}
|
||||
|
||||
/**
|
||||
* @return morphMany
|
||||
* @return hasManyDeep
|
||||
*/
|
||||
// public function transactions(): morphMany
|
||||
// {
|
||||
// return $this->morphMany(Transaction::class, 'owner');
|
||||
// }
|
||||
public function transactions(): hasManyDeep
|
||||
{
|
||||
return $this->hasManyDeep(Transaction::class, [PackingList::class], ['owner_id', 'owner_id'], ['id', 'id']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user