PHP code example of internetcode / laravel-user-settings

1. Go to this page and download the library: Download internetcode/laravel-user-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/ */

    

internetcode / laravel-user-settings example snippets


$user->setting('my_setting');

$user->getSetting('my_setting');

$user->setting('my_setting', true);

$user->setSetting('my_setting', true);

/**
 * getSettingFields function.
 * Get the default possible settings for the user. Can be overwritten
 * in the user model.
 *
 * @return array
 */
public function getSettingFields()
{
    return config('user-settings.setting_fields', []);
}

$user = (new User())->whereSetting('my_setting')->first();

$user->setMultipleSettings([
    'my_setting'        => true,
    'my_setting_2'      => false,
]);
$user->save();

'providers' => [

        /*
         * Laravel Framework Service Providers...
         */
        Illuminate\Auth\AuthServiceProvider::class,

        ...

        Internetcode\LaravelUserSettings\LaravelUserSettingsServiceProvider::class,
    ],



namespace Internetcode\LaravelUserSettings\Tests;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Internetcode\LaravelUserSettings\Traits\HasSettingsTrait;

class User extends Authenticatable
{
    use HasSettingsTrait;

php artisan vendor:publish --tag=config
php artisan vendor:publish --tag=migrations