mardi 24 novembre 2015

can't show result of two columns in blade, laravel 5.1

I am trying to show columns of two tables in my template, but I have not been successful

Template :

@foreach ($LatestSeeker_list_adv as $ads)
    <span>ads id</span><span>{{ $ads->advertise->id }}</span>
    <span>inf id</span><span>{{ $ads->information->id }}</span>
@endforeach

Controller :

public function SeekerLatest()
{
    $LatestSeeker_list = Advertise_Model::with('information')->get();

    return view('Users.Seeker.LatestAds.index',compact('LatestSeeker_list'));
}

Advertise Model :

public function Information()
    {
        return $this->hasOne('App\Information_Model');
    }

Information Model :

public function Advertise()
    {
        return $this->belongsTo('App\Advertise_Model');
    }

advertise migration :

Schema::table('advertise', function($table) {
            $table->foreign('information_id')->references('id')->on('information');
        });

error :

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'information.advertise__model_id' in 'where clause' (SQL: select * from information where information.advertise__model_id in (1, 2))



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire