Beispiel #1
0
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     $expensesss = Expense::where('project_id', '=', 0)->first();
     $expensess = Expense::where('project_id', '=', 0)->orderBy('paid_on', 'desc')->get();
     $clients = Client::orderBy('created_at', 'desc')->get();
     $projects = Project::orderBy('created_at', 'desc')->get();
     $expenses = Expense::where('project_id', '>', 0)->orderBy('paid_on', 'desc')->get();
     $payments = Payment::orderBy('created_at', 'desc')->get();
     $hours = Hour::where('amount_paid', '<', 0)->orderBy('day_worked', 'desc')->get();
     return view('home', compact('projects', 'expenses', 'payments', 'hours', 'clients', 'expensess', 'expensesss'));
 }
Beispiel #2
0
 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'));
 }
 static function clientHours($hour_id)
 {
     $hour = Hour::where('id', $hour_id)->first();
     return $hour;
 }