php - Laravel: Cannot retrieve an relation -


it seems laravel 4 cannot relation when use ::where() syntax. have:

<?php   // works fine   $questions = auth::user()->questions;    // error   $questions = user::where('profilename', '=', $username)->questions;    // error   $questions = user::where('profilename', '=', $username)->get()->questions; ?> 

the first method works fine, second third not.

these give following error: "undefined property: illuminate\database\eloquent\builder::$questions "

any idea on how can make work? thanks.

try:

$questions = user::where('profilename', '=', $username)->first()->questions; 

relationships works model , not array of models have when use get()


Comments