Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

hjortur17's avatar

How to parse this.

How to parse this:

?carNumber=PXT82&carSize=Fólksbíll&carType=Fiat&carSubtype=500x&carColor=Hvítur&name=Hjörtur Freyr Lárusson&socialId=1712992769&[email protected]&phone=8425759&dropOffDate=13/08/2019&dropOffTime=08:30&pickUpDate=15/08/2019&pickUpTime=08:45&flightNumber=FI123&numberOfDays=2&priceForDays=1000&paidPrice=20400

I need the data from this string to fill in my form:

$booking = Booking::create([
            'carNumber' => request('carNumber'),
            'carSize' => request('carSize'),
            'carType' => request('carType'),
            'carSubtype' => request('carSubtype'),
            'carColor' => request('carColor'),

            'name' => request('name'),
            'socialId' => request('socialId'),
            'email' => request('email'),
            'phone' => request('phone'),

            'dropOffDate' => request('dropOffDate'),
            'dropOffTime' => request('dropOffTime'),
            'pickUpDate' => request('pickUpDate'),
            'pickUpTime' => request('pickUpTime'),
            'flightNumber' => request('flightNumber'),

            'numberOfDays' => request('numberOfDays'),
            'priceForDays' => request('priceForDays'),

            'paidPrice' => request('paidPrice')
        ]);
0 likes
2 replies
Nakov's avatar
Nakov
Best Answer
Level 73

It seems like you are doing it okay, does it work, or is there an error that you get?

Make sure that you add all the fields in the $fillable array within your Booking model because you are hitting the mass-assignment protection, so it won't store the values otherwise.

bugsysha's avatar

What about parse_str()? Maybe even request()->all()? Or request()->only()?

Please or to participate in this conversation.