Skip to content
This repository has been archived by the owner on Aug 17, 2021. It is now read-only.

Commit

Permalink
Merge pull request #7 from ricardovanlaarhoven/patch-1
Browse files Browse the repository at this point in the history
Update HasTranslations.php
  • Loading branch information
koenhoeijmakers authored Oct 24, 2018
2 parents bbf7c4b + 6ab663f commit db559ab
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/HasTranslations.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace KoenHoeijmakers\LaravelTranslatable;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Arr;
use KoenHoeijmakers\LaravelTranslatable\Exceptions\MissingTranslationsException;
use KoenHoeijmakers\LaravelTranslatable\Scopes\JoinTranslationScope;
Expand Down Expand Up @@ -51,7 +52,7 @@ public static function bootHasTranslations()
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function translations()
public function translations(): HasMany
{
return $this->hasMany($this->getTranslationModel(), $this->getTranslationForeignKey());
}
Expand Down Expand Up @@ -129,7 +130,7 @@ public function getTranslationForeignKey()
*/
public function getTranslatable(): array
{
if (!isset($this->translatable)) {
if (! isset($this->translatable)) {
throw new MissingTranslationsException('Model "' . static::class . '" is missing translations');
}

Expand All @@ -153,7 +154,7 @@ public function getTranslatableAttributes(): array
*/
public function storeTranslation(string $locale, array $attributes = [])
{
if (!is_null($model = $this->translations()->where($this->getLocaleKeyName(), $locale)->first())) {
if (! is_null($model = $this->translations()->where($this->getLocaleKeyName(), $locale)->first())) {
$model->update($attributes);

return $model;
Expand Down Expand Up @@ -224,11 +225,11 @@ public function getLocale(): string
/**
* Refresh the translation (in the current locale).
*
* @return \Illuminate\Database\Eloquent\Model|null
* @return \Illuminate\Database\Eloquent\Model|null|HasTranslations
*/
public function refreshTranslation()
{
if (!$this->exists) {
if (! $this->exists) {
return null;
}

Expand All @@ -253,7 +254,7 @@ public function refreshTranslation()
*/
public function translate(string $locale)
{
if (!$this->exists) {
if (! $this->exists) {
return null;
}

Expand Down Expand Up @@ -290,7 +291,7 @@ public function newQueryWithoutScopes(): Builder
/**
* Retrieve the model for a bound value.
*
* @param mixed $value
* @param mixed $value
* @return \Illuminate\Database\Eloquent\Model|null
*/
public function resolveRouteBinding($value)
Expand Down

0 comments on commit db559ab

Please sign in to comment.