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

Emokores's avatar

Inertia not handling data from show() method (ReactJS)

In my show() method I need to display details of the record to the user. However, when I pass the data to the frontend, it is undefined.


public function show(Order $order) : InertiaResponse
    {
        if(Gate::allows('is-admin-cashier')) return inertia('Orders/Details', [
            'order' => $order->with(['customer', 'user', 'service',]),
            'payments' => Payment::query()->where('order_id', $order)->with(['user', 'order']),
        ]);

        return abort(403);
    }

I used the usePage().props to pass the data to the frontend in my Details.js page:


const { order } = usePage().props

When I console.log(order) I get an empty object. I don't know why it is so.

0 likes
4 replies
anilkumarthakur60's avatar

what do you get while

        if(Gate::allows('is-admin-cashier')) {
$data['order' ]= $order->with(['customer', 'user', 'service',]);
            $data['payments'] = Payment::query()->where('order_id', $order)->with(['user', 'order']);
return $data;
}

what do you get?

if you are using typescript then


interface Props {
  order: {
    data: Order;
  };
}

export default function OrderShow(props: Props) {
  console.log(props);
Emokores's avatar

The problem is with my $order->with(['customer', 'user', 'service']) query. It gives me a null. Is there any better way I can pull this off using Route-Model binding?

Please or to participate in this conversation.