PHP Method Schema::getConnection, someline-starter Code Examples

This page contains top rated real world PHP examples of method Schema::getConnection from package someline-starter extracted from open source projects. You can rate examples to help us improve the quality of examples
Frequently Used Methods

getConnection() public static method

Get the database connection instance.
public static getConnection ( ) : Connection
return Illuminate\Database\Connection
Example #1
Show file File: TestCase.php Project: sohailaammarocs/lfc
0
 /**
  * Resets the database and install the migration table.
  *
  * @return void
  */
 protected function migrate()
 {
     $tableNames = Schema::getConnection()->getDoctrineSchemaManager()->listTableNames();
     foreach ($tableNames as $table) {
         Schema::drop($table);
     }
     $this->app['Illuminate\\Contracts\\Console\\Kernel']->call('migrate:install', ['--env' => 'testing']);
 }
Example #2
Show file File: 2016_08_30_084634_make_purchase_cost_nullable.php Project: stijni/snipe-it
0
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform();
     $platform->registerDoctrineTypeMapping('enum', 'string');
     Schema::table('assets', function ($table) {
         $table->decimal('purchase_cost', 8, 2)->nullable()->default(null)->change();
     });
 }
Example #3
Show file File: 2014_06_09_203000_add_capsule_to_goods_table.php Project: huanghua581/erp
0
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Schema::table('goods', function (Blueprint $table) {
         $table->dropColumn('capsule_unit');
     });
     $table = Schema::getConnection()->getTablePrefix() . 'good_log';
     DB::statement("ALTER TABLE `" . $table . "` MODIFY COLUMN  `status`  ENUM('purchase', 'new', 'picking' , 'price', 'edit', 'damage', 'replacement', 'allocation', 'empty');");
 }
Example #4
Show file File: 2014_09_23_194713_create_GDN_Discussion_table.php Project: bishopb/laravel-forums
0
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     $grammar = Schema::getConnection()->getSchemaGrammar();
     if ($grammar instanceof \Illuminate\Database\Schema\Grammars\MySqlGrammar) {
         Schema::table('GDN_Discussion', function ($table) {
             $table->dropIndex('search');
         });
     }
     Schema::drop('GDN_Discussion');
 }
Example #5
Show file File: DatabaseSeeder.php Project: noikiy/laravel-chat-example
0
 /**
  * Clean out the database for a new seed generation.
  */
 private function cleanDatabase()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS=0');
     $tableNames = Schema::getConnection()->getDoctrineSchemaManager()->listTableNames();
     foreach ($tableNames as $name) {
         //if you don't want to truncate migrations
         if ($name == 'migrations') {
             continue;
         }
         DB::table($name)->truncate();
     }
     DB::statement('SET FOREIGN_KEY_CHECKS=1');
 }
Example #6
Show file File: CreateMetaAttributesTable.php Project: boukeversteegh/eloquence
0
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     \Schema::create($this->table, function (Blueprint $table) {
         $table->increments('meta_id');
         $table->string('meta_key');
         $table->longText('meta_value');
         $table->string('meta_type')->default('string');
         $table->morphs('metable');
         $table->index('meta_key');
         // Laravel doesn't handle index length, so we need raw statement for this one
         \Schema::getConnection()->statement('create index meta_attributes_index_value on meta_attributes (meta_key, meta_value(20))');
     });
 }
Example #7
Show file File: 2016_10_11_133800_fix_people_indexes.php Project: boomcms/boom-core
0
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('people', function (Blueprint $table) {
         // Credit: https://github.com/laravel/framework/issues/3253#issuecomment-51961561
         $conn = Schema::getConnection();
         $dbSchemaManager = $conn->getDoctrineSchemaManager();
         $doctrineTable = $dbSchemaManager->listTableDetails('people');
         if ($doctrineTable->hasIndex('people_email_unique')) {
             $table->dropUnique('people_email_unique');
         }
         $table->dropUnique('deleted_at');
         $table->unique(['email', 'deleted_at']);
     });
 }
Example #8
Show file File: 2014_09_23_194714_seed_base_vanilla_tables.php Project: bishopb/laravel-forums
0
 /**
  * Add the seeded data.
  */
 public function up()
 {
     // we will have some crazy ID values, cajole MySQL into accepting them
     $grammar = Schema::getConnection()->getSchemaGrammar();
     if ($grammar instanceof \Illuminate\Database\Schema\Grammars\MySqlGrammar) {
         DB::statement('SET SESSION SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";');
     }
     // do the seeding
     DB::beginTransaction();
     foreach ($this->getSeedData() as $table => $rows) {
         // Note: each row may have different columns: can't use bulk insert
         foreach ($rows as $row) {
             $this->insertRow($table, $row);
         }
     }
     DB::commit();
 }
Example #9
Show file File: DatabaseSeeder.php Project: slice-beans/cqs-framework
0
 private function emptyTables()
 {
     if (substr_count(get_class(DB::connection()), 'MySql') > 0) {
         DB::statement('SET FOREIGN_KEY_CHECKS=0');
     }
     $tableNames = Schema::getConnection()->getDoctrineSchemaManager()->listTableNames();
     foreach ($tableNames as $name) {
         //if you don't want to truncate migrations
         if ($name == 'migrations') {
             continue;
         }
         DB::table($name)->truncate();
     }
     if (substr_count(get_class(DB::connection()), 'MySql') > 0) {
         DB::statement('SET FOREIGN_KEY_CHECKS=1');
     }
 }
Example #10
Show file File: SnAPITest.php Project: morphatic/snapi
0
 /**
  * Tests to make sure our testing environment is set up correctly
  */
 public function testSetUp()
 {
     // make sure tests are working
     $this->assertTrue(true);
     // make sure Sentry is loaded and facade works
     $this->assertInstanceOf('Cartalyst\\Sentry\\Sentry', $this->app['sentry']);
     // verify that we have a database connection
     $this->assertInstanceOf('Illuminate\\Database\\Connection', Schema::getConnection());
     // test that our database exists and has tables created in migrations
     $this->assertTrue(Schema::hasTable('migrations'));
     $this->assertTrue(Schema::hasTable('users'));
     $this->assertTrue(Schema::hasTable('foos'));
     $this->assertTrue(Schema::hasTable('bars'));
     $this->assertTrue(Schema::hasTable('bazes'));
     // test that the data we entered is loaded
     // check to see that our testing models were loaded
     $this->assertTrue(class_exists('Morphatic\\Snapi\\Tests\\Foo'));
     $this->assertTrue(class_exists('Morphatic\\Snapi\\Tests\\Bar'));
     $this->assertTrue(class_exists('Morphatic\\Snapi\\Tests\\Baz'));
 }
Example #11
Show file File: Synchronize.php Project: jrafaelca/Doptor
0
 /**
  * Drop all the tables in the database
  */
 public function dropTables()
 {
     $all_tables = \Schema::getConnection()->getDoctrineSchemaManager()->listTableNames();
     \DB::statement("SET foreign_key_checks = 0");
     foreach ($all_tables as $table) {
         \DB::statement('DROP TABLE IF EXISTS ' . $table);
     }
 }
Example #12
Show file File: 2016_04_06_132243_change_products_table.php Project: sagaciresearch/adtracking
0
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
$platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('enum', 'string');
class ChangeProductsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('products', function ($table) {
            $table->integer('subindustry_id')->unsigned()->nullable()->change();
        });
    }
    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('products', function ($table) {
            $table->integer('subindustry_id')->unsigned()->change();
        });
    }
}
Example #13
Show file File: 2014_05_08_143850_add_status_to_good_log_table.php Project: huanghua581/erp
0
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     $table = Schema::getConnection()->getTablePrefix() . 'good_log';
     DB::statement("ALTER TABLE `" . $table . "` MODIFY COLUMN  `status`  ENUM('purchase', 'new', 'picking' , 'price', 'edit', 'damage', 'replacement');");
 }