/** * Run the database seeds. * * @return void */ public function run() { if (Language::get()->count() != 0) { return; } Language::create(['locale' => 'en', 'name' => 'english']); }
/** * Validate the given attributes * * @param array $attributes * @return boolean */ public function validate(array $attributes) { $id = array_get($attributes, 'id', 'NULL'); $table = $this->model->getTable(); $rules = ['locale' => "required|unique:{$table},locale,{$id}", 'name' => "required|unique:{$table},name,{$id}"]; $validator = $this->validator->make($attributes, $rules); if ($validator->fails()) { $this->errors = $validator->errors(); return false; } return true; }