Reputation: 362
I'm working on a website and I have a layout for at least 20 services which are only different in description and image. I'm trying to find a way to implement one layout and add data for a specific link and I don't want to use a database because the data isn't important to save. Is there another way or I have to use 20 blades that extend one layout?
Upvotes: 0
Views: 45
Reputation: 156
You can have an array like this that you will pass to a layout
$servicesLayout = [
'service_1' => [
'description' => 'Service 1 description',
'image' => 'www.host.com/assets/img/section_1.jpg'],
'service_2' => [
'description' => 'Service 2 description',
'image' => 'www.host.com/assets/img/section_2.jpg']
];
Now when viewing a section, you pass the section key for example 'section_1' to the layout
To display section description in layout
{{$servicesLayout['service_1']['description']}}
Upvotes: 1