第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何獲取存儲(chǔ)庫實(shí)例?

如何獲取存儲(chǔ)庫實(shí)例?

PHP
長風(fēng)秋雁 2023-05-26 14:24:49
我在 Laravel 存儲(chǔ)庫中很新。我正在使用l5-repository 包。當(dāng)我創(chuàng)建資源控制器時(shí),它創(chuàng)建如下:?public?function?__construct(MyRepository?$repository,?MyValidator?$validator)????{? ????????$this->repository?=?$repository;? ???????????????$this->validator??=?$validator; ????}我可以在這個(gè)控制器中獲得MyRepository實(shí)例。$this->repository但是我需要在這個(gè)控制器中使用另一個(gè)存儲(chǔ)庫。我試圖像這樣但失敗了。$anotherRepo?=?new?AnotherRepo();?//?I?think?AnotherRepo`?is?interface.我打算獲取$anotherRepo->all()數(shù)據(jù)但無法獲取$anotherRepo實(shí)例。請(qǐng)幫助我如何獲取存儲(chǔ)庫實(shí)例。
查看完整描述

1 回答

?
DIEA

TA貢獻(xiàn)1820條經(jīng)驗(yàn) 獲得超2個(gè)贊

您只需將它傳遞給構(gòu)造函數(shù),然后像其他人一樣訪問它。

public function __construct(AnotherRepo $another, MyRepository $repository, MyValidator $validator){
    $this->another = $another;
        $this->repository = $repository;
            $this->validator  = $validator;
}

然后得到它$this->another。


查看完整回答
反對(duì) 回復(fù) 2023-05-26
  • 1 回答
  • 0 關(guān)注
  • 168 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)