I'm trying to display a query in a view. Each result I want to be a submit button that would submit his value when clicked.
In ListController I have this code:
public function index()
{
$tables = DB::table('tables')->select('name')->get();
return view('welcome', compact('tables'));
}
In welcome.blade.php I have:
<form action="{{ route('get_table') }}" method="POST">
{{ csrf_field() }}
@foreach($tables as $data)
<input type="submit" name="tables[]" value="{{ $data }}">
@endforeach
</form>
In routes web.php I have:
Route::get('/', 'ListController@index');
And I get this error:
"htmlspecialchars() expects parameter 1 to be string, object given (View:...welcome.blade.php)"
What am I doing wrong?