Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Http/Controllers/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __invoke(RestifyRequest $request)
$meta = [];

if (method_exists($user, 'profile')) {
$meta = (array)call_user_func([$user, 'profile'], $request);
$meta = (array) call_user_func([$user, 'profile'], $request);
}

return $this->response()
Expand All @@ -41,12 +41,12 @@ public function guessRepository(RestifyRequest $request): ?Repository
{
$repository = $request->repository('users');

if (!$repository) {
if (! $repository) {
return null;
}

if (method_exists($repository, 'canUseForProfile')) {
if (!call_user_func([$repository, 'canUseForProfile'], $request)) {
if (! call_user_func([$repository, 'canUseForProfile'], $request)) {
return null;
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/Services/Search/RepositorySearchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ public function prepareMatchFields(RestifyRequest $request, $query, $extra = [])
foreach ($this->repository->getMatchByFields() as $key => $type) {
$negation = false;

if ($request->has('-' . $key)) {
if ($request->has('-'.$key)) {
$negation = true;
}

if (!$request->has($negation ? '-' . $key : $key) && !data_get($extra, "match.$key")) {
if (! $request->has($negation ? '-'.$key : $key) && ! data_get($extra, "match.$key")) {
continue;
}

$match = $request->input($negation ? '-' . $key : $key, data_get($extra, "match.$key"));
$match = $request->input($negation ? '-'.$key : $key, data_get($extra, "match.$key"));

if ($negation) {
$key = Str::after($key, '-');
Expand Down Expand Up @@ -76,7 +76,7 @@ public function prepareMatchFields(RestifyRequest $request, $query, $extra = [])
case RestifySearchable::MATCH_INTEGER:
case 'number':
case 'int':
$query->where($field, $negation ? '!=' : '=', (int)$match);
$query->where($field, $negation ? '!=' : '=', (int) $match);
break;
case RestifySearchable::MATCH_DATETIME:
$query->whereDate($field, $negation ? '!=' : '=', $match);
Expand Down Expand Up @@ -114,7 +114,7 @@ public function prepareOrders(RestifyRequest $request, $query, $extra = [])
}

if (empty($params) === true) {
$this->setOrder($query, '+' . $this->repository->newModel()->getKeyName());
$this->setOrder($query, '+'.$this->repository->newModel()->getKeyName());
}

return $query;
Expand Down Expand Up @@ -158,7 +158,7 @@ public function prepareSearchFields(RestifyRequest $request, $query, $extra = []
$likeOperator = $connectionType == 'pgsql' ? 'ilike' : 'like';

foreach ($this->repository->getSearchableFields() as $column) {
$query->orWhere($model->qualifyColumn($column), $likeOperator, '%' . $search . '%');
$query->orWhere($model->qualifyColumn($column), $likeOperator, '%'.$search.'%');
}
});

Expand Down Expand Up @@ -211,12 +211,12 @@ public function setOrder($query, $param)

protected function applyIndexQuery(RestifyRequest $request, Repository $repository)
{
return fn($query) => $repository::indexQuery($request, $query->with($repository::$with));
return fn ($query) => $repository::indexQuery($request, $query->with($repository::$with));
}

protected function applyFilters(RestifyRequest $request, Repository $repository, $query)
{
if (!empty($request->filters)) {
if (! empty($request->filters)) {
$filters = json_decode(base64_decode($request->filters), true);

collect($filters)
Expand All @@ -242,7 +242,7 @@ protected function applyFilters(RestifyRequest $request, Repository $repository,
return $matchingFilter;
})
->filter()
->each(fn(Filter $filter) => $filter->filter($request, $query, $filter->value));
->each(fn (Filter $filter) => $filter->filter($request, $query, $filter->value));
}

return $query;
Expand Down