Skip to content

Commit 1a5df52

Browse files
authored
Changed helper methods to static methods
1 parent 83a6ed6 commit 1a5df52

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

Eloquent/Traits/Translatable.php

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,26 +135,45 @@ public function newFromBuilder($attributes = [], $connection = null)
135135

136136
return $model;
137137
}
138+
138139
/**
139-
* @return array
140+
* @return bool
141+
*
142+
* @author Rytis Grincevičius <[email protected]>
140143
*/
141-
public function getTranslatableAttributes()
144+
public static function hasTranslatableTrait()
142145
{
143-
return $this->translatable;
146+
return true;
144147
}
148+
145149
/**
146-
* @param string $attribute
147150
* @return bool
151+
*
152+
* @author Rytis Grincevičius <[email protected]>
148153
*/
149-
public function isAttributeTranslatable($attribute)
154+
public static function hasTranslatableAttribute()
150155
{
151-
return in_array($attribute, $this->translatable);
156+
return count(self::getTranslatableAttributes()) > 0;
152157
}
158+
159+
/**
160+
* @return array
161+
*
162+
* @author Rytis Grincevičius <[email protected]>
163+
*/
164+
public static function getTranslatableAttributes()
165+
{
166+
return (array) with(new self)->translatable;
167+
}
168+
153169
/**
170+
* @param string|array $attribute
154171
* @return bool
172+
*
173+
* @author Rytis Grincevičius <[email protected]>
155174
*/
156-
public function isModelTranslatable()
175+
public static function isAttributeTranslatable($attribute)
157176
{
158-
return count($this->translatable) > 0;
177+
return count(array_diff((array) $attribute, self::getTranslatableAttributes())) === 0;
159178
}
160179
}

0 commit comments

Comments
 (0)