In my view tests.index is it possible to open my route tests.show by clicking in a select dropdown where datas comes from database ?
My controller :
public function index(Request $request)
{
$tests = DB::table('test')->distinct()->get();
return view('tests.index')->with('tests', $tests);
}
public function show($id)
{
$test = Test::findOrFail($id);
return view('tests.show', compact('test'));
}
My view index :
<select id="apports" type="dropdown-toggle" class="form-control" name="apports" onchange="">
<option value="choisir" selected disabled>Choisir</option>
@foreach($tests as $test)
<option class="apports" value=""></option>
@endforeach
When I put my route here : onchange
I get the error "Undefined variable: test" when I add a button below the select like that :
<a class="btn btn-small btn-success" href="">Show</a>
I get always the last id of the table...
I would prefer not have a button, just when I change value in the select, return tests.show... Is someone could help me please ?
via ginette