/** * Run the migrations. * * @return void */ public function up() { // Schema::create(Locale::getTableName(), function (Blueprint $oTable) { $oTable->increments(Locale::getTablePrimaryKeyName()); $oTable->string(Locale::COLUMN_CODE, 10)->index(); $oTable->string(Locale::COLUMN_NAME); $oTable->string(Locale::COLUMN_DESCRIPTION); // make it unique $oTable->unique(Locale::COLUMN_CODE); if (Locale::IsTimeStampAllowed()) { $oTable->timestamps(); } }); }
/** * */ public function performSeeding() { /* * Truncate the Message Seeder */ Message::truncate(); $aKeys = Key::all()->lists(Key::getTablePrimaryKeyName()); $aLocales = Locale::all()->lists(Locale::getTablePrimaryKeyName())->toArray(); // dd($aLocales); collect($aKeys)->each(function ($iKey) use($aLocales) { foreach ($aLocales as $iLocaleID) { $oMessage = factory(Message::class)->make(); $oMessage->setAttribute(Message::COLUMN_LOCALE_ID, $iLocaleID); $oMessage->setAttribute(Message::COLUMN_KEY_ID, $iKey); $aMessage = $oMessage->toArray(); // create the message Message::create($aMessage); } }); }
/** * Run the migrations. * * @return void */ public function up() { // $this->down(); Schema::create(Message::getTableName(), function (Blueprint $table) { $table->increments(Message::getTablePrimaryKeyName()); $table->unsignedInteger(Message::COLUMN_KEY_ID)->nullable()->index(); $table->unsignedInteger(Message::COLUMN_LOCALE_ID)->nullable()->index(); $table->mediumText(Message::COLUMN_TEXT)->nullable(); if (Message::IsTimeStampAllowed()) { $table->timestamps(); } // make the key id and locale code unique $table->unique([Message::COLUMN_KEY_ID, Message::COLUMN_LOCALE_ID]); /* * Foreign Keys */ $table->foreign(Message::COLUMN_KEY_ID)->references(Key::getTablePrimaryKeyName())->on(Key::getTableName())->onDelete('cascade')->onUpdate('cascade'); $table->foreign(Message::COLUMN_LOCALE_ID)->references(Locale::getTablePrimaryKeyName())->on(Locale::getTableName())->onDelete("cascade")->onUpdate("cascade"); }); }