public function postRestrict(Request $request) { $messages = ["rplan.required" => "Plan is not select please go to your managing panel.", "rplan.exists" => "Plan is not exists.", "rplan.numeric" => "Illegal plan access.", "rcategory.required" => "Category is not selected.", "rcategory.exists" => "Category is not exists.", "rcategory.numeric" => "Illegal category selected.", "rlimit.required" => "Limitation amount is required.", "rlimit.numeric" => "Limit exceed per month should be only numbers.", "rtype.required" => "Please select what this restriction apply to.", "rtype.boolean" => "Wrong restriction type selected."]; $validator = Validator::make($request->all(), ['rplan' => 'required|numeric|exists:plan,id', 'rcategory' => 'required|numeric|exists:category,id', 'rlimit' => 'required|numeric', 'rtype' => 'required|boolean'], $messages); if ($validator->fails()) { return redirect()->back()->withErrors($validator)->withInput(); } if ($this->user == null) { $validator->errors()->add('User', 'You are not login!'); return redirect('login')->withErrors($validator); } else { $restrict = new Restrict(); $restrict->plan_id = $request->rplan; $restrict->category_id = $request->rcategory; $restrict->exceed = $request->rlimit; $restrict->for = $request->rtype; $restrict->save(); } return redirect()->back()->withInput(); }