carousel.blade.php
<div class="container">
<div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel">
<div class="carousel-inner">
@foreach($sliders as $key => $slider)
<div class="carousel-item {{$key == 0 ? 'active' : ''}}">
<img class="d-block w-100" src="{{ asset('img/promotion/' . $slider->img) }}" alt="promotion">
</div>
@endforeach
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="visually-hidden">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
</div>
route web.php
Route::get('carousel', [AppHttpControllersCarouselController::class, 'index']);
carouselController.php
namespace AppHttpControllers;
use IlluminateHttpRequest;
class CarouselController extends Controller
{
protected $promotion;
function __construct( AppRepositoriesroda2PromotionRepo $promotion)
{
$this->promotion = $promotion;
}
public function index()
{
$sliders = $this->promotion->getWhereAll(['group_type' => 'R2']);
return view('frontend.carousel', compact('sliders'));
}
}
2
Answers
$this->promotion->getWhereAll(['group_type' => 'R2']) is get PromotionRepo
carousel models
We don’t know what
$this->promotion->getWhereAll(['group_type' => 'R2'])
actually returns, but the return of the index function inside the controller class should be something like