DeveloperBreeze

Laravel Best Practices Development Tutorials, Guides & Insights

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

Creating a Configurable Pagination System in Laravel

Tutorial November 16, 2024
php

Add methods to edit and update settings:

   namespace App\Http\Controllers\Admin;

   use App\Models\Setting;
   use Illuminate\Http\Request;

   class SettingsController extends Controller
   {
       public function edit()
       {
           $paginationLimit = Setting::where('key', 'pagination_limit')->value('value');
           return view('admin.settings.edit', compact('paginationLimit'));
       }

       public function update(Request $request)
       {
           Setting::updateOrCreate(
               ['key' => 'pagination_limit'],
               ['value' => $request->input('pagination_limit')]
           );

           return redirect()->back()->with('success', 'Pagination limit updated successfully.');
       }
   }

Optimizing Performance in Laravel by Centralizing Data Loading

Tutorial November 16, 2024
php

   php artisan make:provider PerformanceServiceProvider

Open the newly created file in app/Providers/PerformanceServiceProvider.php and define shared data:

Building a Base Controller for Reusable Data Access in Laravel

Tutorial November 16, 2024
php

  • User Roles: Determine if a user has admin or moderator privileges.
  • Feature Toggles: Enable or disable features like file uploads.
  • App-Wide Configurations: Share global preferences like application mode or API limits.

We will implement these as shared properties and methods in a Base Controller.