Skip to content

Commit

Permalink
Changing the way that we check if the model has the Spatie's translat…
Browse files Browse the repository at this point in the history
…able trait
  • Loading branch information
ngiraud committed Feb 4, 2020
1 parent 1e6f3c3 commit 991132c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to `ngiraud/nova-translatable-v2` will be documented in this file

## 1.0.1 - 2020-02-04

- Changing the way that we check if the model has the Spatie's translatable trait

## 1.0.0 - 2020-02-04

- initial release
4 changes: 2 additions & 2 deletions src/FieldMacros.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Exception;
use Laravel\Nova\Http\Requests\NovaRequest;
use Spatie\Translatable\HasTranslations;

class FieldMacros
{
Expand All @@ -14,8 +13,9 @@ public function translatable()
$originalComponent = $this->component;

$this->resolveUsing(function ($value, $resource, $attribute) use ($locales, $originalComponent) {
// We check if the model has the Spatie's translatable trait
throw_if(
!in_array(HasTranslations::class, class_uses($resource)),
!method_exists($resource, 'guardAgainstNonTranslatableAttribute'),
new Exception("You must attach the \Spatie\Translatable\HasTranslations trait to model " . get_class($resource) . " in order to use the translatable functionality.")
);

Expand Down

0 comments on commit 991132c

Please sign in to comment.