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

vbasky's avatar

Stripe Integration Question

In the chapter

https://laracasts.com/series/how-to-accept-payments-with-stripe/episodes/4

I would like to know in the line

$product = Product::findOrFail(request('product'))

Where is the value request('product') being passed when the form is submitted?

Can someone share light on how this is done?

0 likes
1 reply
martinbean's avatar

@VikramBhaskaran request() is a helper method that accesses the current HTTP request. Passing it a string parameter (i.e. product) then accesses that attributed submitted as form data.

This question is why I prefer to be a bit more "explicit" in my code, and will do something like:

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class SomeController extends Controller
{
    public function someMethod(Request $request)
    {
        $product = $request->input('product');

        // No question where product is coming from now
    }
}

Please or to participate in this conversation.