By John Koster
The isEmpty
can be used to determine if the collection has items or not. If the collection has no items, true
will be returned, otherwise false
will be returned.
1<?php
2
3use Illuminate\Support\Collection;
4
5// Create a new collection instance.
6$collection = new Collection;
7
8// true
9$empty = $collection->isEmpty();
10
11// Add an item to the collection.
12$collection[] = 'First item';
13
14// false
15$empty = $collection->isEmpty();
#Continue Reading
This article is the start of a mini-series about Laravel's ErrorMessageBag
component. Click through the rest of the articles to continue reading:
- An Introduction to Laravel Message Bags
- Laravel MessageBag Public API: add
- Laravel MessageBag Public API: all
- Laravel MessageBag Public API: any
- Laravel MessageBag Public API: count
- Laravel MessageBag Public API: first
- Laravel MessageBag Public API: get
- Laravel MessageBag Public API: getFormat
- Laravel MessageBag Public API: getMessageBag
- Laravel MessageBag Public API: getMessages
- Laravel MessageBag Public API: has
- Laravel MessageBag Public API: isEmpty
- Laravel MessageBag Public API: jsonSerialize
- Laravel MessageBag Public API: keys
- Laravel MessageBag Public API: merge
- Laravel MessageBag Public API: setFormat
- Laravel MessageBag Public API: toArray
- Laravel MessageBag Public API: toJson
- Laravel MessageBag Public API: __toString
∎