PHP code example of liam-wiltshire / laravel-model-meta

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

    

liam-wiltshire / laravel-model-meta example snippets


$book = new \App\Models\Book();

$book->forceFill(
[
    'title' => 'Laravel Quickstart Guide',
    'author_id' => 90,
    'publisher_id' => 5,
    'description' => 'This is an awesome book'
]
);

$book->save();

$book = \App\Models\Book::find(1);

//This is an actual field in the DB, so this will be set to that attribute
$book->title = 'Laravel Quickstart Guide, Second Edition';

//This isn't a field in the DB, and isn't a relationship etc, so will be stored in the meta field
$book->page_count = 200;

$test->save();

$table->json('meta')->nullable()->default(null);

protected $metaDbField = 'metaData';