I was trying to do a query in my routes for the view composer to load all the records and count it and display it in my sidebar for purposes.
I think there is no problem with the query since it worked in my shell using the php artisan tinker for testing purposes of the query.
But I got this error when I try to do it in my routes and pass it to the menu.blade.php
Here is the code in my routes with the view composer function.
// Menu View for Microbiologist
View::composer('microbiologist-dashboard.layouts.menu', function($view)
{
$view->with('counts', [
'microbiologist_task' => App\Models\AnalysisRequest::where('status', 'under_analyzation')
->whereHas('actors', function ($query) {
$microbiologist = Auth::guard('microbiologist')->user()->id;
$query->where('microbiologist_id', $microbiologist)->count();
})
]);
});
and here is the code in my menu.blade.php
<span class="pull-right-container">
@if($counts['microbiologist_task'])
<small class="label pull-right bg-yellow"></small>
@else
@endif
</span>
Here is the screenshot of the error.
is there something wrong with the config of my project about UTF-8? or should I use some helpers. Thanks btw I am using Laravel 5.5
Appreciate if someone could help. Thanks in advance.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire