我的问题是我无法搜索,也无法显示texboxes中的值。
我想要的是搜索每个用户的ID,并将其数据显示在我的文本框中
如何在Laravel的视频This Video上执行此操作?
到目前为止,我有 this
查看
exports.verifyUSN = function(req, res, next){
res.status(200)
.json({
status: 'success',
data: data,
message: 'USN Verified.'
});
}
控制器
{!! Form::open(['action' => 'Admin\EmployeeFilemController@search', 'method' => 'POST', 'enctype' => 'multipart/form-data']) !!}
<input type="text" name="id" class="form-control" placeholder="Enter ID to Search"><br>
<input type="submit" class="btn btn-primary btn-md" name="search" value="Search Data">
{!! Form::close() !!}
我的 查看输入
public function search(Request $request){
$output = "";
$employees = DB::table('employeefms')->where('id')->get();
return redirect('/admin/employeemaintenance');
}
答案 0 :(得分:1)
您似乎没有传递用户在控制器功能中输入的id
。
$employees = DB::table('employeefms')->where('id')->get();
您可能必须进行以下更改
$input = $request->all();
$id = $input['id']
// $employees = DB::table('employeefms')->where('id', $id)->get();
// actually, if 'id' is the primary key, you should be doing
$employee = DB::table('employeefms')->find($id);
// now pass the data to the view where you want to display the record
// like so
return view('name_of_view', compact('employee'));
然后,使用Laravel的Form-Model绑定
{!! Form::model($employee,
['action' => ['Admin\EmployeeFilemController@update', $employee->id],
'method' => 'patch' // or whatever method you have defined
]) !!}
// your form fields specified above will go here
{!! Form::close() !!}