Soukaina WARACH
Soukaina WARACH

Reputation: 81

Send data using redirect action using Laravel 7

I need to use something like this one :

return redirect()->action([HomeController::class, 'index'])->with('data'=>$data);

but I don't know how ?

Upvotes: 1

Views: 99

Answers (1)

Tpojka
Tpojka

Reputation: 7111

Action method accepts two parameters which are array both. Second array is associative array of key as parameter name and value of parameter value. In your case it would be

return redirect()->action(
    [HomeController::class, 'index'], 
    ['data' => $data]
);

Docs.

Upvotes: 1

Related Questions