/** * @param $id * @return \Illuminate\Http\RedirectResponse */ public function checkin($id) { $lastTransaction = Transaction::findLatest($id); if (!$lastTransaction->get()->isEmpty() && $lastTransaction->in_or_out == 'OUT') { $transaction = new Transaction(); $transaction->in_or_out = 'IN'; $transaction->transaction_id = $this->generateTransactionId($transaction->in_or_out); $transaction->due_date = NULL; $transaction->equipment_id = $id; $transaction->username = Auth::id(); // temporary $transaction->person_id = $lastTransaction->person_id; // temporary $transaction->save(); $this->generateReceiptEmail($transaction); return redirect()->route('inventory.index'); } else { return redirect()->route('inventory.index'); } }