query builder select DISTINCT id,file_no,registration_date_ad,registration_date_bs from building
this is my query.
i have databse with table building.i want to get the specified fields data in view page in table form.
please help me with controller and blade.php
You might need something like this?
Controller
public function index() {
$buildings = DB::table('building')->
select('id','file_no','registration_date_ad','registration_date_bs')->distinct()->get();
return view('buildings.index',compact('buildings'));
}
Blade
@foreach ($buildings as $building)
{{ $building->id }}
{{ $building->file_no}}
{{ $building->registration_date_ad}}
{{ $building->registration_date_bs }}
@endforeach
thanks sir,but i want to display it in table form...any idea since itcame in gathered form
much much thanks sir,i did it..... was stucked in it
You mean tabular form in blade?
<table>
<thead>
<tr>
<th>Id</th>
<th>File No</th>
<th>Registration Date ad</th>
<th>Registration Date bs</th>
</tr>
</thead>
<tbody>
@foreach ($buildings as $building)
<tr>
<td>{{ $building->id }}</td>
<td>{{ $building->file_no}}</td>
<td>{{ $building->registration_date_ad}}</td>
<td>{{ $building->registration_date_bs }}</td>
</tr>
@endforeach
</tbody>
</table>
Please sign in or create an account to participate in this conversation.