DeveloperBreeze

Laravel Programming Tutorials, Guides & Best Practices

Explore 51+ expertly crafted laravel tutorials, components, and code examples. Stay productive and build faster with proven implementation strategies and design patterns from DeveloperBreeze.

Tutorial
php

Creating Dynamic Content in Laravel Based on Site Settings

   php artisan db:seed --class=SiteSettingsSeeder

To easily access the settings, create a helper function.

Nov 16, 2024
Read More
Tutorial
php

Creating a Configurable Pagination System in Laravel

Open the generated migration file and define a key-value structure:

   use Illuminate\Database\Migrations\Migration;
   use Illuminate\Database\Schema\Blueprint;
   use Illuminate\Support\Facades\Schema;

   class CreateSettingsTable extends Migration
   {
       public function up()
       {
           Schema::create('settings', function (Blueprint $table) {
               $table->id();
               $table->string('key')->unique();
               $table->string('value')->nullable();
               $table->timestamps();
           });
       }

       public function down()
       {
           Schema::dropIfExists('settings');
       }
   }

Nov 16, 2024
Read More
Tutorial
php

Using Laravel Config and Localization Based on Site Settings

Define edit and update methods:

   namespace App\Http\Controllers\Admin;

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

   class SiteSettingsController extends Controller
   {
       public function edit()
       {
           $settings = SiteSetting::all();
           return view('admin.settings.edit', compact('settings'));
       }

       public function update(Request $request)
       {
           foreach ($request->settings as $key => $value) {
               SiteSetting::updateOrCreate(['key' => $key], ['value' => $value]);
           }

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

Nov 16, 2024
Read More