DeveloperBreeze

Categories In Laravel Development Tutorials, Guides & Insights

Unlock 1+ expert-curated categories in laravel tutorials, real-world code snippets, and modern dev strategies. From fundamentals to advanced topics, boost your categories in laravel skills on DeveloperBreeze.

Leveraging Service Providers to Manage Global Data in Laravel

Tutorial November 16, 2024
php

   namespace App\Http\Controllers;

   use Illuminate\Support\Facades\View;

   class ExampleController extends Controller
   {
       public function index()
       {
           $globalPreferences = View::shared('globalPreferences');

           return view('example', [
               'apiLimit' => $globalPreferences['api_limit'],
               'appMode' => $globalPreferences['app_mode'],
           ]);
       }
   }

If the data needs to change during the application lifecycle (e.g., a feature toggle), you can update it dynamically.