I am creating a Reply model and then trying to return the object with it's owner relation. Here is the code that returns an empty object:
//file: Thread.php
//this returns an empty object !!??
public function addReply($reply)
{
$new_reply = $this->replies()->create($reply);
return $new_reply->with('owner');
}
However, if i swap the with() method for load() method to load the owner relation, i get the expected result. That is the reply object is returned with it's associated owner relation:
//this works
{
$new_reply = $this->replies()->create($reply);
return $new_reply->load('owner');
}
i don't understand why. Looking for clarifications.
Thanks, Yeasir