<?php use App\Branch; use App\User; use App\Worker; use App\WorkerPayment; // Get all the payments. $payments = array(); // Get the worker's branch Id. $worker = Worker::where('Cedula', '=', $worker)->first(); if ($worker != null) { $branchId = $worker->BranchId; $payments = WorkerPayment::where('WorkerId', '=', $worker->Id)->get(); } ?> @foreach($payments as $payment) <tr id='payment-{{ $payment->Id }}'><td>{{ $payment->Date }}</td><td>{{ $payment->WorkedDays }}</td><td>{{ $payment->VacationDays }}</td><td>{{ $payment->TotalBasic }}</td><td>{{ $payment->TotalBonus }}</td><td>{{ $payment->TotalAguinaldo }}</td><td>{{ $payment->TotalLoan }}</td><td>{{ $payment->TotalInsurance }}</td></tr> @endforeach
/** * Function that searches for past payments of worker. * * @return Response */ public function staffPaymentReprint() { // Validate Input. $validator = Validator::make(Input::all(), array('paymentId' => 'required')); if ($validator->fails()) { return response()->json(['error' => 'Informacion incompleta!']); } // Check that user is part of authorized staff. if (Auth::user()->Type != 1) { // If they are unauthorized no point in returning anything. return response()->json(array()); } $payment = WorkerPayment::find(Input::get('paymentId')); $worker = Worker::find($payment->WorkerId); $response['state'] = 'Success'; $response['paymentInfo'] = $payment; $response['worker'] = $worker; return response()->json($response); }