public function markahPost(Request $request) { $request->all(); // Validation $validation = Validator::make($request->all(), ['position' => 'required|min:5', 'mark' => 'required|numeric']); if ($validation->fails()) { Session::flash('error', 'Ralat. Sila isikan input dengan format yang betul.'); return redirect()->back(); } $markah = new Markah(); $markah->position = ucwords($request->get('position')); $markah->mark = $request->get('mark'); if ($markah->save()) { Session::flash('success', 'Berjaya. Markah berjaya direkod.'); } return redirect()->back(); }
public function indexPost(Request $request) { $validation = Validator::make($request->all(), ['position' => 'required|min:5', 'mark' => 'required|numeric']); if ($validation->fails()) { Session::flash('error', 'Gagal. Permarkahan gagal direkodkan.'); return redirect()->back(); } // check redundunt position $markah = Markah::where('position', strtoupper($request->get('position')))->get(); if (!$markah->isEmpty()) { Session::flash('error', 'Gagal. Jawatan tersebut telah wujud.'); return redirect()->back(); } $markah = new Markah(); $markah->position = strtoupper($request->get('position')); $markah->mark = $request->get('mark'); $markah->ppk_id = Auth::user()->ppk_id; if ($markah->save()) { Session::flash('success', 'Permarkahan berjaya direkod.'); } return redirect()->back(); }