Issues (19)

Concerns/ChronosInteractsWithPivotTable.php (2 issues)

Labels
Severity
1
<?php
2
3
namespace Cino\LaravelChronos\Eloquent\Concerns;
4
5
use Illuminate\Database\Eloquent\Relations\Pivot;
6
7
trait ChronosInteractsWithPivotTable
8
{
9
    /**
10
     * Get the pivot models that are currently attached.
11
     *
12
     * @return \Illuminate\Support\Collection
13
     */
14 1
    protected function getCurrentlyAttachedPivots()
15
    {
16
        return $this->newPivotQuery()->get()->map(function ($record) {
0 ignored issues
show
It seems like newPivotQuery() 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 ignore-call  annotation

16
        return $this->/** @scrutinizer ignore-call */ newPivotQuery()->get()->map(function ($record) {
Loading history...
17 1
            $class = $this->using ? $this->using : Pivot::class;
18
19 1
            $pivot = $class::fromRawAttributes($this->parent, (array)$record, $this->getTable(), true);
0 ignored issues
show
It seems like getTable() 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 ignore-call  annotation

19
            $pivot = $class::fromRawAttributes($this->parent, (array)$record, $this->/** @scrutinizer ignore-call */ getTable(), true);
Loading history...
20
21 1
            return $pivot->setPivotKeys($this->foreignPivotKey, $this->relatedPivotKey);
22 1
        });
23
    }
24
}
25