Fix Laravel Pint formatting
This commit is contained in:
@@ -7,9 +7,7 @@ use Illuminate\Support\Facades\DB;
|
||||
|
||||
class PreferencesCommandService
|
||||
{
|
||||
public function __construct(private PreferencesOptionsService $options)
|
||||
{
|
||||
}
|
||||
public function __construct(private PreferencesOptionsService $options) {}
|
||||
|
||||
public function upsert(int $userId, array $payload): Preferences
|
||||
{
|
||||
@@ -22,6 +20,7 @@ class PreferencesCommandService
|
||||
if ($existing) {
|
||||
$existing->fill($data);
|
||||
$existing->save();
|
||||
|
||||
return $existing->refresh();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,21 +28,23 @@ class PreferencesOptionsService
|
||||
|
||||
public function normalizeStyle(?string $style): ?string
|
||||
{
|
||||
if (!$style) {
|
||||
if (! $style) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$style = trim($style);
|
||||
|
||||
return in_array($style, $this->styleOptions(), true) ? $style : null;
|
||||
}
|
||||
|
||||
public function normalizeMenu(?string $menu): ?string
|
||||
{
|
||||
if (!$menu) {
|
||||
if (! $menu) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$menu = trim($menu);
|
||||
|
||||
return in_array($menu, $this->menuOptions(), true) ? $menu : null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,16 +7,14 @@ use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
|
||||
class PreferencesQueryService
|
||||
{
|
||||
public function __construct(private PreferencesOptionsService $options)
|
||||
{
|
||||
}
|
||||
public function __construct(private PreferencesOptionsService $options) {}
|
||||
|
||||
public function getForUser(int $userId): array
|
||||
{
|
||||
$row = Preferences::query()->where('user_id', $userId)->first();
|
||||
|
||||
$base = $this->options->defaultPreferences();
|
||||
if (!$row) {
|
||||
if (! $row) {
|
||||
return [
|
||||
'preferences' => $base,
|
||||
'options' => $this->optionsPayload(),
|
||||
@@ -35,12 +33,12 @@ class PreferencesQueryService
|
||||
->leftJoin('users', 'users.id', '=', 'user_preferences.user_id')
|
||||
->select('user_preferences.*', 'users.firstname', 'users.lastname', 'users.email');
|
||||
|
||||
if (!empty($filters['user_id'])) {
|
||||
if (! empty($filters['user_id'])) {
|
||||
$query->where('user_preferences.user_id', (int) $filters['user_id']);
|
||||
}
|
||||
|
||||
if (!empty($filters['q'])) {
|
||||
$term = '%' . strtolower(trim((string) $filters['q'])) . '%';
|
||||
if (! empty($filters['q'])) {
|
||||
$term = '%'.strtolower(trim((string) $filters['q'])).'%';
|
||||
$query->where(function ($q) use ($term) {
|
||||
$q->whereRaw('LOWER(users.firstname) LIKE ?', [$term])
|
||||
->orWhereRaw('LOWER(users.lastname) LIKE ?', [$term])
|
||||
@@ -53,7 +51,7 @@ class PreferencesQueryService
|
||||
$allowedSorts = ['updated_at', 'created_at', 'user_id'];
|
||||
|
||||
if (in_array($sortBy, $allowedSorts, true)) {
|
||||
$query->orderBy('user_preferences.' . $sortBy, $sortDir);
|
||||
$query->orderBy('user_preferences.'.$sortBy, $sortDir);
|
||||
} else {
|
||||
$query->orderBy('user_preferences.updated_at', 'desc');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user