Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
In this tutorial, I will give you an example of “How to create Multiple step form in Laravel 8”, So you can easily apply it with your laravel 5, laravel 6, laravel 7, laravel 8, and laravel 9 application.
First, what we’re doing here, This is the example :
We will create a query page with two wizard steps. In the first step, we collect all the user-selected values in the session and we set all these values in this form if the user wants to edit his previous details after going in the second form he easily does this, and after that,
We collect user details in the second step and then we store all these values in our query table in the database in the Laravel application.
Let’s see the below preview and follow the below step.
Generating Migration with Model :
php artisan make:model TripQuery -m
Migration Structures :
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateTripQueriesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('trip_queries', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email');
$table->string('phone');
$table->string('trip_place');
$table->string('trip_intrest');
$table->string('no_of_travelers');
$table->string('trip_budget_per_person');
$table->string('trip_duration');
$table->string('trip_month_year');
$table->string('trip_stage_planning');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('trip_queries');
}
}
Run Migration :
php artisan migrate
Create a Controller :
php artisan make:controller TripQueryController
routes\web.php :
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\TripQueryController;
/*
|--------------------------------------------------------------------------
| Web Routes for Frontend
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
#Manage Trip Query Step-By-Step Form
Route::get('/create-my-tripstep-1', [TripQueryController::class, 'createQueryStep1'])->name('create.query.step1');
Route::post('/post-my-tripstep-1', [TripQueryController::class, 'postQueryStep1'])->name('post.query.step1');
Route::get('/create-my-tripstep-2', [TripQueryController::class, 'createQueryStep2'])->name('create.query.step2');
Route::post('/post-my-tripstep-2', [TripQueryController::class, 'postQueryStep2'])->name('post.query.step2');
resources\views\querystep1.blade.php
<section class="trip-bg">
<div class="container ServicesPageBanner">
<div class="row d-flex justify-content-center align-items-center">
<div class="col-md-6">
<h4 class=" text-center inner-text-title font-weight-bold mb-sm-2">Trip </h4>
<form method="post" action="{{ route('post.query.step1') }}">
@csrf
<h4 class="inner-text-title font-weight-bold mb-sm-2 d-none">Trip </h4>
@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<div class="col-sm-12 float-right">
@if(Session::has('flash_message_success'))
<div class="alert alert-success alert-dismissible p-2">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong>Success!</strong> {!! session('flash_message_success')!!}.
</div>
@endif
</div>
<div class="tab">
<h3 class="mb-3">1. Trip Details</h3>
<div class="row">
<div class="form-group mb-3 col-lg-12">
<select class="custom-select my-1 mr-sm-2 input-1" name="trip_place" required>
<option value="" selected>Where do you want to go?</option>
<option>North India</option>
<option>South India</option>
<option>Central</option>
<option>West India</option>
<option>Himalayas</option>
<option>Islands Beaches</option>
</select>
</div>
<div class="form-group mb-3 col-lg-12">
<select class="custom-select my-1 mr-sm-2 input-1" name="trip_intrest" required>
<option value="" selected>Your Interest</option>
<option>Adventure</option>
<option>Heritage Culture</option>
<option>Nature Landscapes</option>
<option>Wildlife Safaris</option>
<option>North India</option>
<option>Wine Food</option>
<option>Beaches</option>
</select>
</div>
<div class="form-group mb-3 col-lg-6">
<select class="custom-select my-1 mr-sm-2 input-1" name="no_of_travelers" required>
<option value="" selected>No. of Travelers</option>
<option>1 traveler</option>
<option>2 traveler</option>
<option>3 traveler</option>
<option>4 traveler</option>
<option>5 traveler</option>
<option>6 traveler</option>
<option>6+ traveler</option>
</select>
</div>
<div class="form-group mb-3 col-lg-6">
<select class="custom-select my-1 mr-sm-2 input-1" name="trip_budget_per_person" required>
<option value="" selected>Your Budget / person</option>
<option>₹ 3,000 to ₹ 4,000</option>
<option>₹ 4,000 to ₹ 6,000</option>
<option>₹ 6,000 to ₹ 8,000</option>
<option>₹ 8,000 to ₹ 10,000</option>
<option>₹ 10,000+</option>
</select>
</div>
<div class="form-group mb-3 col-lg-6">
<select class="custom-select my-1 mr-sm-2 input-1" name="trip_duration" required>
<option value="" selected>Trip Duration in Days</option>
<option>One</option>
<option>Two</option>
<option>Three</option>
<option>Four</option>
<option>Five</option>
<option>Six</option>
<option>Six+</option>
</select>
</div>
<div class="form-group mb-3 col-lg-6">
<select class="custom-select my-1 mr-sm-2 input-1" name="trip_month_year" required>
<option value="" selected>When?</option>
<option>July 2022</option>
<option>August 2022</option>
<option>September 2022</option>
<option>October 2022</option>
<option>November 2022</option>
<option>December 2022</option>
<option>January 2023</option>
<option>February 2023</option>
<option>March 2023</option>
<option>April 2023</option>
<option>May 2023</option>
<option>June 2023</option>
<option>July 2023</option>
<option>August 2023</option>
<option>September 2023</option>
<option>October 2023</option>
<option>November 2023</option>
<option>December 2023</option>
<option>January 2024</option>
<option>February 2024</option>
<option>March 2024</option>
<option>April 2024</option>
<option>May 2024</option>
<option>June 2024</option>
<option>July 2024</option>
</select>
</div>
<div class="form-group mb-3 col-lg-12">
<select class="custom-select my-1 mr-sm-2 input-1" name="trip_stage_planning" required>
<option value="" selected>What Stage of Planning you are?</option>
<option>Definitely traveling, not sure which country yet</option>
<option>I want to book a trip</option>
</select>
</div>
</div>
</div>
<div style="overflow:auto;">
<div class="text-center">
<button type="submit" class="w-100 mb-3 next-btn">Next</button>
</div>
</div>
</form>
</div>
</div>
</div>
</section>
resources\views\querystep2.blade.php
<section class="trip-bg">
<div class="container ServicesPageBanner">
<div class="row d-flex justify-content-center align-items-center">
<div class="col-md-6">
<h4 class=" text-center inner-text-title font-weight-bold mb-sm-2">Trip </h4>
@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<form method="post" action="{{ route('post.query.step2') }}">
@csrf
<h4 class="inner-text-title font-weight-bold mb-sm-2 d-none">Trip </h4>
<div class="tab">
<h3 class="mb-3">2. Your Information</h3>
<input class="form-control my-3 input-1" type="text" placeholder="Full Name" name="name">
<input class="form-control my-3 input-1" type="emal" placeholder="Email address" name="email">
<input class="form-control my-3 input-1" type="text" placeholder="Phone No." name="phone">
</div>
<div style="overflow:auto;">
<div class="text-center">
<button type="submit" class="w-100 mb-3 next-btn">Submit</button>
<a href="/create-my-tripstep-1"><button class="w-100 mb-3 prev-btn" type="button">BACK TO TRIP DETAILS</button></a>
</div>
</div>
</form>
</div>
</div>
</div>
</section>
app\Http\Controllers\TripQueryController.php :
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Session;
use App\Models\TripQuery;
class TripQueryController extends Controller
{
#Manage Trip Query
public function createQueryStep1(Request $request){
$tripquery = $request->session()->get('tripquery');
return view('querystep1',compact('tripquery'));
}
public function postQueryStep1(Request $request){
$validatedData = $request->validate([
'trip_place' => 'required',
'trip_intrest' => 'required',
'no_of_travelers' => 'required',
'trip_budget_per_person' => 'required',
'trip_duration' => 'required',
'trip_month_year' => 'required',
'trip_stage_planning' => 'required',
]);
if(empty($request->session()->get('tripquery'))){
$tripquery = new TripQuery();
$tripquery->fill($validatedData);
$request->session()->put('tripquery', $tripquery);
}else{
$tripquery = $request->session()->get('tripquery');
$tripquery->fill($validatedData);
$request->session()->put('tripquery', $tripquery);
}
return redirect()->route('create.query.step2');
}
public function createQueryStep2(Request $request){
if (session()->missing('tripquery')) {
return redirect()->route('create.query.step1');
}
$tripquery = $request->session()->get('tripquery');
return view('querystep2',compact('tripquery', $tripquery));
}
public function postQueryStep2(Request $request){
$validatedData = $request->validate([
'name' => 'required',
'email' => 'required',
'phone' => 'required|numeric',
]);
$tripquery = $request->session()->get('tripquery');
$tripdata = new TripQuery();
$tripdata->name = $request->name;
$tripdata->email = $request->email;
$tripdata->phone = $request->phone;
$tripdata->trip_place = $tripquery->trip_place;
$tripdata->trip_intrest = $tripquery->trip_intrest;
$tripdata->no_of_travelers = $tripquery->no_of_travelers;
$tripdata->trip_budget_per_person = $tripquery->trip_budget_per_person;
$tripdata->trip_duration = $tripquery->trip_duration;
$tripdata->trip_month_year = $tripquery->trip_month_year;
$tripdata->trip_stage_planning = $tripquery->trip_stage_planning;
$tripdata->save();
$request->session()->forget('tripquery');
return redirect()->route('create.query.step1')->with('flash_message_success','Thank You! Your Dream Trip is Underway.');
}
}
Note: We will redirect back the user if he is not filling in data in step 1 and directly he hit the step 2 URL.
public function createQueryStep2(Request $request){
if (session()->missing('tripquery')) {
return redirect()->route('create.query.step1');
}
}
Read also:- How to add the canonical tag in Laravel.
Validating Form Request
#Query Form one
$validatedData = $request->validate([
'trip_place' => 'required',
'trip_intrest' => 'required',
'no_of_travelers' => 'required',
'trip_budget_per_person' => 'required',
'trip_duration' => 'required',
'trip_month_year' => 'required',
'trip_stage_planning' => 'required',
]);
#Query Form two
$validatedData = $request->validate([
'name' => 'required',
'email' => 'required',
'phone' => 'required|numeric',
]);
Return and set values in Blade file using Session
After submitting the first step from we collect all the request data and store all the data in session and pass it into our blade file to set in values.
$tripquery = $request->session()->get('tripquery');
return view('querystep1',compact('tripquery'));
resources\views\querystep1.blade.php
<section class="trip-bg">
<div class="container ServicesPageBanner">
<div class="row d-flex justify-content-center align-items-center">
<div class="col-md-6">
<h4 class=" text-center inner-text-title font-weight-bold mb-sm-2">Trip </h4>
<form method="post" action="{{ route('post.query.step1') }}">
@csrf
<h4 class="inner-text-title font-weight-bold mb-sm-2 d-none">Trip </h4>
@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<div class="col-sm-12 float-right">
@if(Session::has('flash_message_success'))
<div class="alert alert-success alert-dismissible p-2">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong>Success!</strong> {!! session('flash_message_success')!!}.
</div>
@endif
</div>
<div class="tab">
<h3 class="mb-3">1. Trip Details</h3>
<div class="row">
<div class="form-group mb-3 col-lg-12">
<select class="custom-select my-1 mr-sm-2 input-1" name="trip_place" required>
<option value="" selected>Where do you want to go?</option>
<option {{{ (isset($tripquery->trip_place) && $tripquery->trip_place == 'North India') ? "selected=\"selected\"" : "" }}}>North India</option>
<option {{{ (isset($tripquery->trip_place) && $tripquery->trip_place == 'South India') ? "selected=\"selected\"" : "" }}}>South India</option>
<option {{{ (isset($tripquery->trip_place) && $tripquery->trip_place == 'Central') ? "selected=\"selected\"" : "" }}}>Central</option>
<option {{{ (isset($tripquery->trip_place) && $tripquery->trip_place == 'West India') ? "selected=\"selected\"" : "" }}}>West India</option>
<option {{{ (isset($tripquery->trip_place) && $tripquery->trip_place == 'Himalayas') ? "selected=\"selected\"" : "" }}}>Himalayas</option>
<option {{{ (isset($tripquery->trip_place) && $tripquery->trip_place == 'Islands Beaches') ? "selected=\"selected\"" : "" }}}>Islands Beaches</option>
</select>
</div>
<div class="form-group mb-3 col-lg-12">
<select class="custom-select my-1 mr-sm-2 input-1" name="trip_intrest" required>
<option value="" selected>Your Interest</option>
<option {{{ (isset($tripquery->trip_intrest) && $tripquery->trip_intrest == 'Adventure') ? "selected=\"selected\"" : "" }}}>Adventure</option>
<option {{{ (isset($tripquery->trip_intrest) && $tripquery->trip_intrest == 'Heritage Culture') ? "selected=\"selected\"" : "" }}}>Heritage Culture</option>
<option {{{ (isset($tripquery->trip_intrest) && $tripquery->trip_intrest == 'Nature Landscapes') ? "selected=\"selected\"" : "" }}}>Nature Landscapes</option>
<option {{{ (isset($tripquery->trip_intrest) && $tripquery->trip_intrest == 'Wildlife Safaris') ? "selected=\"selected\"" : "" }}}>Wildlife Safaris</option>
<option {{{ (isset($tripquery->trip_intrest) && $tripquery->trip_intrest == 'North India') ? "selected=\"selected\"" : "" }}}>North India</option>
<option {{{ (isset($tripquery->trip_intrest) && $tripquery->trip_intrest == 'Wine Food') ? "selected=\"selected\"" : "" }}}>Wine Food</option>
<option {{{ (isset($tripquery->trip_intrest) && $tripquery->trip_intrest == 'Beaches') ? "selected=\"selected\"" : "" }}}>Beaches</option>
</select>
</div>
<div class="form-group mb-3 col-lg-6">
<select class="custom-select my-1 mr-sm-2 input-1" name="no_of_travelers" required>
<option value="" selected>No. of Travelers</option>
<option {{{ (isset($tripquery->no_of_travelers) && $tripquery->no_of_travelers == '1 traveler') ? "selected=\"selected\"" : "" }}}>1 traveler</option>
<option {{{ (isset($tripquery->no_of_travelers) && $tripquery->no_of_travelers == '2 traveler') ? "selected=\"selected\"" : "" }}}>2 traveler</option>
<option {{{ (isset($tripquery->no_of_travelers) && $tripquery->no_of_travelers == '3 traveler') ? "selected=\"selected\"" : "" }}}>3 traveler</option>
<option {{{ (isset($tripquery->no_of_travelers) && $tripquery->no_of_travelers == '4 traveler') ? "selected=\"selected\"" : "" }}}>4 traveler</option>
<option {{{ (isset($tripquery->no_of_travelers) && $tripquery->no_of_travelers == '5 traveler') ? "selected=\"selected\"" : "" }}}>5 traveler</option>
<option {{{ (isset($tripquery->no_of_travelers) && $tripquery->no_of_travelers == '6 traveler') ? "selected=\"selected\"" : "" }}}>6 traveler</option>
<option {{{ (isset($tripquery->no_of_travelers) && $tripquery->no_of_travelers == '6+ traveler') ? "selected=\"selected\"" : "" }}}>6+ traveler</option>
</select>
</div>
<div class="form-group mb-3 col-lg-6">
<select class="custom-select my-1 mr-sm-2 input-1" name="trip_budget_per_person" required>
<option value="" selected>Your Budget / person</option>
<option {{{ (isset($tripquery->trip_budget_per_person) && $tripquery->trip_budget_per_person == '₹ 3,000 to ₹ 4,000') ? "selected=\"selected\"" : "" }}}>₹ 3,000 to ₹ 4,000</option>
<option {{{ (isset($tripquery->trip_budget_per_person) && $tripquery->trip_budget_per_person == '₹ 4,000 to ₹ 6,000') ? "selected=\"selected\"" : "" }}}>₹ 4,000 to ₹ 6,000</option>
<option {{{ (isset($tripquery->trip_budget_per_person) && $tripquery->trip_budget_per_person == '₹ 6,000 to ₹ 8,000') ? "selected=\"selected\"" : "" }}}>₹ 6,000 to ₹ 8,000</option>
<option {{{ (isset($tripquery->trip_budget_per_person) && $tripquery->trip_budget_per_person == '₹ 8,000 to ₹ 10,000') ? "selected=\"selected\"" : "" }}}>₹ 8,000 to ₹ 10,000</option>
<option {{{ (isset($tripquery->trip_budget_per_person) && $tripquery->trip_budget_per_person == '₹ 10,000+') ? "selected=\"selected\"" : "" }}}>₹ 10,000+</option>
</select>
</div>
<div class="form-group mb-3 col-lg-6">
<select class="custom-select my-1 mr-sm-2 input-1" name="trip_duration" required>
<option value="" selected>Trip Duration in Days</option>
<option {{{ (isset($tripquery->trip_duration) && $tripquery->trip_duration == 'One') ? "selected=\"selected\"" : "" }}}>One</option>
<option {{{ (isset($tripquery->trip_duration) && $tripquery->trip_duration == 'Two') ? "selected=\"selected\"" : "" }}}>Two</option>
<option {{{ (isset($tripquery->trip_duration) && $tripquery->trip_duration == 'Three') ? "selected=\"selected\"" : "" }}}>Three</option>
<option {{{ (isset($tripquery->trip_duration) && $tripquery->trip_duration == 'Four') ? "selected=\"selected\"" : "" }}}>Four</option>
<option {{{ (isset($tripquery->trip_duration) && $tripquery->trip_duration == 'Five') ? "selected=\"selected\"" : "" }}}>Five</option>
<option {{{ (isset($tripquery->trip_duration) && $tripquery->trip_duration == 'Six') ? "selected=\"selected\"" : "" }}}>Six</option>
<option {{{ (isset($tripquery->trip_duration) && $tripquery->trip_duration == 'Six+') ? "selected=\"selected\"" : "" }}}>Six+</option>
</select>
</div>
<div class="form-group mb-3 col-lg-6">
<select class="custom-select my-1 mr-sm-2 input-1" name="trip_month_year" required>
<option value="" selected>When?</option>
<option {{{ (isset($tripquery->trip_month_year) && $tripquery->trip_month_year== 'July 2022') ? "selected=\"selected\"" : "" }}}>July 2022</option>
<option {{{ (isset($tripquery->trip_month_year) && $tripquery->trip_month_year == 'August 2022') ? "selected=\"selected\"" : "" }}}>August 2022</option>
<option {{{ (isset($tripquery->trip_month_year) && $tripquery->trip_month_year == 'September 2022') ? "selected=\"selected\"" : "" }}}>September 2022</option>
<option {{{ (isset($tripquery->trip_month_year) && $tripquery->trip_month_year == 'October 2022') ? "selected=\"selected\"" : "" }}}>October 2022</option>
<option {{{ (isset($tripquery->trip_month_year) && $tripquery->trip_month_year == 'November 2022') ? "selected=\"selected\"" : "" }}}>November 2022</option>
<option {{{ (isset($tripquery->trip_month_year) && $tripquery->trip_month_year == 'December 2022') ? "selected=\"selected\"" : "" }}}>December 2022</option>
<option {{{ (isset($tripquery->trip_month_year) && $tripquery->trip_month_year == 'January 2023') ? "selected=\"selected\"" : "" }}}>January 2023</option>
<option {{{ (isset($tripquery->trip_month_year) && $tripquery->trip_month_year == 'February 2023') ? "selected=\"selected\"" : "" }}}>February 2023</option>
<option {{{ (isset($tripquery->trip_month_year) && $tripquery->trip_month_year == 'March 2023') ? "selected=\"selected\"" : "" }}}>March 2023</option>
<option {{{ (isset($tripquery->trip_month_year) && $tripquery->trip_month_year == 'April 2023') ? "selected=\"selected\"" : "" }}}>April 2023</option>
<option {{{ (isset($tripquery->trip_month_year) && $tripquery->trip_month_year == 'May 2023') ? "selected=\"selected\"" : "" }}}>May 2023</option>
<option {{{ (isset($tripquery->trip_month_year) && $tripquery->trip_month_year == 'June 2023') ? "selected=\"selected\"" : "" }}}>June 2023</option>
<option {{{ (isset($tripquery->trip_month_year) && $tripquery->trip_month_year == 'July 2023') ? "selected=\"selected\"" : "" }}}>July 2023</option>
<option {{{ (isset($tripquery->trip_month_year) && $tripquery->trip_month_year == 'August 2023') ? "selected=\"selected\"" : "" }}}>August 2023</option>
<option {{{ (isset($tripquery->trip_month_year) && $tripquery->trip_month_year == 'September 2023') ? "selected=\"selected\"" : "" }}}>September 2023</option>
<option {{{ (isset($tripquery->trip_month_year) && $tripquery->trip_month_year == 'October 2023') ? "selected=\"selected\"" : "" }}}>October 2023</option>
<option {{{ (isset($tripquery->trip_month_year) && $tripquery->trip_month_year == 'November 2023') ? "selected=\"selected\"" : "" }}}>November 2023</option>
<option {{{ (isset($tripquery->trip_month_year) && $tripquery->trip_month_year == 'December 2023') ? "selected=\"selected\"" : "" }}}>December 2023</option>
<option {{{ (isset($tripquery->trip_month_year) && $tripquery->trip_month_year == 'January 2024') ? "selected=\"selected\"" : "" }}}>January 2024</option>
<option {{{ (isset($tripquery->trip_month_year) && $tripquery->trip_month_year == 'February 2024') ? "selected=\"selected\"" : "" }}}>February 2024</option>
<option {{{ (isset($tripquery->trip_month_year) && $tripquery->trip_month_year == 'March 2024') ? "selected=\"selected\"" : "" }}}>March 2024</option>
<option {{{ (isset($tripquery->trip_month_year) && $tripquery->trip_month_year == 'April 2024') ? "selected=\"selected\"" : "" }}}>April 2024</option>
<option {{{ (isset($tripquery->trip_month_year) && $tripquery->trip_month_year == 'May 2024') ? "selected=\"selected\"" : "" }}}>May 2024</option>
<option {{{ (isset($tripquery->trip_month_year) && $tripquery->trip_month_year == 'June 2024') ? "selected=\"selected\"" : "" }}}>June 2024</option>
<option {{{ (isset($tripquery->trip_month_year) && $tripquery->trip_month_year == 'July 2024') ? "selected=\"selected\"" : "" }}}>July 2024</option>
</select>
</div>
<div class="form-group mb-3 col-lg-12">
<select class="custom-select my-1 mr-sm-2 input-1" name="trip_stage_planning" required>
<option value="" selected>What Stage of Planning you are?</option>
<option {{{ (isset($tripquery->trip_stage_planning) && $tripquery->trip_stage_planning == 'Definitely traveling, not sure which country yet') ? "selected=\"selected\"" : "" }}}>Definitely traveling, not sure which country yet</option>
<option {{{ (isset($tripquery->trip_stage_planning) && $tripquery->trip_stage_planning == 'I want to book a trip') ? "selected=\"selected\"" : "" }}}>I want to book a trip</option>
</select>
</div>
</div>
</div>
<div style="overflow:auto;">
<div class="text-center">
<button type="submit" class="w-100 mb-3 next-btn">Next</button>
</div>
</div>
</form>
</div>
</div>
</div>
</section>
Get step-1 parameters using session
$tripquery = $request->session()->get('tripquery');
Finally Store all these requests and session data
public function postQueryStep2(Request $request)
{
$tripquery = $request->session()->get('tripquery');
$tripdata = new TripQuery();
$tripdata->name = $request->name;
$tripdata->email = $request->email;
$tripdata->phone = $request->phone;
$tripdata->trip_place = $tripquery->trip_place;
$tripdata->trip_intrest = $tripquery->trip_intrest;
$tripdata->no_of_travelers = $tripquery->no_of_travelers;
$tripdata->trip_budget_per_person = $tripquery->trip_budget_per_person;
$tripdata->trip_duration = $tripquery->trip_duration;
$tripdata->trip_month_year = $tripquery->trip_month_year;
$tripdata->trip_stage_planning = $tripquery->trip_stage_planning;
$tripdata->save();
$request->session()->forget('tripquery');
return redirect()->route('create.query.step1')
->with('flash_message_success','Thank You! Your Dream Trip is Underway.');
}
Run Application :
http://127.0.0.1:8000/create-my-tripstep-1
In this article, we learned “How to create ans store Multiple step form in Laravel 8”, I hope this article will help you with your Laravel application Project.
Also Read:- Handle multiple pages using a single route in Laravel.