Are you sure there is data? Try to dd the results and make sure you have data.
Dec 20, 2022
7
Level 41
it's made me mad !! Undefined variable $consultants
This bad error always comes with me and really I wonder what is the wrong
Route::get('/instructors/consultant', [Frontend\ConsultantController::class, 'index'])->name('instructors.partial.consultant');
class ConsultantController extends Controller
{
public function index()
{
$consultants = Consultant::with('user')->latest()->get();
return view('instructors.partial.consultant', compact('consultants'));
}
}
<section class="department-section-two style-two">
@foreach($consultants as $consultant)
<div class="auto-container">
<div class="sec-title centered">
<h2>Consultant Department</h2>
<div class="separator"></div>
</div>
<div class="three-item-carousel owl-carousel owl-theme">
<!-- Department Block Two -->
<div class="department-block-two">
<div class="inner-box">
<div class="image">
<a href="blog-single.html"><img src="{{asset ('Theme/images/resource/department-1.jpg')}}" alt="" /></a>
</div>
<div class="lower-content">
<h3><a href="blog-single.html">{{ $consultant->title }}</a></h3>
<div class="text">{{ $consultant->description }}</div>
<div>
<p>{{ $consultant->price }}</p>
<p>{{ $consultant->created_at->diffForHumans() }}</p>
</div>
<a href="blog-single.html" class="read-more">Read More <span class="arrow fas fa-angle-double-right"></span></a>
</div>
</div>
</div>
</div>
</div>
@endforeach
</section>
what's wrong in my code please
Please or to participate in this conversation.