1. Go to this page and download the library: Download leinonen/yii2-eloquent 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/ */
use Illuminate\Database\Schema\Blueprint;
Yii::$app->db->schema()->create('user', function (Blueprint $table) {
$table->increments('id');
$table->string('email')->unique();
$table->timestamps();
});
use Illuminate\Database\Capsule\Manager as Capsule;
$users = Capsule::table('users')->where('votes', '>', 100)->get();
$results = Capsule::select('select * from users where id = ?', array(1));
use leinonen\Yii2Eloquent\Eloquent\Model;
class Order extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'order';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['name'];
/**
* {@inheritdoc}
*/
public function rules()
{
return [
['address', '
use Illuminate\Database\Capsule\Manager as Capsule;
use yii\db\MigrationInterface;
class myMigration implements MigrationInterface
{
public function up()
{
Capsule::schema()->create('my_table', function($table){
$table->increments('id');
});
}
public function down()
{
Capsule::schema()->dropIfExists('my_table');
}
}
use leinonen\Yii2Eloquent\Fixtures\EloquentFixture;
class OrderFixture extends EloquentFixture
{
public $modelClass = Order::class;
public function getData()
{
return [
'example1' => [
'address' => 'Test address',
],
];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.