Skip to content

Use a private controller method from artisan tinker

Sometimes I’ve found myself with the need to call a controller method by hand within artisan tinker.  It’s not too hard to do, you just need to use make to create an instance of the controller and then you can call a specific method and include parameters as well.

1
2
$controller = app()->make('App\Http\Controllers\Controller');
$return = app()->call([$controller, 'method'], [$variable1, $variable2]);
Published inPHPScripting

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *