I have queried in the blade template in a foreach loop like the way
@foreach ($employees as $employee)
<td></td>
<td>
@php
$project_info = \App\Models\Project::select('title')->find($employee->id);
echo $project_info;
@endphp
</td>
@endforeach
Output: {"title":"Hull 21"} // when echo $project_info;
The problem is that I can not access to the "title" so that "Hull 21" is shown. I have tried the following ways, but no luck.
// way 1
echo $project_info->title;
// way 2
echo $project_info['title'];
Output way 1
Trying to get property 'title' of non-object (View: /home/sajib/Desktop/emp/resources/views/backend/attendee/index.blade.php)
Output way 2
Trying to access array offset on value of type null (View: /home/sajib/Desktop/emp/resources/views/backend/attendee/index.blade.php)
If I debug with dd($project_info->title) then it gives output "Hull 21";
I need to show the project title "Hull 21" for each Employee.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/31Wc38U
via IFTTT
Aucun commentaire:
Enregistrer un commentaire