config/app.php:
...
'providers' => [
...
App\Providers\CustomRegisterProvider::class,
],
Файл app/Providers/CustomRegisterProvider:
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use App\Services\CustomRegister;
class CustomRegisterProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
$this->app->bind('App\Services\CustomRegisterContract', function(){
return new CustomRegister();
});
}
}
В контроллере:
...
use App\Services\CustomRegister as Register;
class RegisterController extends Controller
{
...
/**
* Регистрация потребителя
*
* @param Request $request
*/
public function consumer(Request $request, Register $register){
...
}
}
Ошибка:
ReflectionException in Route.php line 286:
Class App\Services\CustomRegister does not exist