PHP code example of bfg / bless_model

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

    

bfg / bless_model example snippets


\BlessModel::do(\App\Models\User::class, []);

class Profile extends \Illuminate\Database\Eloquent\Model {
   
    protected $fillable = ["first_name","last_name","age","about"];
}

class Role extends \Illuminate\Database\Eloquent\Model {
   
    protected $fillable = ["slug","name"];
}

class Post extends \Illuminate\Database\Eloquent\Model {
   
    protected $fillable = ["subject","text"];
}

class Commentary extends \Illuminate\Database\Eloquent\Model {
   
    protected $fillable = ["text"];
}

\BlessModel::do(\App\Models\User::class, [
    "name" => "DoctorWho",
    "email" => "[email protected]",
    "profile" => [
        "first_name" => "Doctor",
        "last_name" => "Who",
        "age" => 2200,
        "about" => "An eccentric alien traveler of a great mind who fights injustice."
    ],
    "role" => [
        "slug" => "time_lord",
        "name" => "Time Lord",
    ],
    "posts" => [
        [
            "subject" => "About TARDIS",
            "text" => "The TARDIS (Time And Relative Dimension In Space) is a time machine and spacecraft that appears in the British science fiction television series Doctor Who and its various spin-offs."
        ]       
    ],
    "commentaries" => [
        [
            "text" => "Butterflies are cool!"
        ],
        [
            "text" => "Yowzah!"
        ],
        [
            "text" => "Geronimo!"
        ]
    ]
]);