/**
  *
  */
 public function testIlluminateConnection()
 {
     Illuminate\Database\Capsule\Manager::schema()->create('test', function (Blueprint $table) {
         $table->increments('id');
         $table->string('email')->unique();
         $table->timestamps();
     });
     \Illuminate\Database\Capsule\Manager::table('test')->insert(['email' => '*****@*****.**']);
     $test = \Illuminate\Database\Capsule\Manager::table('test')->first();
     $this->assertNotEmpty($test);
     \Illuminate\Database\Capsule\Manager::schema()->drop('test');
 }
Beispiel #2
0
<?php

Illuminate\Database\Capsule\Manager::schema($connectName)->create('roles', function ($table) {
    $table->increments('id');
    $table->string('name');
    $table->text('permissions');
    $table->timestamps();
});
$now = date('Y-m-d H:i:s', time());
Illuminate\Database\Capsule\Manager::connection($connectName)->table('roles')->insert([['name' => 'OnlyRead', 'permissions' => '', 'created_at' => $now, 'updated_at' => $now], ['name' => 'User', 'permissions' => 'global/write;global/file', 'created_at' => $now, 'updated_at' => $now], ['name' => 'Moderator', 'permissions' => 'global/write;global/modify;global/file', 'created_at' => $now, 'updated_at' => $now], ['name' => 'Admin', 'permissions' => 'global/all', 'created_at' => $now, 'updated_at' => $now]]);
Beispiel #3
0
<?php

Illuminate\Database\Capsule\Manager::schema($connectName)->create('user_providers', function ($table) {
    $table->increments('id');
    $table->string('user_id');
    $table->string('provider_name', 255);
    $table->string('provider_id', 255);
    $table->timestamps();
});
Beispiel #4
0
<?php

Illuminate\Database\Capsule\Manager::schema($connectName)->create('feedback_posts', function ($table) {
    $table->increments('id');
    $table->string('name', 100);
    $table->string('email');
    $table->text('message');
    $table->boolean('readed')->default(false);
    $table->boolean('closed')->default(false);
    $table->string('hash', 128);
    $table->integer('user_id')->unsigned()->default(0);
    $table->string('ip', 64)->default('127.0.0.1');
    // ipv6 & ipv4
    $table->timestamps();
});
Beispiel #5
0
<?php

Illuminate\Database\Capsule\Manager::schema($connectName)->create('content_ratings', function ($table) {
    $table->increments('id');
    $table->integer('content_id');
    $table->integer('user_id');
    $table->string('type')->default('unknown');
    $table->timestamps();
});
Beispiel #6
0
<?php

Illuminate\Database\Capsule\Manager::schema($connectName)->create('comment_answers', function ($table) {
    $table->increments('id');
    $table->integer('comment_id')->unsigned();
    $table->integer('user_id')->unsigned();
    $table->string('guest_name', 100);
    $table->text('message');
    $table->string('lang', 32)->default('en');
    $table->string('ip', 64)->default('127.0.0.1');
    // ipv4 and ipv6 (32 chars + 7 digits is max)
    $table->boolean('moderate')->default(false);
    $table->timestamps();
});
/**
 * Created by PhpStorm.
 * User: Stefano "Yoghi" Tamagnini
 * Date: 23/09/15 - 21:32
 *
 */
function setup($config)
{
    foreach ($config['databases'] as $name => $database) {
        if (!file_exists($config['uploads_dir'])) {
            mkdir($config['uploads_dir']);
        }
        if ($database['driver'] == 'sqlite') {
            $dbh = new PDO('sqlite:' . $database['database']);
            $dbh = null;
        }
        if (!Illuminate\Database\Capsule\Manager::schema($name)->hasTable('annotations')) {
            Illuminate\Database\Capsule\Manager::schema($name)->create('annotations', function ($table) {
                $table->increments('id');
                $table->string('author');
                $table->string('source');
                $table->string('sourceId');
                $table->text('text');
                $table->text('textHtml');
                $table->string('hashtags');
                $table->softDeletes();
                $table->timestamps();
            });
            echo "<h3>{$name} - Annotations table created</h3>";
        } else {
            echo "<h3>{$name} - Annotations table ok</h3>";
        }
        if (!Illuminate\Database\Capsule\Manager::schema($name)->hasTable('attachments')) {
            Illuminate\Database\Capsule\Manager::schema($name)->create('attachments', function ($table) {
                $table->increments('id');
                $table->integer('annotation_id');
                $table->string('source');
                $table->string('fileName');
                $table->string('filePath')->unique();
                // http://laravel.com/docs/5.0/schema#foreign-keys
                $table->foreign('annotation_id')->references('id')->on('annotations');
                $table->softDeletes();
                $table->timestamps();
            });
            echo "<h3>{$name} - Attachments table created</h3>";
        } else {
            echo "<h3>{$name} - Attachments table ok</h3>";
        }
        if (!Illuminate\Database\Capsule\Manager::schema($name)->hasTable('evaluations')) {
            Illuminate\Database\Capsule\Manager::schema($name)->create('evaluations', function ($table) {
                $table->increments('id');
                $table->integer('annotation_id');
                $table->string('sessione');
                $table->integer('evento');
                $table->integer('punteggio');
                $table->foreign('annotation_id')->references('id')->on('annotations');
                $table->softDeletes();
                $table->timestamps();
            });
            echo "<h3>{$name} - Evaluations table created</h3>";
        } else {
            echo "<h3>{$name} - Evaluations table ok</h3>";
        }
        if ($name == 'testing' && !Illuminate\Database\Capsule\Manager::schema($name)->hasTable('inbox')) {
            Illuminate\Database\Capsule\Manager::schema($name)->create('inbox', function ($table) {
                $table->increments('ID');
                $table->string('SenderNumber');
                $table->string('TextDecoded');
            });
            echo "<h3>{$name} - Inbox SMS table created</h3>";
        } else {
            echo "<h3>{$name} - Inbox SMS table ok</h3>";
        }
    }
}
Beispiel #8
0
<?php

Illuminate\Database\Capsule\Manager::schema($connectName)->create('user_notifications', function ($table) {
    $table->increments('id');
    $table->string('user_id');
    $table->string('msg', 2048);
    $table->string('uri', 2048);
    $table->binary('vars')->nullable();
    $table->boolean('readed')->default(false);
    $table->timestamps();
});
Beispiel #9
0
<?php

Illuminate\Database\Capsule\Manager::schema($connectName)->create('profile_fields', function ($table) {
    $table->increments('id');
    $table->enum('type', ['text', 'link']);
    $table->text('name');
    $table->string('reg_exp', 512)->nullable();
    $table->tinyInteger('reg_cond')->default(0);
    $table->timestamps();
});