/** * Get the validation rules that apply to the request. * * @return array */ public function rules() { $path = Request::path(); $id = explode("/", $path); $id = $id[count($id) - 1]; return ['name' => 'required|unique:events,name,' . $id . ',id', 'timelineDate' => 'required', 'tags' => 'required']; }
/** * Get the validation rules that apply to the request. * Dynamically apply rules based on what type of request is being made * * @return array */ public function rules() { switch (Request::path()) { case "login": $rules = ['name' => 'required|min:3|exists:users,name', 'password' => 'required|min:8|hashed']; break; // Default to registration requirements // Default to registration requirements default: $rules = ['name' => 'required|min:3|unique:users', 'email' => 'required|email|unique:users', 'password' => 'required|min:8|confirmed']; break; } return $rules; }
/** * Get the validation rules that apply to the request. * * @return array */ public function rules() { $data = Input::all(); $path = Request::path(); $id = explode("/", $path); $id = $id[count($id) - 1]; $required = array('name' => 'required|unique:media,name,' . $id . ',id', 'series' => 'required', 'collection' => 'required', 'medium' => 'required', 'timelineDate' => 'required'); if ($data['series'] == 'newSeries') { $required['newSeriesName'] = 'required|unique:series,seriesName,' . $id . ',id'; $required['newSeriesAbbr'] = 'required|not_in:newSeries|unique:series,seriesAbbreviation,' . $id . ',id'; } if ($data['collection'] == 'newCollection') { $required['newCollectionName'] = 'required|not_in:newCollection'; } if ($data['medium'] == 'newMedium') { $required['newMediumName'] = 'required|not_in:newMedium'; } return $required; }