To make the page_help setting globally available in all your Blade views, you can share the setting with all views using a view composer or a service provider. Here's how you can do it using a service provider:
-
Open the
AppServiceProvideror create a new service provider (e.g.,SettingsServiceProvider). -
In the
bootmethod of your service provider, use theviewfacade to share thepage_helpsetting with all views.
Here's an example using the AppServiceProvider:
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\View;
use App\Settings\GeneralSettings;
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
// Share the 'page_help' setting with all views
View::composer('*', function ($view) {
$settings = app(GeneralSettings::class);
$view->with('page_help', $settings->page_help);
});
}
// ...
}
After adding this code to your service provider, the page_help variable will be available in all your Blade templates. You can then use it to conditionally display the block of text like this:
@if($page_help)
<small>
This is the "Posts Index." Here you can search for and read and post that has not been expired. Expired posts will not show up in the search results.
You can search the title and body.
</small>
@endif
Make sure that your service provider is registered in the config/app.php file under the providers array if you are creating a new one.
This way, you can easily control the visibility of the help text block across all your views by updating the page_help setting in your GeneralSettings.