Publishable
Enso provides a way to easily add a "published" state to your crud model, including some query scopes and a "publish at" date that allows you to publish an item at a set date in the future.
- Add a
publishedboolean to your model. - Add the
Yadda\Enso\Crud\Traits\IsPublishabletrait to your model. - Add the
Yadda\Enso\Crud\Traits\IsPublishableCrudtrait to your Crud config. - Add the
Yadda\Enso\Crud\Traits\PublishesItemstrait to your Crud Controller. - Add a checkbox to your Crud config.
Adding the checkbox
CheckboxField::make('published')
->setLabel('Ready to Publish?')
->setOptions([
'published' => '',
]),
Publishing in the Future
If you want to add a "publish at" date, add a timestamp column to your model and then override the getPublishAtColumn method, e.g.:
/**
* Gets the name of the Publish At DateTime column on this publishable
*
* @return string|null
*/
public function getPublishAtColumn()
{
return 'publish_at';
}
Add a DateTimeField to your crud as follows:
DateTimeField::make('publish_at'),