class AAController extends BaseController
{
protected $externalImageRepository;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct(
Request $request,
ComicTrialRepositoryInterface $comicTrialRepository,
ExternalImageRepositoryInterface $externalImageRepository,
ここ-> StaffRepositoryInterface $staffRepositoryInterface
) {
parent::__construct($request);
$this->repository = $comicTrialRepository;
$this->externalImageRepository = $externalImageRepository;
ここ-> $this->staffRepository = $staffRepositoryInterface;
}
.
.
.
.
.
public function index(Request $request <--いらない)
{
// $requestParams = $request->all(); //取得データ用のパラメータ
ここ-> $requestParams = $this->request->all(); //取得データ用のパラメータ
unset($requestParams['page']);
$params = $requestParams; // viewに受け渡す用のパラメータ
if (isset($requestParams['assigned_user_id']) && $requestParams['assigned_user_id'] == 'all') {
unset($requestParams['assigned_user_id']);
}
if (isset($requestParams['q']) && $requestParams['q'] == null) {
unset($requestParams['q']);
}
// $staffList = $this->repository->staffList()->pluck('name', 'id')->toArray();
ここ-> $staffList = $this->staffRepository->getStaffList()->where('group', 'comic')->pluck('name', 'id')->toArray();
// dd($staffList);
$comicTrialPager = $this->repository->getPager($requestParams);
return view('comic_trial.index', compact('comicTrialPager', 'params', 'staffList'));
}
・__construct() で Requestのセットしているので、ここで引数にしなくていい
・$this->repository->staffList()
comic_trial の関連テーブル以外の取得をComicTrialRepositoryを使わない。
StaffRepositoryを使う。