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.

  1. Add a published boolean to your model.
  2. Add the Yadda\Enso\Crud\Traits\IsPublishable trait to your model.
  3. Add the Yadda\Enso\Crud\Traits\IsPublishableCrud trait to your Crud config.
  4. Add the Yadda\Enso\Crud\Traits\PublishesItems trait to your Crud Controller.
  5. 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'),