[英]Laravel can't update database?
This is a weird error. 这是一个奇怪的错误。 I can add a new record to the database fine with a new UserEdit method, but if I try to update a record.
我可以使用新的UserEdit方法将新记录添加到数据库中,但是如果我尝试更新记录。 Nothing.
没有。 It doesn't even file a blank value, or issue an error.
它甚至不会提交空白值,也不会发出错误。
What am I missing? 我想念什么? To try to eliminate issues, I tried running the core update method in the documentation like so:
为了尝试消除问题,我尝试运行文档中的核心更新方法,如下所示:
protected function create()
{
$save = UserEdit::find(715);
$save->First_Name = 'Jeffrey';
$save->Last_Name = 'Way';
$save->save();
$id = UserEdit::find(715)->toArray();
return view('NewUser', compact('id'));
//return $array;
}
This problem is the same as my earlier question here , but I didn't think it appropriate to double up the questions and this is technically a different problem. 这个问题与我之前在这里提出的问题相同,但我认为不适合将问题加倍,这从技术上讲是一个不同的问题。 My blade just prints an array of the user data at the moment so I know if it's working or not:
我的刀片此时仅打印用户数据数组,因此我知道它是否有效:
@extends('layout') @extends('布局')
@section('content')
<h1> Add Your Information {{ $id['name'] }}</h1>
<div class="col-md-6">
@foreach ($id as $key=>$value)
{{ $value }}<br>
@endforeach
</div>
@stop
The Routes: 路线:
<?php
Route::get('/', function () {
return view('welcome');
});
Auth::routes();
Route::get('/home', 'HomeController@index');
Route::get('NewUser', 'UserEntryController@create');
Route::post('NewUser', 'UserEntryController@UserForm');
Route::post('NewUser', 'UserEntryController@UserForm')->name('submit');
I'm assuming I'm missing some crucial minor detail, but for the life of me, can't find what. 我以为我错过了一些关键的次要细节,但是对于我一生来说,找不到任何东西。 Anybody got an idea where to look?
有人知道去哪里看吗?
public function store(Request $request)
{
$user = new UserEdit;
//$user->name = $request->name;
$user->First_Name = "foo";
$user->Last_Name = "bar";
$user->save();
return $user;
}
Try this function, maybe you had a mistake in your code. 尝试使用此功能,可能您的代码有误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.