I am trying to send a lot of stats to my dashboard view but I am having undefined variable errors for all the passed variables.
My controller is
public function index(Request $request)
{
$user = Auth::user();
$company_id = $user->company_id;
$data['emps'] = 600;
$data['docs'] = 500;
// $data['users'] = User::where([
// 'company_id' => $company_id
// ])->get()->count();
$data['recent_docs'] =[];
$data['count'] = 1500;
return view('home', $data);
}
In my view I am trying to access the passed values like this
<div class="col-md-3">
<x-adminlte-info-box
text={{$count}}
title="Documents"
theme="gradient-purple"
icon="fas fa-lg fa-copy text-yellow"
icon-theme="red"
/>
</div>
<div class="col-md-3">
<x-adminlte-info-box
text={{$docs}}
title="Employees"
icon="fas fa-lg fa-users text-primary"
theme="gradient-primary" icon-theme="white"
/>
</div>
2
Answers
There was an issue with the routes file that is fixed. Thankyou Stackoverflow community for being so nice always.
I see that you are using blade component. In the docs there’s information that
So you should use the
$count
in your template like that: