I want to display the name of a user alongside his notes. I have two models the user and the Notes Model. The Notes Model has the id of the user and the relationship is good. How do I fech the name of a user using their id in the view?
I have used plain php between the tags
<div class="card-body">
<div class="d-flex justify-content-center">
<span><strong><?php $userid=$note->user_id;
$user = App\User::find($userid);
$name = $user->name;
echo $name;?>:::</strong></span>
<span class="success"></span>
</div>
<div class="form-panel"> {!! html_entity_decode($note->note_body)!!}</div>
</div>
@endforeach```
Am getting the correct name but I guess thats not the correct way in laravel
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/35y5zwM
via IFTTT
Aucun commentaire:
Enregistrer un commentaire