Yes, the eager-loaded relationship is still loaded even if it's being passed to another method. In the provided code example, the user relationship is loaded on the $task model instance in the approve method using the load method. When the $task instance is passed to the doSomething method, the user relationship will still be loaded and accessible on the $task instance.
Here's an example to demonstrate this:
public function approve(Task $task, Request $request)
{
// here we load the user relationship
$task = $task->load('user');
// and now we pass the task to another method to do something
$this->doSomething($task);
}
public static function doSomething(Task $task)
{
// is the user relationship still loaded here?
// do something here
$user = $task->user; // the user relationship is still loaded and accessible
}