Matrix Helpers
Available Methods
matrix_exists
matrix_collections
matrix_entries
matrix_collection
matrix_type
matrix_builder
matrix_make
Method Listing
matrix_exists()
The matrix_exists
method will return a boolean value based on if the given matrix collection exists or not.
if (matrix_exists('blog')) {
// The matrix collection "blog" exists
}
matrix_collections()
The matrix_collections
method returns an instance of the matrix collection model.
foreach (matrix_collections()->get() as $collection) {
//
}
matrix_entries()
The matrix_entries
method returns an instance of the matrix entry model for the given matrix collection handle.
$posts = matrix_entries('blog');
You may also pass through a second parameter to limit the entries from a specific type associated with the collection.
$articles = matrix_entries('support', 'faq');
Query Scopes
The Matrix Entry model instance provides easy to use query scopes for common queries used in pulling and sorting content. Query scopes are easy to use, only requiring you to chain them on to your query:
matrix_entries('blog')
->sorted()
->enabled()
->live()
->paginate(15);
enabled()
Filters out disabled items.
disabled()
Filters out enabled items.
live()
Filters out items that have a publish_at
greater than today's date, as well as items that have a expire_at
value equal or less than today's date.
sorted()
Sorts items according to the matrix type settings.
matrix_collection()
The matrix_collection
method returns an instance of the matrix collection model for the given handle.
$blog = matrix_collection('blog');
matrix_type()
The matrix_type
method returns an instance of the matrix type model for the given collection and type handle.
$faq = matrix_collection('support', 'faq');
matrix_builder()
The matrix_builder
method returns an instance of the matrix builder using the passed collection and type handles.
$builder = matrix_builder('blog', 'posts');
matrix_make()
The matrix_make
method returns an instance of the matrix entry model using the passed collection and type handles.
$model = matrix_make('blog', 'posts');