PHP code example of laracraft-tech / laravel-dynamic-model

1. Go to this page and download the library: Download laracraft-tech/laravel-dynamic-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/ */

    

laracraft-tech / laravel-dynamic-model example snippets

 php
Schema::create('foo', function (Blueprint $table) {
    $table->id();
    $table->string('col1');
    $table->integer('col2');
    $table->timestamps();
});

Schema::create('bar', function (Blueprint $table) {
    $table->date('period')->primary();
    $table->string('col1');
    $table->integer('col2');
    $table->timestamps();
});
 bash
php artisan migrate

^ LaracraftTech\LaravelDynamicModel\DynamicModel_mysql_foo {#328 ▼
  #connection: "mysql"
  #table: "foo"
  #primaryKey: "id"
  #keyType: "int"
  +incrementing: true
  #attributes: array:5 [▼
    "id" => 1
    "col1" => "asdf"
    "col2" => 123
    "created_at" => "2023-03-22 15:34:22"
    "updated_at" => "2023-03-22 15:34:22"
  ]
}

^ LaracraftTech\LaravelDynamicModel\DynamicModel_mysql_faz {#328 ▼
  #connection: "mysql"
  #table: "faz"
  #primaryKey: "period"
  #keyType: "string"
  +incrementing: false
  #attributes: array:5 [▼
    "period" => "2023-01-01"
    "col1" => "asdf"
    "col2" => 123
    "created_at" => "2023-03-22 15:34:22"
    "updated_at" => "2023-03-22 15:34:22"
  ]
}

^ LaracraftTech\LaravelDynamicModel\DynamicModel_mysql2_foo {#328 ▼
  #connection: "mysql2"
  #table: "foo"
  #primaryKey: "id"
  #keyType: "int"
  +incrementing: true
  #attributes: array:5 [▼
    "id" => 1
    "col1" => "asdf"
    "col2" => 123
    "created_at" => "2023-03-22 15:34:22"
    "updated_at" => "2023-03-22 15:34:22"
  ]
}

^ App\Model\MyDynamicModel_mysql_foo {#328 ▼
  #connection: "mysql"
  #table: "foo"
  #primaryKey: "id"
  #keyType: "int"
  +incrementing: true
  #attributes: array:5 [▼
    "id" => 1
    "col1" => "asdf"
    "col2" => 123
    "created_at" => "2023-03-22 15:34:22"
    "updated_at" => "2023-03-22 15:34:22"
  ]
  ...
}