Skip to content

Instantly share code, notes, and snippets.

Created January 2, 2018 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/235b0c4929a000c880cde30ef0d29d64 to your computer and use it in GitHub Desktop.
Save anonymous/235b0c4929a000c880cde30ef0d29d64 to your computer and use it in GitHub Desktop.
Constant expression contains invalid operations
protected $rules = array(
'brand'=>'required',
'model'=>'required',
'source'=>'required',
'name'=>'required|string|min:3|max:255',
'email'=>['nullable','email','max:255',new EmailValidator()],// this line is causing error
'phone'=>'required|digits_between:10,15',
'alt_phone'=>'nullable|digits_between:10,15',
'address'=>'required|string|min:3',
'description'=>'required|string|min:3',
'state'=>'required',
'city'=>'required',
'follow_date'=>'required|date|after:today',
'visit_date'=>'required|date|after:today',
);
//Validation
public function store(Request $request){
$lead = new Lead;
if ($lead->validate($request->all())) {
$request->request->add([
'created_by' => Auth::user()->id,
'follow_date' =>date('Y-m-d', strtotime($request->follow_date)),
'visit_date' =>date('Y-m-d', strtotime($request->visit_date)),
'state'=>state::where('id',$request->state)->first()->name
]);
Lead::create($request->except('_token'));
} else {
return back()->withErrors($lead->errors())->withInput($request->all());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment