public function insertBorrower($id) { $borrower_id = Auth::user()->student_id; $contract = Contract::where('contract_id', $id)->first(); $contract->borrower_id = $borrower_id; $contract->save(); $student = Student::where('student_id', $borrower_id)->first(); $data = array('email' => $student->email, 'first_name' => $student->first_name); Mail::send('emails.success', $data, function ($message) use($data) { $message->from('*****@*****.**', 'ShareBook'); $message->to($data['email']); $message->subject('Successfully Borrowed Textbook!'); }); $due_date = new DateTime($contract->due_date); $reminder_date = $due_date->modify('-1 Week'); $today = new DateTime("now"); $interval = $reminder_date->getTimestamp() - $today->getTimestamp(); Mail::later($interval, 'emails.reminder', $data, function ($message) use($data) { $message->from('*****@*****.**', 'ShareBook'); $message->to($data['email']); $message->subject('Due Date Reminder'); }); $book = Book::where('book_id', $contract->book_id); $book->delete(); \Session::flash('message', 'Successfully borrowed textbook!'); return view('index'); }
public function getBook() { $books = Book::where('book_id', '=', $this->book_id)->get(); foreach ($books as $book) { $book_name = $book->name; } return $book_name; }