get(); return view('admin.payroll_head.index',$data); } public function create() { $data['title'] = "Payroll Head Create"; return view('admin.payroll_head.add',$data); } public function store(Request $request) { $this->validate($request,[ 'name' => 'required' ]); $user_id = \Auth::user()->id; $ph = new PayrollHead; $ph->name = $request->name; $ph->added_by = $user_id; $ph->status = 1; $ph->save(); return redirect('admin/payroll_head')->with('msg','Data Insert Successful!'); } public function edit($id) { $data['title'] = "Payroll Head Edit"; $data['single'] = PayrollHead::find($id); return view('admin.payroll_head.edit',$data); } public function update(Request $request, $id) { $this->validate($request,[ 'name' => 'required' ]); $user_id = \Auth::user()->id; $phu = PayrollHead::find($id); $phu->name = $request->name; $phu->updated_by = $user_id; $phu->save(); return redirect('admin/payroll_head')->with('msg','Data Update Successful!'); } public function destroy($id) { PayrollHead::whereId($id)->delete(); return redirect('admin/payroll_head')->with('msg','Successfully Deleted!'); } public function statusUpdate($id) { $user_id = \Auth::user()->id; $ph_info = PayrollHead::find($id); if($ph_info->status == 0){ $ph_info->status = 1; $status = 'published'; }else{ $ph_info->status = 0; $status = 'unpublished'; } $ph_info->update(); } }