public function create() { $rules = array('surname' => 'required', 'othernames' => 'required', 'gender' => 'required', 'birthdate' => 'required', 'mobile' => 'required', 'email' => 'required', 'postaladdress' => 'required', 'designation' => 'required'); $validation = Validator::make(Input::all(), $rules); if ($validation->fails()) { return redirect('/NewStaff')->with('form_error_message', $validation->errors()->first())->withInput(); } else { $staff = new StaffInfo(); $staff->designation_id = 1; //Input::get('designation'); $staff->Staff_Id = '1029828'; $staff->surname = Input::get('surname'); $staff->other_names = Input::get('othernames'); $staff->gender = Input::get('gender'); $staff->date_of_birth = Input::get('birthdate'); $staff->contact_no = Input::get('mobile'); $staff->email = Input::get('email'); $staff->postal_address = Input::get('postaladdress'); $staff->residential_address = Input::get('residentialaddress'); $staff->ssn = Input::get('ssn'); $staff->nok_name = Input::get('nokname'); $staff->nok_contact = Input::get('nokcontact'); $staff->nok_address = Input::get('nokcontact'); $staff->created_by = Auth::user()->get_user_id(); $staff->updated_by = Auth::user()->get_user_id(); $staff->approved_by = Auth::user()->get_user_id(); $staff->created_at = date("Y-m-d"); $staff->status = 0; $staff->save(); //$user = new User; //$user->create_new_user(); /* \Mail::send('newUserMail',['name'=>'nic','username'=>'Nic'], function($message) { $message->to('*****@*****.**')->subject('Nicholas Test Massage'); } ); */ return redirect('/ViewStaff')->with('success_message', 'New Staff Created'); } }
private function registerStaff($staff_id, $name) { if (StaffInfo::where('staff_id', '=', $staff_id)->count() > 0) { return true; } else { $staff = new StaffInfo(); $staff->staff_id = $staff_id; $staff->surname = $name; $staff->created_by = Auth::user()->get_user_id(); $staff->updated_by = Auth::user()->get_user_id(); $staff->approved_by = Auth::user()->get_user_id(); $staff->created_at = date("Y-m-d"); $staff->status = 0; if ($staff->save()) { return true; } else { return false; } } }