存在しないエラーは言う:。(1/1)ReflectionExceptionエラークラスのApp のHttp リクエストは、私がlaravelに新しいですし、私がログインしているユーザーのプロファイルにアップデートしようとしている
クラスApp \ Http \ Request \ UpdateApplicantRequestは存在しません
しかし、私はそれをコントローラの上部にインポートしました。ここで
HomeController.php
<?php
namespace App\Http\Controllers\Applicant;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Repositories\ApplicantsRepository;
use Flash;
use Response;
use App\Models\Applicant;
use App\Http\Request\UpdateApplicantRequest;
class HomeController extends Controller
{
private $applicantRepository;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct(ApplicantsRepository $applicantRepo)
{
$this->middleware('applicant');
$this->applicantsRepository = $applicantRepo;
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return view('applicant-dashboard.home');
}
public function edit($id)
{
//$applicant = $this->applicantRepository->findWithoutFail($id);
$applicant = Applicant::where('id',$id)->get()->last();
if (empty($applicant)) {
Flash::error('Applicant');
return redirect(route('applicant.home'));
}
return view('applicant-dashboard.edit')->with('applicant', $applicant);
}
public function update($id, UpdateApplicantRequest $request)
{
$applicant = $this->applicantRepository->findWithoutFail($id);
if (empty($applicant)) {
Flash::error('Applicant not found');
return redirect(route('applicant.home'));
}
$input = $request->all();
$applicant = $this->applicantRepository->update([
'name' => $input['name'],
'email' => $input['email'],
'password' => bcrypt($input['password']),
'address' => $input['address'],
'cellphone_no' => $input['cellphone_no']], $id);
Flash::success('Profile updated successfully.');
return redirect(route('applicant.home'));
}
}
は私のルートのコードです:
Route::get('/edit/{id}', '[email protected]')->name('applicant.edit');
Route::patch('/put', '[email protected]')->name('applicant.update');
と私のブレード・ファイル内のコード:
@section('content')
<section class="content-header">
<h1>
Applicant Profile
</h1>
</section>
<div class="content">
{{-- @include('adminlte-templates::common.errors') --}}
<div class="box box-primary">
<div class="box-body">
<div class="row" style="padding-left: 20px">
{!! Form::model($applicant, ['route' => ['applicant.update', $applicant->id], 'method' => 'patch']) !!}
@include('applicant-dashboard.fields')
{!! Form::close() !!}
</div>
</div>
</div>
</div>
@endsection
私が探しています助けて。 ありがとうございました。
その後、からフォームを変更'UpdateApplicantRequest.php'ファイルに名前空間を定義しますか?そしてそれはどこに置かれますか? –
App \ Http \ Requestsのような名前空間。 –
私はすでにそれを解決しました。しかし問題は、私が提出するか、更新ボタンを保存するボタンを押すときです。ブラウザをリフレッシュするだけです。 –