I try to call a controller in an other controller with a parameter. I have no problem without any parameters.
return app()->call('App\Http\Controllers\AppointmentController@create');
AppointmentController.php
class AppointmentController extends Controller
{
public function create(CalendarInterface $calendar, Request $request) {
...
}
}
But I have an error when I try to pass one.
return app()->call('App\Http\Controllers\AppointmentController@create', $response);
AppointmentController.php
class AppointmentController extends Controller
{
public function create($response, CalendarInterface $calendar, Request $request) {
...
}
}
Type error: Argument 2 passed to Illuminate\Container\Container::call() must be of the type array, object given
Or if I do
return app()->call('App\Http\Controllers\AppointmentController@create', [$response]);
Type error: Argument 2 passed to App\Http\Controllers\AppointmentController::create() must implement interface App\CalendarInterface, instance of Illuminate\Http\Request given in [...]/app/Http/Controllers/AppointmentController.php:18
Use named parameters:
app()->call('App\Http\Controllers\AppointmentController@create', [
"response" => $response
]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With