我刚接触laravel 5.4并且我正在尝试创建一个寄存器表单,它将验证并将其存储在申请人表中,并且它表示在null上调用成员函数create()。 继承我的代码:
private $applicantRepository;
public function repo(ApplicantRepository $applicantRepo)
{
$this->middleware('auth');
$this->applicantRepository = $applicantRepo;
}
public function store(CreateApplicantRequest $request)
{
$input = $request->all();
$applicants = $this->applicantRepository->create([
'name' => $input['name'],
'email' => $input['email'],
'password' => bcrypt($input['password']),
'address' => $input['address'],
'cellphone_no' => $input['cellphone_no']
]);
Flash::success('Cashier saved successfully.');
return redirect(route('applicants/home'));
}
答案 0 :(得分:1)
我认为如果你想要make构造函数,你应该声明__construct
,这样你的repo
函数就会变成:
public function __construct(ApplicantRepository $applicantRepo)
{
$this->middleware('auth');
$this->applicantRepository = $applicantRepo;
}