PHP code example of farzai / laravel-model-settings

1. Go to this page and download the library: Download farzai/laravel-model-settings library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

farzai / laravel-model-settings example snippets


// config/model-settings.php
return [
    'model' => \Farzai\ModelSettings\Model::class,
];

use Farzai\ModelSettings\Facades\Setting;
use App\Models\Post;

// Create a setting for a model
Setting::for(Post::class)->set('default-status', 'draft');

// Get a setting for a model
Setting::for(Post::class)->get('default-status');

// Get a setting for a model or return a default value
Setting::for(Post::class)->get('default-status', 'published');

use Farzai\ModelSettings\Facades\Setting;

// Create a setting
Setting::set('default-status', 'draft');

// Get a setting
Setting::get('default-status');
bash
php artisan vendor:publish --tag="laravel-model-settings-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="laravel-model-settings-config"