You're passing a variable called $results to your view, and then trying to use a variable called $overview.
Aug 4, 2017
3
Level 4
Solved: Undefined variable:
Hello All,
I ran into issues, which causes me a real headache. I guess I'm doing something really stupid, but I cannot find the error.
Its all about Undefined variable: Overview.
The only thing I would like to show is an overview of some results. My resultsController:
/**
*Show overview per user
*/
public function overview()
{
$results = Result::all()->load('user');
$results = $results->where('user_id', '=', Auth::id());
// dd($results);
return view ('users.overview', compact('results'));
}
Outcome of my DD:
Collection {#440 ▼
#items: array:1 [▼
0 => Result {#433 ▼
#fillable: array:4 [▼
0 => "correct"
1 => "date"
** 2 => "user_id" **
3 => "question_id"
]
#connection: null
#table: null
#primaryKey: "id"
#keyType: "int"
#perPage: 15
+incrementing: true
+timestamps: true
#attributes: array:8 [▶]
#original: array:8 [▶]
#relations: array:1 [▶]
#hidden: []
#visible: []
#appends: []
#guarded: array:1 [▶]
#dates: []
#dateFormat: null
#casts: []
#touches: []
#observables: []
#with: []
+exists: true
+wasRecentlyCreated: false
#forceDeleting: false
And My overview.blade.php:
@section('content')
<div class="main-container">
<div class="row background">
<div class="col-xs-12 marge-top">
<h1>Account Overview</h1>
{{ $overview->user_id }}
</div>
</div>
</div>
Unfortunately I receive the mentioned error. I hope someone can help me out
Level 13
Please or to participate in this conversation.