I have a controller method that ends in two different redirects depending on the user role, all users except one create an order and the other one doesn't, I'm trying to send some information in the session to another controller to then send to a view.
This is what I have
public function cashOrder($amount, $products, $delivery)
{
if (auth()->user()->role_id !== Role::JOKER) {
DB::beginTransaction();
//create order
DB::commit();
return redirect('cart/summary/' . $order->id);
}
$joker = collect();
$joker->products = $products;
$joker->client_id = auth()->user()->id;
$joker->charge_id = 'no_charge_cash';
$joker->charge_dateTime = date('Y-m-j H:m:s');
$joker->charge_currency = 'cash';
$joker->charge_amount = $amount;
if ($delivery) {
$joker->delivery_customer = $delivery['customer'];
$joker->delivery_phone = $delivery['phone'];
$joker->delivery_email = $delivery['email'];
}
return redirect('cart/joker_summary')->with('info', $joker);
}
I then have this route
Route::get('cart/joker_summary', 'CartController@showJokerSummaryPage');
And this method in the other controller, if I dd($joker) after setting it I do see the info but it sends the variable joker as empty to the vue component.
public function showJokerSummaryPage(Request $request) {
$joker = $request->session()->get('info');
return Inertia::render('Cart/JokerSummary', [
'joker' => $joker
]);
}
What am I doing wrong? or What is the correct way to do this?