Instead of creating multiple slider components for each section in your template, consider creating a single slider component and passing it the data source as a prop. You can then use Axios or VueResource to fetch data from that source. Here's an example:
//test.blade.php
<div id="app">
<slider-component :source="{{$source}}"></slider-component>
</div>
//$source is a variable passed to the blade view, representing the endpoint to fetch data from
Here's how you can fetch data in your slider component:
//slider component
<template>
//your html goes here
</template>
<script>
export default {
props : ['source'],
data(){
return {
items : [],
}
},
created(){
axios.post(this.source , {
//request body
})
.then(res => {
//handle the request and assign items the response body
})
.catch(err => {
//error handling
});
}
}
</script>
This way, you have a customizable slider component that can fetch data from any source.
In Laravel, create endpoints in routes/web.php
like this:
//routes/web.php
Route::get('/products/hot-deals" , "ProductController@hotDeals");
And in the Product Controller:
use App\Models\Product;
class ProductController extends Controller {
public function hotDeals(){
//query your product model to select the hot-deals items
return Product::where('price' , '<=' , 100);
}
}
Hope this helps, good luck!