I am having this code in my controller. When i print the variable in view it gives only last row of database table column. How i print all the value as a string on view. Can anyone help please
public function welcome(){
$company_name = DB::table('companies')
->select('company_name')
->get();
return view('welcome',['company_name' => $company_name]);
}
I am trying to access the value in this jquery code
@foreach ($company_name as $company_names)
<script>
$(document).ready(function() {
$("#tags").autocomplete({
source: [
{ value: "{{$company_names->company_name}}", url: "http://localhost:8000/company_profile" },
],
select: function (event, ui) {
window.location = ui.item.url;
}
});
});
</script>
@endforeach