PHP code example of okipa / laravel-model-json-storage

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

    

okipa / laravel-model-json-storage example snippets


// laravel model json storage
// https://github.com/Okipa/laravel-model-json-storage
$this->app->register(Okipa\LaravelModelJsonStorage\ModelJsonStorageServiceProvider::class);

class MyTestModel extends Illuminate\Database\Eloquent\Model
{
    use Okipa\LaravelModelJsonStorage\ModelJsonStorage;
    
    [...]
}

$testModel = app(MyTestModel::class)->create([
    'name' => 'John Doe',
    'email' => '[email protected]',
    'password' => Hash::make('secret'),
]);

$testModel = app(MyTestModel::class)->all();

$testModel = app(MyTestModel::class)->where('email', '[email protected]')->first();

$testModel->update([
    'name' => 'Gary Cook'
]);

$testModel->delete();
bash
php artisan vendor:publish --tag=model-json-storage::config