NewsController.php
This is the contoller and i use the create function to add record to the database but when i add all records will be empty
public function insertNews() {
$attribute = [
'Ntitle' => 'News Title',
'Ndesc' => 'News Description',
'Naddedby' => 'News Added By',
'Ncontent' => 'News Content',
'Nstatus' => 'News Status'
];
$data = $this->validate(request(), [
'Ntitle' => 'required',
'Ndesc' => 'required',
'Naddedby' => 'required',
'Ncontent' => 'required',
'Nstatus' => 'required'
], [], $attribute);
News::create($data);
return redirect('all/news');
}
and i use dd() to show the record and it will show with the token and all other values
dd(request()->all())
news.blade.php
and this is the blade file that contain the form that i sent to the controller
<form action="" method="POST">
<input type="text" name="Ntitle" value="" placeholder="News Title"><br />
<input type="text" name="Ndesc" value="" placeholder="News Descrption"><br />
<input type="number" name="Naddedby" value="" placeholder="News Added By"><br />
<textarea name="Ncontent" value="" placeholder="News Content"></textarea><br />
<select name="Nstatus">
<option value="Active" >Active</option>
<option value="Pending" >Pending</option>
<option value="Disabled" >Disabled</option>
</select><br />
<input type="submit" value="Add News">
</form>
Aucun commentaire:
Enregistrer un commentaire