/** * Save request inputs into account's revenue * @param \Illuminate\Http\Request $request * @param \App\Account $account Account * @param \App\Operation|null $operation Operation * @return void */ public function saveRevenue(Request $request, Account $account, $operation) { if (is_null($operation)) { $operation = new Revenue(); } $operation->fill(['account_id' => $account->id, 'envelope_id' => $request->get('envelope_id') ?: null, 'name' => $request->get('name'), 'amount' => $request->get('amount'), 'date' => Carbon::createFromFormat('d/m/Y', $request->get('date'))->startOfDay()])->save(); }
/** * Save request inputs into envelope's revenue * @param \Illuminate\Http\Request $request * @param \App\Envelope $envelope Envelope * @param \App\Operation|null $operation Operation * @return void */ private function saveRevenue(Request $request, Envelope $envelope, $operation = null) { if (is_null($operation)) { $operation = new Revenue(); } $operation->fill(['envelope_id' => $request->get('envelope_id'), 'account_id' => $envelope->account->id, 'name' => $request->get('name'), 'amount' => $request->get('amount'), 'date' => Carbon::createFromFormat('d/m/Y', $request->get('date'))->startOfDay()])->save(); }