/** * Store a newly created resource in storage. * * @return Response */ public function store($id) { $input = Request::all(); $number = $input['envelope_number']; if (!empty($number)) { Validator::extend('envelope_number_fail', function ($attr, $value, $params) { $exists = Donor::where(array('organisation_id' => $params[0], 'envelope_number' => Input::get('envelope_number')))->first(); if ($exists) { // true is false in this case. We want to fail if items does exist return false; } return true; }); $val = Validator::make($input, ['envelope_number' => 'envelope_number_fail:' . $id]); if ($val->fails()) { return Redirect::to('/dashboard/' . $id . '/donor/create/')->withErrors($val); } $input['organisation_id'] = $id; $input['envelope_number'] = $number; $donor = Donor::create($input); } else { DB::beginTransaction(); try { $latestEnvelope = Donor::where(array('organisation_id' => $id))->orderBy('envelope_number', 'desc')->first(); $input['organisation_id'] = $id; $input['envelope_number'] = $latestEnvelope->envelope_number + 1; $donor = Donor::create($input); DB::commit(); } catch (Exception $e) { DB::rollback(); } } return redirect('/dashboard/' . $id . '/donor/view/' . $donor->id); }
public function add($donorDatas) { $thisData['name'] = $donorDatas['name']; $thisData['address'] = $donorDatas['address']; $thisData['gender'] = $donorDatas['gender']; $thisData['dob'] = $donorDatas['dob']; $thisData['contact'] = $donorDatas['contact']; $thisData['ward_number'] = $donorDatas['ward_number']; $thisData['email'] = $donorDatas['email']; $thisData['password'] = md5($donorDatas['password']); $thisData['blood_type'] = $donorDatas['blood_type']; return Donor::create($thisData); }
public function register($request) { // TODO: Implement register() method. \App\Donor::create($request->all()); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // Donor::destroy($id); return redirect(action('DonorsController@index')); }
public function store(Request $request) { \App\Donor::create($request->all()); }