Skip to content

Commit

Permalink
Update casting documentation. (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdpoulter authored Dec 10, 2020
1 parent a059de0 commit 69627ec
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
];
Expand All @@ -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
{
// ...

Expand All @@ -52,7 +55,7 @@ class User extends Resource
return [
// ...

Enum::make('Role')->attachEnum(UserRole::class),
Enum::make('User Type')->attachEnum(UserType::class),

// ...
];
Expand Down

0 comments on commit 69627ec

Please sign in to comment.