Retrieved value from the MySQL database using
@foreach($entity as $key => $value)
{{ $value->firstname }}
@endforeach
Controller code is like
public function showSearch()
{
$entity = DB::select('SELECT * FROM table WHERE status = ? ', array('active'));
return View::make('pages/home/search')->with('entity',$entity);
}
How to check if the value is null or not, before displaying it.
I'm kind of new here, and not professional. Still, i look for solutions for me, and when i find i can, i help!
Got a little confused, maybe try to remember
foreach($entity as $a=> $b)
{
echo $a; // = "<fieldmame>" (name)
echo $b; // = <value> (john)
}
foreach($entity as $a)
echo $a; // = <value> (john);
then, doing blade you can also decide with if cycle
@foreach($entity as $key => $value)
@if ($something)
<p>Something is true! {{ $variable }} </p>
@else
<p>Something is false!</p>
@endif
@endforeach
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community