1
私はデータを追加するために別のファイルを持っていました。しかし、私はテーブルでそれを使用していて、動作していません。誰も助けてもらえますか?データをどのように追加するのか、そしてdatepickerとcheckboxの投稿に私が助けを要求したのを助けてくれます。事前にありがとう私はlaravelのデータベースにデータを追加するにはどうすればいいですか
コード
<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','[email protected]');
Route::get('selftask', '[email protected]');
Route::post('storeself','[email protected]');
Route::any('selfdele/{id}', '[email protected]');
コントローラ
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');
}
}
しかし、そのコンテンツを別のファイルに追加すると、要求を呼び出さずに動作しますが、問題は、テーブルにアクセスしてその下に追加するときです – Hemanth