In my PHP code, I noticed that I can access my value only with a foreach. Can anyone explain why?
return view('pages.temp_page_course', [
'page' => $this->course($slug),
]);
public function course($slug)
{
$course = Course::where('slug', $slug)->get();
return $course;
}
With this code, I can access the value.
@foreach($page as $key => $course)
{{ $course->title }}
@endforeach
How do I access the value without doing a foreach?
Thank you very much
course()?