/** * Get who it's tied to in one shot * * @return array[0] the amount or Carbon date by which this capital is set to begin * @return array[1] the Income or Expense object **/ public function endsWhen() { $ends = (string) $this->end_at . '_end'; $object = FALSE; if ($this->end_at === 'income') { $object = Income::findOrFail($this->income_end_id); } if ($this->end_at === 'expenses') { $object = Expense::findOrFail($this->expenses_end_id); } return array($object, $this->{$ends}); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $income = Income::findOrFail($id); $income->delete(); return redirect()->route('incomes.index')->with('message', 'Item deleted successfully.'); }
/** * Deletes an income * * @param $id * * @return array */ public function delete($id) { $income = $this->income->findOrFail($id); $income->delete($id); }