搜尋

首頁  >  問答  >  主體

laravel 自訂服務,如何實現注入依賴?

  1. 透過ServiceContainer, ServiceProvider, 建立了一個自訂的服務,請問如何在服務中使用依賴注入,例如 Request, User,Cookie等

##如果直接在服務的方法中寫入User $user ,提示如下:

Argument 1 passed to App\Services\UserService::register() must be an instance of App\User, none given, called in /home/vagrant/Code/zhicheauto/car-server/app/Api /Controllers/UsersController.php on line 32 and defined

我想大声告诉你我想大声告诉你2846 天前541

全部回覆(1)我來回復

  • 迷茫

    迷茫2017-05-16 16:55:06

    沒引入?
    use AppUser

    回覆
    0
  • 取消回覆