PHP Classes

File: tests/bootstrap.php

Recommend this page to a friend!
  Classes of Hashemi Rafsan   Laravel Query Filter Builder   tests/bootstrap.php   Download  
File: tests/bootstrap.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Laravel Query Filter Builder
Build queries with parameters to define conditions
Author: By
Last change:
Date: 3 years ago
Size: 828 bytes
 

Contents

Class file image Download
<?php

require __DIR__ . '/../vendor/autoload.php';

use
Illuminate\Database\Capsule\Manager as Capsule;
use
Illuminate\Database\Schema\Blueprint;

$capsule = new Capsule;

$capsule->addConnection([
   
'driver' => 'sqlite',
   
'database' => __DIR__ . '/database.sqlite',
]);

$capsule->setAsGlobal();
$capsule->bootEloquent();

// Drop table migration
Capsule::schema()->dropIfExists('dummies');

// create table migration
Capsule::schema()->create('dummies', function (Blueprint $table) {
   
$table->increments('id');
   
$table->string('first_name');
   
$table->string('last_name');
   
$table->string('email');
});

// seed data
foreach ( range(1, 10) as $i ) {
   
Dummy::create([
       
'first_name' => 'First Name of',
       
'last_name' => 'Admin' . $i,
       
'email' => "admin$i@example.com",
    ]);

}