/** * Reverse the migrations. * * @return void */ public function down() { // BaseSeeder::disableForeignKeyGuard(); Schema::dropIfExists(Locale::getTableName()); BaseSeeder::enableForeignKeyGuard(); }
public function performSeeding() { Locale::truncate(); foreach ($this->getSeedingData() as $aData) { Locale::create($aData); } // Locale::insert($this->getSeedingData()); }
/** * @return \Illuminate\Database\Eloquent\Collection|static[] */ public function getAll() { $aKeys = Locale::all(); $resource = new Collection($aKeys, new LocaleTransformer(), "locale"); $manager = new Manager(); // $manager->setSerializer(new DataArraySerializer()); $manager->setSerializer(new JsonApiSerializer()); // Run all transformers $aReturn = $manager->createData($resource)->toArray(); return $aReturn; }
/** * */ 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"); }); }