PHP code example of dive-be / eloquent-utils

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

    

dive-be / eloquent-utils example snippets


class Country extends Model
{
    use \Dive\Eloquent\DisablesTimestamps;
}

Schema::create('languages', static function (Blueprint $table) {
    $table->id();
    $table->char('iso', 2)->unique();
});

final class Language extends Model
{
    use \Dive\Eloquent\InteractsWithStaticData;
}

Language::$source = [
    'DE' => ['id' => 1, 'iso' => 'DE'],
    'EN' => ['id' => 2, 'iso' => 'EN'],
    'FR' => ['id' => 3, 'iso' => 'FR'],
    'NL' => ['id' => 4, 'iso' => 'NL'],
];

public function run(ConnectionInterface $db)
{
    $db->table('languages')->insert(Language::$source);
}

Language::find('NL'); // App\Models\Language { #3645 }

class Product extends Model
{
    use \Dive\Eloquent\Unguarded;
}

Product::find(1337)->fill([
    'sku' => 'abcdefg',
])->save(); // true

class Coupon extends Model
{
    use \Dive\Eloquent\Unwritable;
}

Coupon::find(10)->update(['code' => 'je-suis-rogue']); // BadMethodCallException