public function onContactSend() { $rules = ['author' => 'required', 'mail' => 'required|email', '_message' => 'required|min:10', 'arrival' => 'required|date', 'departure' => 'required|date', 'mark' => 'required|numeric']; $post = post(); $validator = Validator::make($post, $rules); if ($validator->fails()) { foreach (array_keys($validator->failed()) as $error) { $errors[$error] = "1"; } //print_r($validator->messages()); $this->page['errors'] = $errors; //$this->page['success'] $this->page['post'] = post(); } else { $testimonial = new Testimonial(); $testimonial->author = $post['author']; $testimonial->email = $post['mail']; $testimonial->message = $post['_message']; $testimonial->arrival = date('Y-m-d', strtotime($post['arrival'])); $testimonial->departure = date('Y-m-d', strtotime($post['departure'])); $testimonial->mark = $post['mark']; $testimonial->approved = 0; if ($testimonial->save()) { $post['id'] = $testimonial->id; Mail::send('cptmeatball.testimonium::mail.message', $post, function ($message) { $message->to('*****@*****.**', "Gastenboek Haus Holunder"); }); $this->page['success'] = "1"; } } }