for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Staudenmeir\EloquentJsonRelations\Relations\Postgres;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Query\Expression;
use Staudenmeir\EloquentJsonRelations\Casts\Uuid;
trait IsPostgresRelation
{
/**
* Get the wrapped and cast JSON column.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $column
* @param string $key
* @return \Illuminate\Database\Query\Expression
*/
protected function jsonColumn(Builder $query, Model $model, $column, $key)
$sql = $query->getQuery()->getGrammar()->wrap($column);
if ($model->getKeyName() === $key && in_array($model->getKeyType(), ['int', 'integer'])) {
$sql = '('.$sql.')::bigint';
}
if ($model->hasCast($key) && $model->getCasts()[$key] === Uuid::class) {
$sql = '('.$sql.')::uuid';
return new Expression($sql);
* Get the name of the "where in" method for eager loading.
* @return string
protected function whereInMethod(Model $model, $key)
$model
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
protected function whereInMethod(/** @scrutinizer ignore-unused */ Model $model, $key)
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
$key
protected function whereInMethod(Model $model, /** @scrutinizer ignore-unused */ $key)
return 'whereIn';
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.