ログインしているユーザーのプロファイルを更新しようとしています。ユーザーが更新または編集したいときにログインしたユーザーの機能を作成したいのですが自分のプロフィール。だから私はエラーがない。しかし、問題はそれが更新されず、ちょうど私のブラウザをリフレッシュすることですが、何も起こりません。ここでLaravel 5.4ユーザープロファイルが更新されない
は私のコントローラここ
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'],
'address' => $input['address'],
'cellphone_no' => $input['cellphone_no']], $id);
Flash::success('Profile updated successfully.');
return redirect(route('applicant.edit'));
}
上のコードである私の路線でコードです:
edit.blade:
Route::get('/edit/{id}', '[email protected]')->name('applicant.edit');
Route::post('/update', '[email protected]')->name('applicant.update');
ここに私の見解でコードがあります。 PHP
@extends('applicant-dashboard.layouts.app')
@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' => 'post']) !!}
@include('applicant-dashboard.fields')
{!! Form::close() !!}
</div>
</div>
</div>
</div>
@endsection
と検証のための私のモデルでfields.blade.php
{!! Form::hidden('id', null, ['class' => 'form-control input-sm','required']) !!}
<!-- Name Field -->
<div class="row" style="padding-right: 15px">
<div class="form-group col-sm-4">
{!! Form::label('name', 'Name:') !!}
{!! Form::text('name', null, ['class' => 'form-control input-sm','required']) !!}
</div>
</div>
<div class="row" style="padding-right: 15px">
<!-- Address Field -->
<div class="form-group col-sm-4">
{!! Form::label('address', 'Address:') !!}
{!! Form::text('address', null, ['class' => 'form-control input-sm','required']) !!}
</div>
</div>
<!-- Cellphone Field -->
<div class="row" style="padding-right: 15px">
<div class="form-group col-sm-4">
{!! Form::label('cellphone_no', 'Cellphone:') !!}
{!! Form::text('cellphone_no', null, ['class' => 'form-control input-sm','required']) !!}
</div>
</div>
<div class="row" style="padding-right: 15px">
<!-- Submit Field -->
<div class="form-group col-sm-12">
{!! Form::submit('Save', ['class' => 'btn btn-primary']) !!}
<a href="{!! route('applicant.home') !!}" class="btn btn-default">Cancel</a>
</div>
</div>
コードで:
public static $rules = [
'name' => 'required',
'email' => 'required|unique:applicants',
'password' => 'required',
'password_confirmation' => 'required|same:password'
];
とUpdateApplicantRequest.php
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use App\Models\Applicant;
class UpdateApplicantRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return Applicant::$rules;
}
}
私が探しています助けを求めて ありがとうございます。
検証確認リクエスト、つまりUpdateApplicantRequestをクロスチェックする必要があります。必要なパラメータをすべて送信しているかどうかを確認してください。 –
はい私はUpdateApplicantRequestのモデルでルールを返しましたが、まだ動作していません –
そのファイルからコードを表示できますか? –