我想更新 laravel 中 cms 的设置形式。
问题:我的列只有option_name和value
如何解决存储数据的输入名称问题?
使用数组作为输入名称?
移民:
Schema::create('settings', function (Blueprint $table) {
$table->id();
$table->string('option_name');
$table->longText('value');
$table->timestamps();
});
设置.blade.php
<form action="{{ route('setting.update', [ 'settings' => $value]) }}" method="POST">
@csrf
@method('PUT')
<input name="value" value="{{ $settings->find(1)->value }}" type="text">
@error('value') <p class="customized-errors">{{ $message }}</p> @enderror
<input name="value" value="{{ $settings->find(2)->value }}" type="text">
@error('value') <p class="customized-errors">{{ $message }}</p> @enderror
<input name="value" value="{{ $settings->find(6)->value }}" type="text">
@error('value') <p class="customized-errors">{{ $message }}</p> @enderror
<input name="value" {{ (($settings->find(3)->value) == 1)? 'checked' : '' }} type="checkbox" class="filled-in chk-col-primary" id="checkbox2">
<label class="col-10 col-form-label text-label lable-customized text-cu"> کاربران می توانند نام نویسی کنند </label>
<input name="value" {{ (($settings->find(4)->value) == 1)? 'checked' : '' }} checked type="checkbox" class="filled-in chk-col-primary" id="checkbox2">
<label class="col-10 col-form-label text-label lable-customized text-cu"> کاربران می توانند دیدگاه های خود را ثبت کنند </label>
</form>
开满天机