Laravel 5 当我尝试调用编辑函数时出现 QueryException
Laravel 5 QueryException When I try to call Edit Function
我正在了解 Laravel 5 并从此来源学习
https://laracasts.com/series/laravel-5-fundamentals/episodes/13
但是当我尝试制作我自己的项目时,我得到了 "QueryException in Connection.php line 620:SQLSTATE[42S22]: Column not found: 1054 Unknown column 'mscustomer.id' in 'where clause' (SQL: select * from mscustomer
where mscustomer
.id
= 1 limit 1)"
这里是代码片段
Routes.php
Route::get('edit/{member}', 'MemberController@edit');
MemberController.php
public function edit($custid)
{$member=mscustomer::findOrFail($custid);return view('member.edit' ,compact('member'));}
这里是 edit.blade.php
<h1>Edit</h1>
<hr/>
{!!Form::open(['url'=>'member'])!!}
<div class="form-group">
{!!Form::label('custname','Name :')!!}
{!!Form::text('custname',null,['class' => 'form-control'])!!}
<br>
{!!Form::label('password','Password :')!!}
{!!Form::password('password',null,['class' => 'form-control'])!!}
<br>
{!!Form::label('email','E-mail :')!!}
{!!Form::text('email',null,['class' => 'form-control'])!!}
{!!Form::submit('Register')!!}
{!!Form::close()!!}
@if ($errors->any())
@foreach ($errors->all() as $error)
<br>{{ $error }}</br>
@endforeach
@endif
如错误所述,数据库中不存在 id 列。
如果您确实正确设置了数据库迁移,您想要 运行 "php artisan migrate"。如果你没有。您需要先设置它们,然后才能开始使用您的 Eloquent 模型。
我正在了解 Laravel 5 并从此来源学习 https://laracasts.com/series/laravel-5-fundamentals/episodes/13
但是当我尝试制作我自己的项目时,我得到了 "QueryException in Connection.php line 620:SQLSTATE[42S22]: Column not found: 1054 Unknown column 'mscustomer.id' in 'where clause' (SQL: select * from mscustomer
where mscustomer
.id
= 1 limit 1)"
这里是代码片段
Routes.php
Route::get('edit/{member}', 'MemberController@edit');
MemberController.php
public function edit($custid)
{$member=mscustomer::findOrFail($custid);return view('member.edit' ,compact('member'));}
这里是 edit.blade.php
<h1>Edit</h1>
<hr/>
{!!Form::open(['url'=>'member'])!!}
<div class="form-group">
{!!Form::label('custname','Name :')!!}
{!!Form::text('custname',null,['class' => 'form-control'])!!}
<br>
{!!Form::label('password','Password :')!!}
{!!Form::password('password',null,['class' => 'form-control'])!!}
<br>
{!!Form::label('email','E-mail :')!!}
{!!Form::text('email',null,['class' => 'form-control'])!!}
{!!Form::submit('Register')!!}
{!!Form::close()!!}
@if ($errors->any())
@foreach ($errors->all() as $error)
<br>{{ $error }}</br>
@endforeach
@endif
如错误所述,数据库中不存在 id 列。
如果您确实正确设置了数据库迁移,您想要 运行 "php artisan migrate"。如果你没有。您需要先设置它们,然后才能开始使用您的 Eloquent 模型。