diff --git a/README.md b/README.md index 36e520f..c48098e 100644 --- a/README.md +++ b/README.md @@ -341,7 +341,7 @@ a language ID or a language code. ### Basic options for translations If you plan on using these functions for handling translations there are some -basics you need to set: +basics you need to set in your service class: ```php @@ -349,17 +349,16 @@ use Flobbos\Crudable\Contracts\Crud; use Flobbos\Crudable; use Flobbos\Crudable\Contracts\Translation; -class Category implements Crud,Translation{ +class CategoryService implements Crud,Translation{ use Crudable\Crudable; use \Flobbos\Crudable\Translations\Translatable; - protected $translation_name; - protected $required_trans; //optional array of fields - - public function __construct(){ - $this->translation_name = 'translations';//defines the relation name - } + //only necessary if your translation relation is named something else + //than 'translations' in your model + protected $translation_name = 'my_translations'; + //optional array of fields that HAVE to be present to save a translation + protected $required_trans; } @@ -444,9 +443,6 @@ This function returns an array that is then put into the save function: if(empty($translations)) throw new MissingTranslationsException; - if(empty($this->translation_name)) - throw new MissingTranslationNameException; - return $model->{$this->translation_name}()->saveMany($translations); } diff --git a/src/Crudable/Exceptions/MissingTranslationNameException.php b/src/Crudable/Exceptions/MissingTranslationNameException.php deleted file mode 100644 index bd56bdd..0000000 --- a/src/Crudable/Exceptions/MissingTranslationNameException.php +++ /dev/null @@ -1,9 +0,0 @@ -translation_name)) - throw new MissingTranslationNameException; - return $model->{$this->translation_name}()->saveMany($translations); }