itstructure /
laravel-media-file-uploader
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Itstructure\MFU\Traits; |
||||
| 4 | |||||
| 5 | use Illuminate\Database\Eloquent\Builder; |
||||
| 6 | |||||
| 7 | trait HasCompositePrimaryKey |
||||
| 8 | { |
||||
| 9 | /** |
||||
| 10 | * @param Builder $query |
||||
| 11 | * @return Builder |
||||
| 12 | */ |
||||
| 13 | protected function setKeysForSaveQuery($query) |
||||
| 14 | { |
||||
| 15 | $keys = $this->getKeyName(); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 16 | if(!is_array($keys)){ |
||||
| 17 | return parent::setKeysForSaveQuery($query); |
||||
| 18 | } |
||||
| 19 | |||||
| 20 | foreach($keys as $keyName){ |
||||
| 21 | $query->where($keyName, '=', $this->getKeyForSaveQuery($keyName)); |
||||
| 22 | } |
||||
| 23 | |||||
| 24 | return $query; |
||||
| 25 | } |
||||
| 26 | |||||
| 27 | /** |
||||
| 28 | * @param null $keyName |
||||
|
0 ignored issues
–
show
|
|||||
| 29 | * @return mixed |
||||
| 30 | */ |
||||
| 31 | protected function getKeyForSaveQuery($keyName = null) |
||||
| 32 | { |
||||
| 33 | if(is_null($keyName)){ |
||||
|
0 ignored issues
–
show
|
|||||
| 34 | $keyName = $this->getKeyName(); |
||||
| 35 | } |
||||
| 36 | |||||
| 37 | if (isset($this->original[$keyName])) { |
||||
| 38 | return $this->original[$keyName]; |
||||
| 39 | } |
||||
| 40 | |||||
| 41 | return $this->getAttribute($keyName); |
||||
|
0 ignored issues
–
show
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
Loading history...
|
|||||
| 42 | } |
||||
| 43 | } |