Support the ongoing development of →
Database Views
Last updated 2 years ago.

Hi there! That's probably not the way you want to use filters. Let's take a look on what the docs say about filters

Route filters provide a convenient way of limiting access to a given route, which is useful for creating areas of your site which require authentication.

You would like to see route filters as a way to control access to your routes and not as a way to process tasks related to your business logic.

What you are probably seeking for is View::share(). This method allows you to share data across all of your views.

$sys_message = DB::table('u_message')->where('uid','=','0')->get();
View::share('sys_message', $sys_message);

That's one way to make your data available in all of your views.

However, a much cleaner way would be for example using controllers with inheritance. But for smaller projects you can stick to View::share() without hesitation.

Happy Coding!

Last updated 2 years ago.

thank you

Last updated 2 years ago.

Sign in to participate in this thread!


Your banner here too?

qq277049 qq277049 Joined 12 Feb 2014


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.