staudenmeir /
eloquent-json-relations
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Staudenmeir\EloquentJsonRelations\Relations\Postgres; |
||||
| 4 | |||||
| 5 | use Illuminate\Database\Eloquent\Builder; |
||||
| 6 | use Illuminate\Database\Eloquent\Model; |
||||
| 7 | use Illuminate\Database\Query\Expression; |
||||
| 8 | use Staudenmeir\EloquentJsonRelations\Casts\Uuid; |
||||
| 9 | |||||
| 10 | trait IsPostgresRelation |
||||
| 11 | { |
||||
| 12 | /** |
||||
| 13 | * Get the wrapped and cast JSON column. |
||||
| 14 | * |
||||
| 15 | * @param \Illuminate\Database\Eloquent\Builder $query |
||||
| 16 | * @param \Illuminate\Database\Eloquent\Model $model |
||||
| 17 | * @param string $column |
||||
| 18 | * @param string $key |
||||
| 19 | * @return \Illuminate\Database\Query\Expression |
||||
| 20 | */ |
||||
| 21 | protected function jsonColumn(Builder $query, Model $model, $column, $key) |
||||
| 22 | { |
||||
| 23 | $sql = $query->getQuery()->getGrammar()->wrap($column); |
||||
| 24 | |||||
| 25 | if ($model->getKeyName() === $key && in_array($model->getKeyType(), ['int', 'integer'])) { |
||||
| 26 | $sql = '('.$sql.')::bigint'; |
||||
| 27 | } |
||||
| 28 | |||||
| 29 | if ($model->hasCast($key) && $model->getCasts()[$key] === Uuid::class) { |
||||
| 30 | $sql = '('.$sql.')::uuid'; |
||||
| 31 | } |
||||
| 32 | |||||
| 33 | return new Expression($sql); |
||||
| 34 | } |
||||
| 35 | |||||
| 36 | /** |
||||
| 37 | * Get the name of the "where in" method for eager loading. |
||||
| 38 | * |
||||
| 39 | * @param \Illuminate\Database\Eloquent\Model $model |
||||
| 40 | * @param string $key |
||||
| 41 | * @return string |
||||
| 42 | */ |
||||
| 43 | protected function whereInMethod(Model $model, $key) |
||||
|
0 ignored issues
–
show
The parameter
$key is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||
| 44 | { |
||||
| 45 | return 'whereIn'; |
||||
| 46 | } |
||||
| 47 | } |
||||
| 48 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.