承接 ronssij/filament-simple-draft 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ronssij/filament-simple-draft

最新稳定版本:v1.0.6

Composer 安装命令:

composer require ronssij/filament-simple-draft

包简介

Is a simple FilamentPHP plugin that allows to save forms as drafts.

README 文档

README

Latest Version on Packagist Total Downloads Licence

This package is a simple plugin to allow required fields on forms to be draftable. Filament field components already could do it on demand using:

->nullable(true|false)

Installation

You can install the package via composer:

composer require ronssij/filament-simple-draft

You can publish the config file with:

php artisan vendor:publish --tag="filament-simple-draft-config"

This is the contents of the published config file:

// config/filament-simple-draft.php
return [
    'publishable_column' => 'published_at',
];

Usage

On your model, these classes should be used. Make sure all of you draftable fields are nullable columns on your model.

use Ronssij\FilamentSimpleDraft\Contracts\CanBePublished;
use Ronssij\FilamentSimpleDraft\Publishable;

class User extends Authenticatable implements CanBePublished
{
    // Optionally, you can set you published column identifier
    // Or you can set it via configuration (config/filament-simple-draft.php).
    protected ?string $publishColumn = 'published_date';

    use Publishable;
}

On your Resources for CreateRecord and EditRecord:

use Filament\Resources\Pages\EditRecord;
use Ronssij\FilamentSimpleDraft\Pages\Traits\Edit\Draftable;

class EditUser extends EditRecord
{
    use Draftable;
}
use Filament\Resources\Pages\CreateRecord;
use Ronssij\FilamentSimpleDraft\Pages\Traits\Create\Draftable;

class CreateUser extends CreateRecord
{
    use Draftable;
}

Resource form usage:

By chaining ->draftable() on any form fields it will be required when Published and nullable on Save Draft.

use Filament\Forms;
use Filament\Forms\Form;
use FilamentTiptapEditor\Enums\TiptapOutput;
use FilamentTiptapEditor\TiptapEditor;

public static function form(Form $form): Form
{
    return $form
        ->schema([
            Forms\Components\TextInput::make('title')
                ->label('Blog title')
                ->draftable()
            Forms\Components\Textarea::make('description')
                ->label('Blog description')
                ->rows(5)
                ->draftable()
            TiptapEditor::make('content')
                ->label('Blog content')
                ->draftable()
                ->output(TiptapOutput::Html)
        ]);
}

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

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

License

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

统计信息

  • 总下载量: 1.67k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-12-06