Rammah
Rammah

Reputation: 27

How can I fetch data from database to multiple views in Laravel?

This might be a challenging topic, because I haven't found anything on Google or YouTube.

So I want to fetch data from a database to multiple views/pages in a Laravel application.

An example of this challenge:

A client who is a photographer. He wants website where he can showcase a gallery of his photographs in a gallery page. He also wants to display the latest the photographs on the home page under the title latest images.

He has an admin page where he can upload all his photographs to a database.

If anyone has an idea how to do this, I will appreciate it!

Thanks!

Upvotes: 0

Views: 312

Answers (1)

Thijs
Thijs

Reputation: 1012

There are allot of ways of solving this problem, i would recommend building a gallery component. This component can be used on the home and gallery page.

You can parse the image models to the component see Passing Additional Data To Components https://laravel.com/docs/5.7/blade#components-and-slots.

Upvotes: 1

Related Questions