PHP code example of sdavis1902 / eloquent-vars

1. Go to this page and download the library: Download sdavis1902/eloquent-vars 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/ */

    

sdavis1902 / eloquent-vars example snippets

 php
sdavis1902\EloquentVars\EloquentVarsServiceProvider::class,
 bash
$ php artisan vendor:publish --provider="sdavis1902\EloquentVars\EloquentVarsServiceProvider"
$ php artisan:migrate
 php
$task->setVar('temporary_field', 'The value');
$task->setVar('temporary_id', 1);

echo $task->getVar('temporary_field');

$task->deleteVar('temporary_field');
 php
$tasks = \App\Task::with('ModelVars')->get();

foreach($tasks as $task){
    if($task->vars->first_var){
        echo $task->vars->first_var;
    }
}