style updates
This commit is contained in:
@@ -6,6 +6,8 @@ namespace Modules\Helpdesk\Livewire;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -824,9 +826,11 @@ final class SettingsManager extends Component
|
||||
* which made every new Helpdesk settings CRUD form appear to do nothing.
|
||||
*
|
||||
* @template TModel of \Illuminate\Database\Eloquent\Model
|
||||
* @param class-string<TModel> $modelClass
|
||||
* @param int|string|null $id
|
||||
* @param array<string, mixed> $data
|
||||
*
|
||||
* @param class-string<TModel> $modelClass
|
||||
* @param int|string|null $id
|
||||
* @param array<string, mixed> $data
|
||||
*
|
||||
* @return TModel
|
||||
*/
|
||||
private function persistSettingModel(string $modelClass, int|string|null $id, array $data): object
|
||||
@@ -847,7 +851,7 @@ final class SettingsManager extends Component
|
||||
$model = $modelClass::query()->create($data);
|
||||
|
||||
return $model;
|
||||
} catch (\Illuminate\Database\QueryException $exception) {
|
||||
} catch (QueryException $exception) {
|
||||
throw ValidationException::withMessages([
|
||||
'settings' => 'The record could not be saved. Check the slug is unique for this section/company and try again.',
|
||||
]);
|
||||
@@ -857,7 +861,7 @@ final class SettingsManager extends Component
|
||||
/**
|
||||
* Clear the default flag on every other record without generating invalid null-id SQL.
|
||||
*
|
||||
* @param class-string<\Illuminate\Database\Eloquent\Model> $modelClass
|
||||
* @param class-string<Model> $modelClass
|
||||
*/
|
||||
private function clearOtherDefaults(string $modelClass, int|string|null $currentId, int|string|null $companyId = null): void
|
||||
{
|
||||
@@ -867,7 +871,7 @@ final class SettingsManager extends Component
|
||||
$query->whereKeyNot((int) $currentId);
|
||||
}
|
||||
|
||||
if (Schema::hasColumn((new $modelClass())->getTable(), 'company_id')) {
|
||||
if (Schema::hasColumn((new $modelClass)->getTable(), 'company_id')) {
|
||||
$query->where('company_id', filled($companyId) ? (int) $companyId : null);
|
||||
}
|
||||
|
||||
@@ -881,7 +885,7 @@ final class SettingsManager extends Component
|
||||
* nullable integer and exists rules expect a real null, so normalising here
|
||||
* keeps every settings CRUD form usable from the browser.
|
||||
*
|
||||
* @param array<int, string> $keys
|
||||
* @param array<int, string> $keys
|
||||
*/
|
||||
private function normalizeNullableFormValues(string $formProperty, array $keys): void
|
||||
{
|
||||
@@ -906,7 +910,8 @@ final class SettingsManager extends Component
|
||||
/**
|
||||
* Remove is_default before save when the database has not been migrated yet.
|
||||
*
|
||||
* @param array<string, mixed> $data
|
||||
* @param array<string, mixed> $data
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function guardDefaultColumn(string $table, array $data): array
|
||||
|
||||
Reference in New Issue
Block a user