jeudi 3 décembre 2020

get null value when return eloquent model relation

i use eloquent package in project(i do not use laravel!!) when i return a model relation , the result is null. but i create relation model !! and in mysql is true


in my book model

public function plandtls()
{
    return $this->hasMany('App\Models\plandtls','book_id');
}

and my plandtls

public function book()
{
    return $this->belongsTo('App\Models\book','book_id');
}

and execute query :

public function planList()
{
    $list=plandtls::select()->with('book')->first();
    var_dump($list);
}

finally i get "null" result. please help me!!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire