1 | <?php |
||||||
2 | |||||||
3 | namespace Cino\LaravelChronos\Eloquent; |
||||||
4 | |||||||
5 | use Cino\LaravelChronos\Eloquent\Concerns\ChronosRelations; |
||||||
6 | use Cino\LaravelChronos\Eloquent\Concerns\ChronosTimestamps; |
||||||
7 | use Cino\LaravelChronos\Eloquent\Relations\Pivot; |
||||||
8 | use Illuminate\Database\Eloquent\Model as BaseModel; |
||||||
9 | use Illuminate\Support\Collection; |
||||||
10 | |||||||
11 | /** |
||||||
12 | * @mixin \Illuminate\Database\Eloquent\Model |
||||||
13 | */ |
||||||
14 | trait Chronos |
||||||
15 | { |
||||||
16 | use ChronosRelations; |
||||||
17 | use ChronosTimestamps; |
||||||
18 | |||||||
19 | /** |
||||||
20 | * Create a new pivot model instance. |
||||||
21 | * |
||||||
22 | * @param \Illuminate\Database\Eloquent\Model $parent |
||||||
23 | * @param array $attributes |
||||||
24 | * @param string $table |
||||||
25 | * @param bool $exists |
||||||
26 | * @param string|null $using |
||||||
27 | * @return \Cino\LaravelChronos\Eloquent\Relations\Pivot |
||||||
28 | */ |
||||||
29 | 1 | public function newPivot(BaseModel $parent, array $attributes, $table, $exists, $using = null) |
|||||
30 | { |
||||||
31 | 1 | return $using ? $using::fromRawAttributes($parent, $attributes, $table, $exists) |
|||||
32 | 1 | : Pivot::fromAttributes($parent, $attributes, $table, $exists); |
|||||
33 | } |
||||||
34 | |||||||
35 | /** |
||||||
36 | * Reload the current model instance with fresh attributes from the database. |
||||||
37 | * |
||||||
38 | * @return \Illuminate\Database\Eloquent\Model |
||||||
39 | */ |
||||||
40 | 1 | public function refresh() |
|||||
41 | { |
||||||
42 | 1 | if (!$this->exists) { |
|||||
43 | return $this; |
||||||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||||||
44 | } |
||||||
45 | |||||||
46 | 1 | $this->setRawAttributes( |
|||||
0 ignored issues
–
show
It seems like
setRawAttributes() 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
![]() |
|||||||
47 | 1 | static::newQueryWithoutScopes()->findOrFail($this->getKey())->attributes |
|||||
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
![]() |
|||||||
48 | ); |
||||||
49 | |||||||
50 | $this->load(Collection::make($this->relations)->reject(function ($relation) { |
||||||
0 ignored issues
–
show
It seems like
load() 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
![]() |
|||||||
51 | return $relation instanceof Pivot; |
||||||
52 | 1 | })->keys()->all()); |
|||||
53 | |||||||
54 | 1 | $this->syncOriginal(); |
|||||
0 ignored issues
–
show
It seems like
syncOriginal() 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
![]() |
|||||||
55 | |||||||
56 | 1 | return $this; |
|||||
0 ignored issues
–
show
|
|||||||
57 | } |
||||||
58 | } |
||||||
59 |