Where do you want to call it? Whithin the model's class or whitin another controller's class? Anyway you can use dependency injection
public function yourMethodWhitinTheModelClass(OrderController $controller)
{
return $controller->mailInvoice($this->id);
}
got error:
Argument 2 passed to Orders::autoPay() must be an instance of OrderController, none given, called in /var/www/haroldas.test.com/app/controllers/OrderController.php on line 137 and defined
function autoPay($user, OrderController $controller)
{
// ...
return $controller->mailInvoice($this->id);
}
got error:
Argument 2 passed to Orders::autoPay() must be an instance of OrderController, none given, called in (filename) on line (linenumber)
Aha! So you are passing a function call with only 1 variable, you need to add another variable:
function autoPay($user, OrderController $controller)
{
$nowwhereismysecondvariableplease = object_instance_of_OrderController;
return $controller->mailInvoice($this->id, $nowwhereismysecondvariableplease);
}
I would pass $controller as that variable ...
Better to invoke an event that the controller observes so you don't wind up with code that is unnecessarily bound.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community