protected function _extraColumns(App\Modules\Abstracts\Models\Blueprint $table)
 {
     $table->unsignedMediumInteger('user_id');
     $table->char('username', 50);
     $table->char('password', 100);
     $table->enum('type', Credential::getCredentialTypes());
     $table->index(['user_id'], 'user_id');
     $table->index(['username'], 'username');
     $table->index(['password'], 'password');
     $table->index(['type'], 'type');
 }
Beispiel #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     factory($this->_entityName, 50)->create()->each(function ($item) {
         $item->createdBy()->associate($item);
         $item->updatedBy()->associate($item);
         $item->save();
         foreach (Credential::getCredentialTypes() as $type) {
             factory(Credential::class)->create(['userId' => $item->id, 'type' => $type, 'updatedById' => $item->id, 'createdById' => $item->id]);
         }
         $pool = factory(MoneyPool::class)->make();
         $pool->entityName = get_class($item);
         $pool->entityId = $item->id;
         $pool->createdBy()->associate($item);
         $pool->updatedBy()->associate($item);
         $pool->save();
     });
 }
use App\Modules\System\Models\Role;
/*
 * |--------------------------------------------------------------------------
 * | Model Factories
 * |--------------------------------------------------------------------------
 * |
 * | Here you may define all of your model factories. Model factories give
 * | you a convenient way to create models for testing and seeding your
 * | database. Just tell the factory how a default model should look.
 * |
 */
$factory->define(User::class, function (Generator $faker) {
    return ['active' => intval(random_int(0, 10) !== 0), 'created' => $faker->dateTime, 'updated' => $faker->dateTime, 'created_by' => User::all()->count() > 0 ? $faker->randomElement(User::all()->all())->id : 1, 'updated_by' => User::all()->count() > 0 ? $faker->randomElement(User::all()->all())->id : 1, 'firstname' => $faker->firstName, 'lastname' => $faker->lastName, 'email' => $faker->email];
});
$factory->define(Credential::class, function (Faker\Generator $faker) {
    return ['user_id' => $faker->randomElement(User::all()->all())->id, 'type' => $faker->randomElement(Credential::getCredentialTypes()), 'username' => $faker->userName, 'password' => Hash::make('12345678'), 'active' => intval(random_int(0, 10) !== 0), 'created' => $faker->dateTime, 'updated' => $faker->dateTime, 'created_by' => User::all()->count() > 0 ? $faker->randomElement(User::all()->all())->id : 1, 'updated_by' => User::all()->count() > 0 ? $faker->randomElement(User::all()->all())->id : 1];
});
$factory->define(Role::class, function (Faker\Generator $faker) {
    do {
        $array = ['name' => $faker->word, 'active' => intval(random_int(0, 10) !== 0), 'created' => $faker->dateTime, 'updated' => $faker->dateTime, 'created_by' => User::all()->count() > 0 ? $faker->randomElement(User::all()->all())->id : 1, 'updated_by' => User::all()->count() > 0 ? $faker->randomElement(User::all()->all())->id : 1];
    } while (Role::where(['name' => $array['name']])->get()->count() > 0);
    return $array;
});
$factory->define(Group::class, function (Faker\Generator $faker) {
    do {
        $array = ['name' => $faker->word, 'description' => $faker->sentences(random_int(1, 3), true), 'active' => intval(random_int(0, 10) !== 0), 'created' => $faker->dateTime, 'updated' => $faker->dateTime, 'created_by' => User::all()->count() > 0 ? $faker->randomElement(User::all()->all())->id : 1, 'updated_by' => User::all()->count() > 0 ? $faker->randomElement(User::all()->all())->id : 1];
    } while (Group::where(['name' => $array['name']])->get()->count() > 0);
    return $array;
});
$factory->define(Group_User::class, function (Faker\Generator $faker) {
    return ['user_id' => $faker->randomElement(User::all()->all())->id, 'group_id' => $faker->randomElement(Group::all()->all())->id, 'active' => intval(random_int(0, 10) !== 0), 'created' => $faker->dateTime, 'updated' => $faker->dateTime, 'created_by' => User::all()->count() > 0 ? $faker->randomElement(User::all()->all())->id : 1, 'updated_by' => User::all()->count() > 0 ? $faker->randomElement(User::all()->all())->id : 1];