Models
Creating models
A model represents a content type of your Prismic environment. Each model should extends the abstract base model from the package.
For example; We have a content type called 'page':
This base setup is already enough to query the api for your documents.
You can overwrite the static method getTypeName
to specify the content type. Prismic Eloquent will use the name of the class by default and convert camelCase to snake_case.
Alter fields
Your model can implement methods that are called when a field is called. For example a 'title' field can be changed like:
You model will now use getTitleField
when $page->title
is called.
Local scopes
Local scopes like used in the normal Eloquent models are also available.
Camel case fields
You can access your model field by camelCase. Prismic Eloquent will automatically change camel case to snake case since this is the default in Prismic.
For example:
You can disable this behaviour by overwriting the fieldsToSnakeCase
property on your model.
Last updated