You see, I'm using combobox for the first time in a Laravel form.
I have this model:
Schema::create('fotos', function(Blueprint $table){
$table->increments('id');
$table->string('foto');
$table->string('nombre')->unique();
$table->date('fecha');
$table->unsignedInteger('categoria_id'); // Forarea de Categoria.
$table->foreign('categoria_id')->references('id')->on('categorias');
$table->unsignedInteger('user_id'); // Foranea de User.
$table->foreign('user_id')->references('id')->on('users');
$table->timestamps();
});
For what interests me we take the variable categoria_id
, which is foreign from another table called Category.
I have this code snippet:
<div class="form-group row">
<label for="categoria_id" class="col-md-4 col-form-label text-md-right">Categoría de la foto</label>
<div class="col-sm-6">
<select name="categoria_id" class="form-control">
@foreach($categorias as $categoria)
<option value="{{ $categoria->id }}">{{$categoria->nombre}}</option>
@endforeach
</select>
</div>
</div>
Which gives me this:
The combobox works, but let's imagine that I'm trying to modify an existing photo. I want the form to show what the current value of the photo is. How do I achieve that?