mardi 28 août 2018

How to show name from id using relationship in laravel 5.6?

I want to show rta name in the table, but it gives me error

Issuer Model Function

public function rtalist(){
    return $this->belongsTo('App\RTAList','rta_id','id');
}

RTAList Model

protected $table = 'rta_list';
protected $fillable = ['rta_name','dp_type','rta_address','rta_phone','rta_email','dp_status','setup_date'];

Code in Issuer Controller

 $data = Issuer::with('rtalist')->get();
    return view('admin.issuer.view_all_issuer')->with(compact('data'));

In view_issuer.blade.php

  <td style="text-transform: uppercase;"></td>

But it gives me this error SQLSTATE[42S22]: Column not found: 1054 Unknown column 'rta_list.id' in 'where clause' (SQL: select * from rta_list where rta_list.id in (3, 4))

How to solve this problem and show name instead of id..



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire