public function run() { $categories = array(array('name' => 'admin'), array('name' => 'student'), array('name' => 'teacher')); foreach ($categories as $category) { Category::create($category); } }
/** * @return void * @throws \Exception */ public function update() { if (is_null($this->entity)) { throw new \Exception("InvalidNotFoundCategory"); } $id = $this->entity->id; $validation = \Validator::make($this->data, $this->rules); if ($validation->fails()) { $categories = Category::where('name')->get(); if (count($categories) != 1) { throw new ManagerValidationException('Validation failed', $validation->messages()); } if ($categories[0]->id != $id) { throw new \Exception('DuplicateUniqueData'); } } $this->entity->update($this->data); }