--level used: 5I'm getting Access to an undefined property Illuminate\Database\Eloquent\Model::$status, it happens only if the model is injected in the __construct method.
OrderController.php
use App\Order;
/**
* @var Order
*/
protected $orderModel;
/**
* @param Order $orderModel
*/
public function __construct(Order $orderModel){
$this->orderModel = $orderModel;
}
In another method I have:
$order = $this->orderModel
->with('items')
->with('parcels')
->find($invoiceId);
$order->status = Order::INCOMPLETE;
It won't happen if I do:
$order = Order::with('items')
->with('parcels')
->find($invoiceId);
$order->status = Order::INCOMPLETE;
Hi,
Thank you for the report. I can confirm this is a bug. $this->orderModel->with() returns Builder without generic type for the model specified. So the default Model is used.
I can fix this, but I'd also argue that injecting a model instance and then calling find on it does not make much sense. The second example makes more sense.
🐎 6 minutes.
🐎 6 minutes.
After 11PM ❗