From 735e323cd6da87491802ce8d280f6328a4af07ea Mon Sep 17 00:00:00 2001 From: alexvenga Date: Fri, 3 Feb 2023 04:55:01 +0300 Subject: [PATCH] Update SettingGroupResource.php.stub --- .../Resources/SettingGroupResource.php.stub | 39 ++++--------------- 1 file changed, 7 insertions(+), 32 deletions(-) diff --git a/stubs/MoonShine/Resources/SettingGroupResource.php.stub b/stubs/MoonShine/Resources/SettingGroupResource.php.stub index 0817fc2..2d0d5e0 100644 --- a/stubs/MoonShine/Resources/SettingGroupResource.php.stub +++ b/stubs/MoonShine/Resources/SettingGroupResource.php.stub @@ -4,21 +4,18 @@ namespace App\MoonShine\Resources; use Illuminate\Database\Eloquent\Model; -use Illuminate\Validation\Rule; -use Leeto\MoonShine\Fields\BelongsTo; use Leeto\MoonShine\Fields\Date; use Leeto\MoonShine\Fields\Text; -use Leeto\MoonShine\Filters\BelongsToFilter; use Leeto\MoonShine\Resources\Resource; use Leeto\MoonShine\Fields\ID; use Leeto\MoonShine\Actions\FiltersAction; -use VI\LaravelSiteSettings\Models\Setting; +use VI\LaravelSiteSettings\Models\SettingGroup; class SettingGroupResource extends Resource { - public static string $model = Setting::class; + public static string $model = SettingGroup::class; - public static string $title = 'Settings'; + public static string $title = 'Settings groups'; public string $titleField = 'slug'; @@ -26,14 +23,8 @@ class SettingGroupResource extends Resource { return [ ID::make()->sortable(), - BelongsTo::make( - 'Group', - 'settingGroup', - new SettingGroupResource() - )->nullable()->sortable(), Text::make('Slug', 'slug')->required()->sortable()->hint('a-z, 0-9, -, _'), Text::make('Hint', 'hint')->nullable()->sortable()->hint('Не используется на сайте, только для удобства администрирования!'), - Text::make('Value', 'value')->required()->sortable(), Date::make('Updated at', 'updated_at')->sortable()->hideOnForm(), ]; } @@ -41,35 +32,19 @@ class SettingGroupResource extends Resource public function rules(Model $item): array { return [ - 'setting_group_id' => 'nullable|exists:setting_groups,id', - 'slug' => [ - 'required', - 'max:190', - 'regex:/^([a-z0-9\-\_]+)$/i', - 'unique:setting_groups,slug', - Rule::unique('settings','slug')->where(function ($query) use ($item) { - return $query->where('id','!=', $item->getKey()) - ->where('setting_group_id', $item->setting_group_id); - }), - ], - 'hint' => 'nullable|max:190', - 'value' => 'required|max:190', + 'slug' => 'required|max:190|regex:/^([a-z0-9\-\_]+)$/i|unique:setting_groups,slug,' . $item->getKey(), + 'hint' => 'nullable|max:190', ]; } public function search(): array { - return ['id', 'slug', 'hint', 'value']; + return ['id', 'slug', 'hint']; } public function filters(): array { - return [ - BelongsToFilter::make( - 'Group', - 'settingGroup' - ), - ]; + return []; } public function actions(): array