PHP code example of luinuxscl / option-package

1. Go to this page and download the library: Download luinuxscl/option-package 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/ */

    

luinuxscl / option-package example snippets


   use Illuminate\Database\Eloquent\Model;
   use Luinuxscl\OptionPackage\Traits\HasOptions;

   class User extends Model
   {
       use HasOptions;
   }
   

     $user->setOption('theme', 'dark');
     

     $theme = $user->getOption('theme', 'light'); // 'light' es el valor por defecto si no se encuentra la opción
     

     $user->removeOption('theme');
     

   use Luinuxscl\OptionPackage\Facades\Option;

   // Asignar una opción global
   Option::set('site_name', 'Mi Sitio Web');

   // Obtener una opción global
   $siteName = Option::get('site_name');

   // Eliminar una opción global
   Option::remove('site_name');
   
bash
   php artisan vendor:publish --provider="Luinuxscl\OptionPackage\Providers\OptionServiceProvider" --tag="migrations"
   
bash
   php artisan migrate
   
bash
   php artisan vendor:publish --provider="Luinuxscl\OptionPackage\Providers\OptionServiceProvider" --tag="config"