Support the ongoing development of Laravel.io →
Database Views
Last updated 1 year ago.
0

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 1 year ago.
0

thank you

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

qq277049 qq277049 Joined 12 Feb 2014

Moderators

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

Your logo here?

Laravel.io

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

© 2024 Laravel.io - All rights reserved.