You are putting the name attribute to the div it should be to the select element:
<select class="form-control" name="size">
And for the field type in the Database it does not matter much.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Right now, I am trying to store value from select option form into my database, how can I achieve this? And are they any difference if I'm using type enum or integer in schema for input form select option?
(create.blade.php)
<div class="form-group">
<label>Type</label>
<select class="form-control" name="type">
<option selected>Pick Type</option>
<option value="swiss">Swiss System</option>
<option value="single">Single Elimination</option>
<option value="double">Double Elimination</option>
</select>
<small class="form-text text-muted">Your tournament type</small>
</div>
<div class="form-group" name="size">
<label>Participant</label>
<select class="form-control">
<option selected>Pick Size</option>
<option value="2">2</option>
<option value="4">4</option>
<option value="8">8</option>
<option value="16">16</option>
<option value="32">32</option>
</select>
<small class="form-text text-muted">Your tournament size</small>
</div>
(postcontroller@store)
public function store(Request $request)
{
$this->validate($request, [
'type' => 'required',
'size' => 'required',
]);
$post = new Post();
$post->user_id = auth()->user()->id;
$post->type = $request->input('type');
$post->size = $request->input('size');
$post->save();
return redirect('/posts')->with('success', 'Post Created');
}
(schema)
Schema::create('posts', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('user_id');
$table->string('type');
$table->string('size');
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
You are putting the name attribute to the div it should be to the select element:
<select class="form-control" name="size">
And for the field type in the Database it does not matter much.
Please or to participate in this conversation.