public function validate() { if (is_null($this::where('name', '=', $this->name)->first())) { if (!is_null(District::where('id', '=', $this->district_id)->first())) { return true; } else { throw new ValidationException(null, null, null, array('district_id' => "Грешен ID на областта.")); } } else { throw new ValidationException(null, null, null, array('name' => "Общината вече съществува.")); } }