From 69627eca51a5068eb479777f29dc49392053c090 Mon Sep 17 00:00:00 2001 From: Matthew Poulter Date: Thu, 10 Dec 2020 12:42:21 +0200 Subject: [PATCH] Update casting documentation. (#22) --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fa9aff4..1ed3232 100644 --- a/README.md +++ b/README.md @@ -22,11 +22,14 @@ composer require simplesquid/nova-enum-field This package requires that you use Attribute Casting in your models. From the docs at [BenSampo/laravel-enum](https://github.com/BenSampo/laravel-enum#attribute-casting), this can be done like so: ```php +use BenSampo\Enum\Traits\CastsEnums; use BenSampo\Enum\Tests\Enums\UserType; use Illuminate\Database\Eloquent\Model; class Example extends Model { + use CastsEnums; + protected $casts = [ 'user_type' => UserType::class, ]; @@ -40,10 +43,10 @@ You can use the `Enum` field in your Nova resource like so: ```php namespace App\Nova; -use App\Enums\UserRole; +use BenSampo\Enum\Tests\Enums\UserType; use SimpleSquid\Nova\Fields\Enum\Enum; -class User extends Resource +class Example extends Resource { // ... @@ -52,7 +55,7 @@ class User extends Resource return [ // ... - Enum::make('Role')->attachEnum(UserRole::class), + Enum::make('User Type')->attachEnum(UserType::class), // ... ];