Support the ongoing development of →
Database Eloquent
Last updated 2 years ago.

You question is slightly confusing as I don't know what the other table is outside User. You first need to figure out the type of relationship between user table and the other.

Check documentation for an example -



I tryed

public function GetUser(){ return $this->belongsTo(Usuario::class, 'id_usuarios', 'fk_usuarios'); }

and into view have this code:

@if (count($user->GetUser) > 0) @foreach($user->GetUser AS $us) de [ {{ $us->nombre_usuarios }} ] @endforeach @endif

What I do wrong?

The error: Trying to get property of non-object (View: F:\Fnt\Web\Economato\Fuentes\resources\views\welcome.blade.php)

Last updated 7 years ago.

Sign in to participate in this thread!


Your banner here too?

paucurro paucurro Joined 30 Aug 2016


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.