PHP code example of igaster / laravel-model-options

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

    

igaster / laravel-model-options example snippets


$table->json('options')->nullable();

$table->string('options')->nullable();

use igaster\modelOptions\modelOptions {
    __get as private; 
    __set as private; 
}

//--- copy these in your model if you need to implement __get() __set() methods

public function __get($key) {
    // Handle modelOptions keys
    $result=$this->modelOptions_get($key);
    if ($this->modelOptions_handled)
        return $result;
    
    //your code goes here
    
    return parent::__get($key);
}

public function __set($key, $value) {
    // Handle modelOptions keys
    $this->modelOptions_set($key, $value);
    if ($this->modelOptions_handled)
        return;

    //your code goes here

    parent::__set($key, $value);
}