with('entries', $entries) ->with('parser', $parser); } /** * Creates a new guestbook entry * * @param Request $request * @return RedirectResponse * @throws ValidationException */ public function addEntry(Request $request): RedirectResponse { $newEntry = GuestbookEntry::create($request); $response = Http::withBasicAuth(config('services.mailjet.key'), config('services.mailjet.secret'))->post('https://api.mailjet.com/v3.1/send', [ 'Messages' => [ [ 'From' => [ 'Email' => 'wah@wah.moe', 'Name' => 'wah dot moe' ], 'To' => [ [ 'Email' => 'roscoe@wah.moe', 'Name' => 'Roscoe D. Wah' ] ], 'Subject' => 'New Guestbook Entry!', 'HtmlPart' => '
Name:'.htmlentities($newEntry->name).'
IP:'.$newEntry->ip.'
Agent:'.htmlentities($newEntry->agent).'
Message:'.htmlentities($newEntry->message).'
' ] ] ]); return back()->with('success', 'Entry submitted successfully!'); } public function destroy($id): RedirectResponse { $entry = GuestbookEntry::findOrFail($id); $entry->delete(); return redirect()->route('guestbook'); } public function flag($id): RedirectResponse { $entry = GuestbookEntry::where("id", $id)->get()->first; $entry->update([ "flagged" => !$entry->flagged, ]); return redirect()->route('guestbook'); } }