1 | <?php |
||||||
2 | |||||||
3 | namespace Translation\Traits; |
||||||
4 | |||||||
5 | trait TranslationTrait |
||||||
6 | { |
||||||
7 | /** |
||||||
8 | * The belongsTo locale relationship. |
||||||
9 | * |
||||||
10 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||||||
11 | */ |
||||||
12 | abstract public function locale(); |
||||||
13 | |||||||
14 | /** |
||||||
15 | * The belongsTo parent relationship. |
||||||
16 | * |
||||||
17 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||||||
18 | */ |
||||||
19 | abstract public function parent(); |
||||||
20 | |||||||
21 | /** |
||||||
22 | * Returns true/false if the current translation |
||||||
23 | * record is the parent translation. |
||||||
24 | * |
||||||
25 | * @return bool |
||||||
26 | */ |
||||||
27 | public function isParent() |
||||||
28 | { |
||||||
29 | if (!$this->getAttribute($this->getForeignKey())) { |
||||||
0 ignored issues
–
show
Bug
introduced
by
![]() It seems like
getAttribute() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
30 | return true; |
||||||
31 | } |
||||||
32 | |||||||
33 | return false; |
||||||
34 | } |
||||||
35 | |||||||
36 | /** |
||||||
37 | * Returns the translations of the current |
||||||
38 | * translation record. |
||||||
39 | * |
||||||
40 | * @return mixed |
||||||
41 | */ |
||||||
42 | public function getTranslations() |
||||||
43 | { |
||||||
44 | if ($this->isParent()) { |
||||||
45 | return $this->query()->where($this->getForeignKey(), $this->getKey())->get(); |
||||||
0 ignored issues
–
show
It seems like
getKey() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() It seems like
query() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
46 | } |
||||||
47 | |||||||
48 | return false; |
||||||
49 | } |
||||||
50 | } |
||||||
51 |