/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $id = $request->id; $hour = Hour::find($id); $hour->hours = $request->hours; $hour->save(); Activity::log('Updated store hours for ' . $hour->day . '.'); $request->session()->flash('status', 'Store hours were successfully updated.'); return Redirect::action('HoursController@index'); }
public function storepayment(CreatePaymentRequest $request) { $hour = Hour::find($request->employee_id); $hourspaid = $hour->where('amount_paid', '=', '')->where('employee_id', '=', $request->employee_id)->sum('hours'); $hours = Hour::where('employee_id', '=', $request->employee_id)->where('amount_paid', '=', '')->groupBy('project_id')->get(); foreach ($hours as $hour) { Expense::create(['project_id' => $hour->project_id, 'employee_id' => $request->employee_id, 'paid_on' => $request->paid_on, 'amount_paid' => round($request->amount_paid / $hourspaid * $hour->where('project_id', '=', $hour->project->id)->where('amount_paid', '=', '')->where('employee_id', '=', $request->employee_id)->sum('hours'), 2), 'reimbursment' => 2, 'office' => 2]); } $hours = Hour::where('employee_id', '=', $request->employee_id)->where('amount_paid', '=', '')->get(); foreach ($hours as $hour) { $update = Hour::where('id', '=', $hour->id)->update(['amount_paid' => round($request->amount_paid / $request->hours * $hour->hours, 2)]); } //add a Pay Check table and send all $request info over return view('hours.createpayment', compact('hours', 'hour', 'hourspaid')); }