This commit is contained in:
mahdi purHosseini
2024-02-13 11:56:00 +03:30
parent a06125d8a2
commit 74f9052df6
2 changed files with 19 additions and 7 deletions
+8 -3
View File
@@ -36,17 +36,22 @@ class Item extends Model implements HasMedia
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");
}
public function registerMediaCollections(): void