When using the compact() function you don't need to pass through the dollar symbol ($) too — it's possible your data isn't getting through to the view at all.
Remove the dollar symbol:
compact('miRec')
how i can send null data or default value of data from controller here is my code Controller
public function recruiterDet()
{
$auth = Auth::User()->id;
$miRec = Recruiters::where('userid',$auth)->first();
if(!empty($miRec))
{
return view('RcDetailMainpage',compact('miRec'));
}
here i m try to fill some default value so i can foreach it in blade
else{
$miRec = collect([['cmpname'=>NULL,'Address'=>NULL],]);
return view('RcDetailMainpage',compact('miRec'));
}
}
Blade View
@foreach($miRec as $a)
<input type="text" class="form-control" id="cmpname" name="cmpname" value="{{ $a->cmpname }}">
<input type="text" class="form-control" id="Address" name="Address" value="{{ $a->Address }}">
<input type="submit" value="Update">
@endforeach
i don't want to use if else condition in blade because i have lots of form if i use if else then it will increase 2 time in size in blade
Please or to participate in this conversation.