mardi 8 janvier 2019

How to view cities name if I saved it as ID in laravel?

I have three table: users,interviews & cities.

I am saving city ID's in user table city field. I am trying to fetch users city field in interview's section and i am getting all users data such as name, age, mobile etc. but I'm getting only city ID not city name.

My interview model relationship:

public function User()
    {
        return $this->belongsTo('App\User','user_id');
    }

My controller

public function index()
    {
        $user_id= Auth::user()->id;
        $items= Interviews::where('user_id',$user_id)->where('status','>=',1)->orderBy('id', 'desc')->paginate(10);
        return view('frontend.index',compact('items'));
    }

My view

@foreach($items as $i => $item)
        <!-- Item #1 -->
            <tr>
                    <td><b> </td>
                    <td><b></td> 
                    <td><b> </td>
                    <td><b> </td>

            </tr>                            
@endforeach



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire