I have an Entity Order which hold Suppliers in an Arraycollection. In my controller i want to check if this arraycollection is empty:
$suppliers = $order->getSuppliers();
I tried:
if(!($suppliers)) {} if(empty($suppliers)) {}
Any ideas?
Doctrine ArrayCollection has a method isEmpty
that will do what you are looking for.
if ($suppliers->isEmpty()) { }
Take a look at the documentation for it here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With