Wedding Invitation
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

MainController.php 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Http\Request;
  4. use App\Models\RSVP;
  5. use App\Models\GuestBook;
  6. class MainController extends Controller
  7. {
  8. public function main(Request $request) {
  9. $rsvp = RSVP::all();
  10. $guestbooks = GuestBook::orderBy('created_at', 'desc')->take(5)->get();
  11. $totalPages = $guestbooks->count();
  12. $host = $request->getHost();
  13. return view('digital-card', compact(['rsvp', 'guestbooks', 'totalPages', 'host']));
  14. }
  15. public function saveRsvp(Request $request) {
  16. $host = $request->getHost();
  17. if ($host == 'rsvp.aliffayuna.com') {
  18. $vip = true;
  19. } else {
  20. $vip = false;
  21. }
  22. RSVP::create([
  23. 'name' => $request->name,
  24. 'member' => $request->member,
  25. 'phone' => $request->phone,
  26. 'is_vip' => $vip
  27. ]);
  28. session()->flash('success', 'Terima kasih kerana sudi menghadirkan diri!');
  29. return response()->json(['message' => 'Terima kasih kerana sudi menghadirkan diri!']);
  30. }
  31. public function saveSpeech(Request $request) {
  32. GuestBook::create([
  33. 'name' => $request->name,
  34. 'speech' => $request->speech
  35. ]);
  36. session()->flash('success', 'Terima kasih atas ucapan anda!');
  37. return response()->json(['message' => 'Terima kasih atas ucapan anda!']);
  38. }
  39. public function fetchGuestbook(Request $request)
  40. {
  41. $page = $request->input('page', 1);
  42. $guestbook = GuestBook::orderBy('created_at', 'desc')->take(5)->get()->forPage($page, 1);
  43. return response()->json([
  44. 'guestbook' => view('partials.guestbook', ['entry' => $guestbook->first()])->render(),
  45. ]);
  46. }
  47. public function attendance() {
  48. $vips = RSVP::where('is_vip', true)->get();
  49. $generals = RSVP::where('is_vip', false)->get();
  50. return view('attendance', compact(['vips', 'generals']));
  51. }
  52. }