From b7d2c0b92093a1c70e4a7b2f095abd40b3b2844a Mon Sep 17 00:00:00 2001 From: mahdi purHosseini Date: Tue, 13 Feb 2024 11:56:49 +0330 Subject: [PATCH] fix --- app/Package.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/Package.php b/app/Package.php index 8dfa95cc..4a0d0c8a 100644 --- a/app/Package.php +++ b/app/Package.php @@ -31,16 +31,21 @@ class Package extends Model public function transfersAll() { - return $this->morphMany( 'App\Transfer' , "transferable" ); + return $this->morphMany( 'App\Transfer' , "transferable" )->orderBy("id" , "desc"); } public function transfers() { - return $this->morphMany( 'App\Transfer' , "transferable" )->where( "status" , StatusTypeEnum::APPROVED ); + return $this->morphMany( 'App\Transfer' , "transferable" )->where( "status" , StatusTypeEnum::APPROVED )->orderBy("id" , "desc"); + } + + public function latestTransfer() + { + return $this->morphOne( 'App\Transfer' , "transferable" )->where( "status" , StatusTypeEnum::APPROVED )->orderBy("id" , "desc")->latest(); } public function transferActive() { - return $this->morphMany( 'App\Transfer' , "transferable" )->where( "status" , StatusTypeEnum::APPROVED )->whereNull( "to_date" ); + return $this->morphMany( 'App\Transfer' , "transferable" )->where( "status" , StatusTypeEnum::APPROVED )->whereNull( "to_date" )->orderBy("id" , "desc"); } }