Download the PHP package think.studio/nova-flexible-content without Composer
On this page you can find all versions of the php package think.studio/nova-flexible-content. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download think.studio/nova-flexible-content
More information about think.studio/nova-flexible-content
Files in think.studio/nova-flexible-content
Package nova-flexible-content
Short Description Flexible Content & Repeater Fields for Laravel Nova.
License MIT
Homepage https://github.com/dev-think-one/nova-flexible-content
Informations about the package nova-flexible-content
Laravel Nova Flexible Content
This is fork from great package whitecube/nova-flexible-content
but reworked without easy possibility to merge
functionality to main package
An easy & complete Flexible Field for Laravel Nova, perfect for repeated and flexible field groups.
Nova | Package |
---|---|
V1 | V1 V2 |
V4 | V3 V4 |
Installation
Usage
A flexible field allows easy management of repeatable and orderable groups of fields. This package does not have constraints on which fields you are allowed to use within these groups. That means you can use all Laravel Nova field types, and also any community-made fields.
Layouts
A layout represents a group of fields that can be repeated inside the Flexible field. You can add as many different layouts as you wish. If only one layout is defined the field will behave like a simple Repeater and by adding more layouts you'll obtain a Flexible Content.
Layout definition
Then use this layout
Customizing display
You can change the display by call methods:
Value resolver
By default, the field takes advantage of a JSON column on your model's table. In some cases, a JSON attribute is just not the way to go. For example, you could want to store the values in another table (meaning you'll be using the Flexible Content field instead of a traditional BelongsToMany or HasMany field). No worries, we've got you covered!
Resolver definition
Each Resolver MUST implement the NovaFlexibleContent\Value\Resolver
contract and therefore feature at least
two methods: set
and get
.
Resolve the field
The get
method used to resolve the field's content. It is responsible to retrieve the content from somewhere and
return a collection of layouts instances (groups). For example, we could want to retrieve the values on a blocks
table
and transform them into Layout instance:
Fill the field
The set
method is responsible for saving the Flexible's content. In our example, it should store the data in
a blocks
table:
Preset
In addition to reusable Layout classes, you can go a step further and create Preset
classes for your Flexible fields.
These allow you to reuse your whole Flexible field anywhere you want. They also make it easier to make your Flexible
fields dynamic, for example if you want to add Layouts conditionally. And last but not least, they also have the added
benefit of cleaning up your Nova Resource classes, if your Flexible field has a lot of useLayout
definitions.
Preset definition
Display flexible content
The field stores its values as a single JSON string, meaning this string needs to be parsed before it can be used in your application.
IDE Helper
Create helper file for IDE your Flexible Layouts in application.