How to showing data on blade with pass through 2 table FK

Posted 1 month ago by adhik13th

I have 3 table like users , data_users , practice

users      : id , name ,dob ,email , etc . . .

data_users : id , user_id , number_exp , etc . .

practice   : id , data_user_id , practice_number , etc ....

in 3 tables connect by relation belongsTo and and want to showing this . i want to show data on table practice :

My controller :

public function show()
    $practice= Practice::with('data_users')->get();

    return view('admin.practice' ,['practice'=>$practice]);

my view

 <table class="table table-bordered">
                  <th>No Surat</th>
                @foreach ($practice as $i)
                  <th scope="row">1</th>
                  <td>{{ $i->data_users->users->name}}</td>//i want to show name but i cant show this
                  <td>{{ $i->practice_number}}</td>
                  <td>{{ $i->practice_date}}</td>
                  <td>{{ $i->status}}</td>

i have problem to showing Data 'NAME' form table users , and i just can showing id from data_users

but still error Trying to Get property

Please sign in or create an account to participate in this conversation.