Hi I am still learning and would just like to ask how I would refactor the following?
$properties = Property::latest()->take(18)->get();
$locations = Location::pluck('name','id')->all();
$types = Type::pluck('name','id')->all();
I don't want to have to include those three lines in every function of my controller for different views, how to I go about setting it up once and then using it where I see fit?
Thanks in advance for any answers.
You could create a base controller and extend each controller from it or you could use a ServiceProvier to share your data globally: https://laravel.com/docs/5.4/views#passing-data-to-views
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community