1. Go to this page and download the library: Download moirei/laravel-model-data 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/ */
moirei / laravel-model-data example snippets
use MOIREI\ModelData\HasData;
class YourModel extends Model
{
use HasData;
...
}
Schema::create('products', function (Blueprint $table) {
$table->modelData('data');
// OR
$table->json('data')->nullable();
// OR
$table->text('data')->nullable();
});
...
/**
* ModelData: use model's column
*
* @var string|array|false
*/
protected $model_data = 'data';
class YourModel extends Model
{
use HasData;
...
}