Support the ongoing development of Laravel.io →
Eloquent Views Blade
Last updated 1 year ago.
0

@smardoox Try eager loading your data first.

$quest = Question::with('users')->where('solved', '=', 0)->orderBy('id')->paginate(4);
0

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();

Error

FatalErrorException in Questions_controller.php line 23: Class 'App\Http\Controllers\App\Question' not found

Last updated 8 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

smardoox smardoox Joined 15 Sep 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.