public function payable($eid) { $basic = Salary::all()->where('eid', $eid)->pluck('basic')->first(); $advanceDeduction = $this->advanceDeduction($eid); //dd($basic - 1000); //$t = $basic + $this->balance($eid) - $advanceDeduction; //dd($t); return $basic - ($advanceDeduction != null ? $advanceDeduction : 0); }
/** * Display payment edit form * Created by smartrahat Date: 2016.01.20 Time: 05:50 AM * @param $id * @return \Illuminate\View\View */ public function editPayment($id) { $title = 'Edit Payment'; $salary = Salary::query()->findOrFail($id); $paid = Salary::all()->where('eid', $salary['eid'])->sum('paid'); $due = Salary::all()->where('eid', $salary['eid'])->sum('total'); $last = $salary['total']; $balance = $paid > $due ? $paid - $due - $last : $due - $paid - $last; $payable = $paid > $due ? $paid - $due : $due - $paid; $repository = $this->repository; return view('salary.edit_payment', compact('title', 'salary', 'repository', 'balance', 'payable')); }