creode/nova-publishable

Utilises the Publishable Package, to create a new published field for the module.

1.2.0 2024-10-22 07:33 UTC

This package is auto-updated.

Last update: 2024-12-22 07:53:45 UTC


README

Latest Version on Packagist Total Downloads

This package provides an integration between the Laravel Publishable package and Nova.

Installation

composer require creode/nova-publishable

Usage

To use the field, you must first add the Publishable trait to your model.

use PawelMysior\Publishable\Publishable;

class Post extends Model
{
    use Publishable;
}

Then, you can add the field to your Nova resource.

use Creode\LaravelPublishable\Published;

class Post extends Resource
{
    // ...

    public function fields(Request $request)
    {
        return [
            // ...

            Published::make('Published', 'published_at'),
        ];
    }
}

Publish/Unpublish Actions

This package also provides actions to publish and unpublish resources. To use these, you must add the Publishable trait to your model as above.

Then you can add the following actions to your Nova resource.

use Creode\NovaPublishable\Actions\PublishAction;
use Creode\NovaPublishable\Actions\UnpublishAction;

class Post extends Resource
{
    // ...

    public function actions(Request $request)
    {
        return [
            // ...

            new PublishAction,
            new UnpublishAction,
        ];
    }
}

Roadmap

  • Add tests with Dusk
  • Improve the field by allowing the user to schedule resources by specify a publishable date via a secondary field

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.