I’m facing some issues with a project built with Laravel
I want the items in the dropdown menu to be able to display the value I select in the dropdown menu please help me. I’ve tried many solutions but it’s not working.
This is my code inside index.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<form id="update-name-form" method="POST" action="{{ route('items.update') }}">
@csrf
<div class="form-group">
<label for="item">Select Item:</label>
<select id="item" name="item" class="form-control">
@foreach ($items as $item)
<option value="{{ $item->id }}">{{ $item->name }}</option>
@endforeach
</select>
</div>
<div class="form-group">
<label for="new_name">New Name:</label>
<input type="text" id="new_name" name="new_name" class="form-control">
</div>
<button type="submit" class="btn btn-primary">Update</button>
</form>
</div>
@endsection
This is my code inside ItemController.php
public function index()
{
$items = Item::get();
return view('index', compact('items'));
}