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"); } }