@smardoox Try eager loading your data first.
$quest = Question::with('users')->where('solved', '=', 0)->orderBy('id')->paginate(4);
when i try
$quest = Question::with('users')->get();
@foreach ($Questions as $quest)
<li>{!! e($quest->question)!!} by {!! $quest->users()->username !!}</li>
@endforeach
it give me this error
ErrorException in 9147a78619da981c7a202282ec3f8d84 line 38: Undefined property: Illuminate\Database\Eloquent\Relations\BelongsTo::$username (View: C:\xampp\htdocs\mysnapy\resources\views\questions\index.blade.php)
$quest = App\Question::with('users')->get();
FatalErrorException in Questions_controller.php line 23: Class 'App\Http\Controllers\App\Question' not found
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community