/**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     //
     BaseSeeder::disableForeignKeyGuard();
     Schema::dropIfExists(Key::getTableName());
     BaseSeeder::enableForeignKeyGuard();
 }
 /**
  * @return \Illuminate\Database\Eloquent\Collection|static[]
  */
 public function getAll()
 {
     $aKeys = Key::all();
     $resource = new Collection($aKeys, new KeyTransformer(), "keys");
     $manager = new Manager();
     //        $manager->setSerializer(new DataArraySerializer());
     $manager->setSerializer(new JsonApiSerializer());
     // Run all transformers
     $aReturn = $manager->createData($resource)->toArray();
     return $aReturn;
 }
 public function performSeeding()
 {
     Key::truncate();
     /*
      * Truncate the Message Seeder
      */
     Message::truncate();
     /*
      * Create the locale
      */
     factory(Key::class, 5)->create();
 }
 /**
  *
  */
 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");
     });
 }