0
며칠 전 Laravel 5.2를 사용하며 문제가 있습니다! 누군가가 나를 도울 수 있기를 바랍니다.Laravel 5.2 업데이트 데이터
특별한 절차가 필요하므로 리소스를 사용하지 않습니다. 내 문제는 사용자의 데이터가 데이터베이스에서 업데이트되지 않는다는 것입니다.
protected function edit($name)
{
return view('user.edit', array('user' => User::findByUsernameOrFail($name)));
}
protected function update($name, ProfileDataRequest $request)
{
$profile = User::findorfail($name);
$input = $request -> all();
$profile->update($input);
return redirect()->action('[email protected]');
}
내 양식 :
{!! Form::model($user, ['method' => 'PATCH', 'action' => ['[email protected]', $user -> name ]]) !!}
{{ csrf_field() }}
{!! Form::label('sms', 'SMS: ') !!}
{!! Form::checkbox('sms', 1, false) !!}
{!! Form::label('name', 'Name: ') !!}
{!! Form::text('name') !!}
{!! Form::submit('Submit') !!}
{!! Form::close() !!}
내 경로 :
Route::get('/user', '[email protected]');
Route::get('/user/{name}', '[email protected]');
Route::get('/user/{name}/edit', '[email protected]');
Route::patch('/user/{name}', '[email protected]');
내 요청 파일 :
class ProfileDataRequest extends Request
{
/**
* 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 [
'name' => 'required',
'sms' => 'required',
];
}
}
,691 여기
내 컨트롤러
더 간단한 방법이 있으면 저에게 편지를 보내십시오!
public
에 교체? 응용 프로그램이 업데이트 기능을 입력합니까? – Laerte제출 버튼을 클릭하면 페이지를 새로 고치기 만하면됩니다. – Brhama