emfpc
4 months ago
57
11
Laravel

Passing Form information in view before saving to DB

Posted 4 months ago by emfpc

I may sound crazy but I'm trying to pass form information to a view before saving it to a DB. For the form i'm using a resource where everything is in the store method. i can pass the information to a view and see it but when i press the button the data is store. and i'm using different models in one controller.

This is the store method:

       $guest = new Guest;
       $guest->confirmation_order = rand(10000, 30000);
       $guest->name = Crypt::encryptString($request->input('name'));
       $guest->email = $request->input('email');
       $guest->mobile = Crypt::encryptString($request->input('mobile'));
       $guest->residence = Crypt::encryptString($request->input('residence'));
       $guest->office = Crypt::encryptString($request->input('office'));
       $guest->fax = Crypt::encryptString($request->input('fax'));
       $guest->address1 = Crypt::encryptString($request->input('address1'));
       $guest->address2 = Crypt::encryptString($request->input('address2'));
       $guest->city = Crypt::encryptString($request->input('city'));
       $guest->state = Crypt::encryptString($request->input('state'));
       $guest->country = Crypt::encryptString($request->input('country'));
       $guest->zip_code = Crypt::encryptString($request->input('zip_code'));
       $guest->save();

       // //Registration Fee Information
       $registrationfee = new RegistrationFee;
       $registrationfee->guest_id = $guest->id;
       $registrationfee->registration_type = Crypt::encryptString($request->input('registration_type'));
       $registrationfee->company_representative = Crypt::encryptString($request->input('company_representative'));
       $registrationfee->total_fee = $request->input('total_fee');
       $registrationfee->save();

       // //Hotel Reservation Information
       $hotel = new HotelReservation;
       $hotel->guest_id = $guest->id;
       $hotel->arrival_date = $request->input('arrival_date');//date('Y-m-d');
       $hotel->departure_date = $request->input('departure_date');//date('Y-m-d');
       $hotel->bed_selection = Crypt::encryptString($request->input('bed_selection'));
       $hotel->adults = Crypt::encryptString($request->input('adults'));
       $hotel->child = Crypt::encryptString($request->input('child'));
       $totalguest = $request->input('adults') + $request->input('child');
       $hotel->total_guest = $totalguest;
       $hotel->special_requests = Crypt::encryptString($request->input('special_requests'));
       $hotel->save();

       // //Payment Information
       $payment = new PaymentInformation;
       $payment->guest_id = $guest->id;
       $payment->creditcardnum = Crypt::encryptString($request->input('creditcardnum'));
       $payment->credit_type = Crypt::encryptString($request->input('credit_type'));
       $payment->expdate = Crypt::encryptString($request->input('expdate'));
       $payment->creditcardname = Crypt::encryptString($request->input('creditcardname'));
       $payment->seccode = Crypt::encryptString($request->input('seccode'));
       $payment->save();


 
       return view('form.registrationformviewdata', compact('guest'));```

I think i may approach this the wrong way

Please sign in or create an account to participate in this conversation.