updated add new category modal

This commit is contained in:
Cihan Şentürk 2026-03-12 00:30:50 +03:00
parent 1789662440
commit 91f1956dc9
2 changed files with 16 additions and 11 deletions

View File

@ -87,9 +87,7 @@ class Categories extends Controller
$type_codes = []; $type_codes = [];
foreach (config('type.category') as $type => $config) { foreach (config('type.category') as $type => $config) {
$show_code = empty($config['hide']) || ! in_array('code', $config['hide']); $type_codes[$type] = empty($config['hide']) || ! in_array('code', $config['hide']);
$type_codes[$type] = $show_code;
$categories[$type] = []; $categories[$type] = [];
} }
@ -175,9 +173,7 @@ class Categories extends Controller
$type_codes = []; $type_codes = [];
foreach (config('type.category') as $type => $config) { foreach (config('type.category') as $type => $config) {
$show_code = empty($config['hide']) || ! in_array('code', $config['hide']); $type_codes[$type] = empty($config['hide']) || ! in_array('code', $config['hide']);
$type_codes[$type] = $show_code;
$categories[$type] = []; $categories[$type] = [];
} }

View File

@ -2,18 +2,20 @@
<div class="grid sm:grid-cols-6 gap-x-8 gap-y-6 my-3.5"> <div class="grid sm:grid-cols-6 gap-x-8 gap-y-6 my-3.5">
<x-form.group.text name="name" label="{{ trans('general.name') }}" form-group-class="col-span-6" /> <x-form.group.text name="name" label="{{ trans('general.name') }}" form-group-class="col-span-6" />
@if ($has_code)
<x-form.group.text name="code" label="{{ trans('general.code') }}" form-group-class="col-span-6" />
@endif
<x-form.group.color name="color" label="{{ trans('general.color') }}" form-group-class="col-span-6" /> <x-form.group.color name="color" label="{{ trans('general.color') }}" form-group-class="col-span-6" />
<x-form.group.select name="parent_id" label="{{ trans('general.parent') . ' ' . trans_choice('general.categories', 1) }}" :options="$categories" not-required sort-options="false" searchable form-group-class="col-span-6" /> <x-form.group.select name="parent_id" label="{{ trans('general.parent') . ' ' . trans_choice('general.categories', 1) }}" :options="$categories" not-required sort-options="false" searchable form-group-class="col-span-6" />
@if (!empty($types) && count($types) > 1) @if (!empty($types) && count($types) > 1)
<x-form.group.select name="type" label="{{ trans_choice('general.types', 1) }}" :options="$types" value="{{ $type }}" form-group-class="col-span-6" /> <x-form.group.select name="type" label="{{ trans_choice('general.types', 1) }}" :options="$types" value="{{ $type }}" form-group-class="col-span-6" change="changeCategories" />
<x-form.group.text name="code" label="{{ trans('general.code') }}" form-group-class="col-span-6" v-show="show_code_field" />
@else @else
<x-form.input.hidden name="type" value="{{ $type }}" /> <x-form.input.hidden name="type" value="{{ $type }}" />
@if ($show_code_field)
<x-form.group.text name="code" label="{{ trans('general.code') }}" form-group-class="col-span-6" />
@endif
@endif @endif
<x-form.group.textarea name="description" label="{{ trans('general.description') }}" not-required /> <x-form.group.textarea name="description" label="{{ trans('general.description') }}" not-required />
@ -21,3 +23,10 @@
<x-form.input.hidden name="enabled" value="1" /> <x-form.input.hidden name="enabled" value="1" />
</div> </div>
</x-form> </x-form>
<script type="text/javascript">
if (typeof type_codes === 'undefined') {
var type_codes = {!! json_encode($type_codes) !!};
}
</script>