public function store(Request $request) { $validator = Validator::make($request->all(), ['name' => 'required|min:3|max:255|unique:contacts', 'nickname' => 'required|min:2|max:50', 'sex' => 'required']); if ($validator->fails()) { return redirect()->route('contacts.create')->withErrors($validator)->withInput(); } $contact = $this->contact->create($request->all()); return redirect()->route('contacts.show', ['id' => $contact->id]); }
public function store(Request $request) { $validator = Validator::make($request->all(), ['name' => 'required|min:3|max:255|unique:contacts', 'nickname' => 'required|min:2|max:50', 'gender' => 'required']); if ($validator->fails()) { return redirect()->route('contact.create')->withErrors($validator)->withInput(); } $contact = Contact::create($request->all()); $initial = strtoupper(substr($contact->nickname, 0, 1)); return redirect()->route('agenda.initial', ['initial' => $initial]); }