PHP code example of peltonsolutions / filament-enums

1. Go to this page and download the library: Download peltonsolutions/filament-enums library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

peltonsolutions / filament-enums example snippets


class ContentPageStatus extends \PeltonSolutions\LaravelEnums\Models\Enum
{
	const DRAFT = 'draft';
	const SCHEDULED = 'scheduled';
	const PUBLISHED = 'published';
	const ARCHIVED = 'archived';

	public static function map(): array
	{
		return [
			static::DRAFT => trans('content_page.statuses.draft'),
			static::SCHEDULED => trans('content_page.statuses.scheduled'),
			static::PUBLISHED => trans('content_page.statuses.published'),
			static::ARCHIVED => trans('content_page.statuses.archived'),
		];
	}
}

class ContentPage extends Model
{
	protected $casts = [
		'status' => ContentPageStatus::class
	];
}

class ContentPageResource extends Resource
{
	protected static ?string $model = ContentPage::class;

	public static function form(Form $form): Form
	{
		return $form
			->schema([
				\PeltonSolutions\FilamentEnums\Models\Forms\Components\EnumSelect::make('status')
						  ->default(ContentPageStatus::DRAFT);
	}
}