public function run() { $faker = Faker\Factory::create(); $users = array(array('full_name' => 'Cristian Gerardo Jaramillo Cruz', 'username' => '2015602493', 'password' => 's3cret', 'email' => '*****@*****.**', 'category_id' => 1, 'authorized' => 'on'), array('full_name' => 'Anita Alcantara Gonzalez', 'password' => 's3cret', 'email' => $faker->email, 'category_id' => 3, 'authorized' => 'on'), array('full_name' => 'Ana Cecilia Villagómez Sandoval', 'password' => 's3cret', 'email' => $faker->email, 'category_id' => 3, 'authorized' => 'on'), array('full_name' => 'Carlos Calva Cruz', 'password' => 's3cret', 'email' => $faker->email, 'category_id' => 3, 'authorized' => 'on'), array('full_name' => 'Judith Sonck Ledesma', 'password' => 's3cret', 'email' => $faker->email, 'category_id' => 3, 'authorized' => 'on'), array('full_name' => 'Alberto Isaac Ramírez Pérez', 'password' => 's3cret', 'email' => $faker->email, 'category_id' => 3, 'authorized' => 'on'), array('full_name' => 'Juan Carlos Cruz Romero', 'password' => 's3cret', 'email' => $faker->email, 'category_id' => 3, 'authorized' => 'on')); foreach ($users as $user) { User::create($user); } }
/** * @return void * @throws ManagerValidationException */ public function update() { if (is_null($this->entity)) { throw new \Exception('InvalidNotFoundUser'); } $id = $this->entity->id; $validation = \Validator::make($this->data, $this->rules); if ($validation->fails()) { $users = User::where('email', $this->data['email'])->orWhere('username', $this->data['username'])->get(); if (count($users) != 1) { throw new ManagerValidationException('Validation failed', $validation->messages()); } } if (isset($this->data['category_id'])) { $this->entity->category_id = $this->data['category_id']; } $this->entity->update($this->prepareData($this->data)); }