我有一个单独的文件用于添加数据,它可以正常使用以下内容。但是当我在桌子上使用它并且它不起作用时。任何人都可以请帮助这些。如何将数据添加到它,并帮助我提供datepicker和复选框帖子,我已请求帮助。提前谢谢
代码
<tr>
<form action="storeself" method="post">
<td><input type="date" name="assigndate"></td>
<td><input type="text" name="topic"></td>
<td><input type="text" name="activity"></td>
<td><select class="form-control" name="respon">
<option>--SELECT--</option>
<option >Hementh</option>
<option >Vijay</option>
<option >Usha</option>
<option >Arun </option>
<option >Yohith </option>
</select></td>
<td><select class="form-control" name="support">
<option>--SELECT--</option>
<option >Hementh</option>
<option >Vijay</option>
<option >Usha</option>
<option >Arun </option>
<option >Yohith </option>
</select></td>
<td><select class="form-control" name="priority">
<option>--SELECT--</option>
<option >High</option>
<option >Medium</option>
<option >Low</option>
</select></td>
<td><input type="date" name="targetdate"></td>
<td><select class="form-control" name="status">
<option>--SELECT--</option>
<option >To be Started</option>
<option >In Progress</option>
<option >Completed</option>
</select></td>
<td><input type="date" name="compledate" ></td>
<td><input type="text" name="remarks"></td>
<td><input type="int" name="targerweek"></td>
<input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
<td><button input type="submit" name="submit"value="submit">ADD</button>
</form>
</tr>
路由
Route::get('selfadd','selfctrl@addself');
Route::get('selftask', 'selfctrl@selflist');
Route::post('storeself','selfctrl@insert');
Route::any('selfdele/{id}', 'selfctrl@destroy');
控制器
class selfctrl extends Controller
{
public function addself(){
return view('forms.selftask.list');
}
public function insert(Request $request){
DB::table("selflist")->insert([
"assigndate"=>$_POST["assigndate"],
"topic"=>$_POST["topic"],
"activity"=>$_POST["activity"],
"respon"=>$_POST["respon"],
"support"=>$_POST["support"],
"priority"=>$_POST["priority"],
"targetdate"=>$_POST["targetdate"],
"status"=>$_POST["status"],
"compledate"=>$_POST["compledate"],
"remarks"=>$_POST["remarks"],
"targerweek"=>$_POST["targerweek"]
]);
return "Hello";
}
public function selflist(){
$users = DB::table('selflist')->get();
return view('forms.selftask.list')->with('users',$users);
}
public function destroy($id)
{
DB::table('selflist')->Where('id',$id)->delete();
return redirect('selftask')->with('success','deleted successfully');
}
}
答案 0 :(得分:0)
你做错了。 首先,您需要通过
调用post参数$request->input('name');
另一件事是,你应该从不在控制器中使用表名,你应该使用模型进行查询。