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 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. $allguestbooks = GuestBook::orderBy('created_at', 'desc')->get();
  13. $host = $request->getHost();
  14. return view('digital-card', compact(['rsvp', 'guestbooks', 'totalPages', 'host', 'allguestbooks']));
  15. }
  16. public function saveRsvp(Request $request) {
  17. $host = $request->getHost();
  18. if ($host == 'rsvp.aliffayuna.com') {
  19. $vip = true;
  20. } else {
  21. $vip = false;
  22. }
  23. RSVP::create([
  24. 'name' => $request->name,
  25. 'member' => $request->member,
  26. 'phone' => $request->phone,
  27. 'is_vip' => $vip
  28. ]);
  29. session()->flash('success', 'Terima kasih kerana sudi menghadirkan diri!');
  30. return response()->json(['message' => 'Terima kasih kerana sudi menghadirkan diri!']);
  31. }
  32. public function saveSpeech(Request $request) {
  33. GuestBook::create([
  34. 'name' => $request->name,
  35. 'speech' => $request->speech
  36. ]);
  37. session()->flash('success', 'Terima kasih atas ucapan anda!');
  38. return response()->json(['message' => 'Terima kasih atas ucapan anda!']);
  39. }
  40. public function fetchGuestbook(Request $request)
  41. {
  42. $page = $request->input('page', 1);
  43. $guestbook = GuestBook::orderBy('created_at', 'desc')->take(5)->get()->forPage($page, 1);
  44. return response()->json([
  45. 'guestbook' => view('partials.guestbook', ['entry' => $guestbook->first()])->render(),
  46. ]);
  47. }
  48. public function attendance() {
  49. $vips = RSVP::where('is_vip', true)->get();
  50. $generals = RSVP::where('is_vip', false)->get();
  51. return view('attendance', compact(['vips', 'generals']));
  52. }
  53. }