A
A
Agelios2018-06-27 15:39:23
Laravel
Agelios, 2018-06-27 15:39:23

Why can't I see the status?

I want to test the status. But it only works that way and I don't understand why? Can someone tell me how to do it right

$order = factory(Order::class)->create();
        $order->setStatus('status');

        $status = $order->status; // null
        $status = Order::find($order->order_id)->status; // find status

setStatus
public function setStatus($status, $timestamp = null)
    {
      
        return $this->status()->create([
            'status' => $status,
            'timestamp' => $timestamp
        ]);
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Agelios, 2018-06-27
@Agelios

Answered on another portal.
$order->fresh()->status;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question