mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-28 12:40:08 +02:00
Dont change the original collection when calling getOrderdetails with $hide_obsolete = true
This caused the orderdetails tab to be hidden on part info, when the orderdetail was obsolete
This commit is contained in:
parent
28c09eb51d
commit
b0d29eaeaf
1 changed files with 4 additions and 8 deletions
|
@ -44,6 +44,7 @@ namespace App\Entity\Parts\PartTraits;
|
|||
|
||||
use App\Entity\PriceInformations\Orderdetail;
|
||||
use App\Security\Annotations\ColumnSecurity;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use function count;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
@ -129,14 +130,9 @@ trait OrderTrait
|
|||
{
|
||||
//If needed hide the obsolete entries
|
||||
if ($hide_obsolete) {
|
||||
$orderdetails = $this->orderdetails;
|
||||
foreach ($orderdetails as $key => $details) {
|
||||
if ($details->getObsolete()) {
|
||||
unset($orderdetails[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
return $orderdetails;
|
||||
return $this->orderdetails->filter(function (Orderdetail $orderdetail) {
|
||||
return ! $orderdetail->getObsolete();
|
||||
});
|
||||
}
|
||||
|
||||
return $this->orderdetails;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue