1

I have simple question here.

$order = Order::where('unique_id', $id)->first();
$canPickup = $order->canPickup();
$order->payment_id = Input::get('payment_id');
$order->save();

$order2 = Order::where('unique_id', $id)->first();  

$canPickup;  //return false
$order->canPickup();  //return false  
$order2->canPickup();  //return true

Why $order->canPickup(); differs form $order2->canPickup(); how I can achieve this function to return new value without creating new instance? Thanks

Update:

In canPickup() method i use paymentType relationship:

public function paymentType()
{
  return $this->belongsTo('PaymentType', 'payment_id');
}

And in same method I have these results. Why these values differs?

Debugbar::warning($this->payment_id); //return 3
Debugbar::warning($this->paymentType->id); //return old value 1. 
vyckiuz
  • 157
  • 10
  • 1
    what is `canPickup` method? post the implementation – cmnardi Sep 08 '16 at 11:55
  • Did you try to execute `->canPickup()` after the `save()` in the `$order`? – cmnardi Sep 08 '16 at 12:00
  • 1
    I think is because you update just the attribute `payment_id` but not the objet `PaymentType` I find this related topic http://stackoverflow.com/questions/23642950/reloading-model-in-laravel – cmnardi Sep 08 '16 at 12:30
  • @vyckiuz can you please update your question with `canPickup()` method code? – Khuram Sep 10 '16 at 07:38

0 Answers0