Я получил ошибку при сохранении данных.
Illuminate\Database\QueryException
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'cne' cannot be null (SQL: insert into `students` (`cne`, `firstName`, `secondName`, `age`, `speciality`, `updated_at`, `created_at`) values (?, ?, ?, ?, ?, 2020-04-03 20:47:34, 2020-04-03 20:47:34))
Интересно, что я мог бы сделать, чтобы это исправить.
Маршрут
Route::get('/',"StudentController@index") ;
Route::get('/edit/{id}',"StudentController@edit") ;
Route::get('/show/{id}',"StudentController@show") ;
Route::get('/create',"StudentController@create") ;
Route::get('/store',"StudentController@store") ;
Route::get('/update/{id}',"StudentController@update") ;
Контроллер
public function store(Request $request )
{
$student = new Student() ;
$student->cne = $request->input('cne') ;
$student->firstName = $request->input('firstName') ;
$student->secondName = $request->input('secondName') ;
$student->age = $request->input('age') ;
$student->speciality = $request->input('speciality') ;
$student->save() ;
return redirect('/') ;
//
}
HTML
@if($layout == 'index')
<div class="container-fluid">
<div class="row">
<selctio class="col">
@include("studentslist")
</selction>
<selction class="col"></selction>
</div>
</div>
@elseif($layout == 'create')
<div class="container-fluid" id="create-form">
<div class="row">
<selctio class="col">
@include("studentslist")
</selction>
<selction class="col">
<form action="{{ url('/store') }}" method="POST" >
@csrf
<div class="form-group">
<label>CNE</label>
<input name="cne" id="cne" type="text" class="form-control" placeholder="Enter cne">
</div>
<div class="form-group">
<label>First Name</label>
<input name="firstName" id="firstName" type="text" class="form-control" placeholder="Enter the first name">
</div>
<div class="form-group">
<label>second Name</label>
<input name="secondName" type="text" class="form-control" placeholder="Enter second name">
</div>
<div class="form-group">
<label>Age</label>
<input name="age" type="text" class="form-control" placeholder="Enter the Age">
</div>
<div class="form-group">
<label>Speciality</label>
<input name="speciality" type="text" class="form-control" placeholder="Enter Sepeciality">
</div>
<input type="submit" class="btn btn-info" value="Save">
<input type="reset" class="btn btn-warning" value="Reset">
</form>
</selction>
</div>
</div>
@elseif($layout == 'show')
<div class="container-fluid">
<div class="row">
<selctio class="col">
@include("studentslist")
</selction>
<selction class="col"></selction>
</div>
</div>
@elseif($layout == 'edit')
<div class="container-fluid">
<div class="row">
<section class="col-md-7">
@include("studentslist")
</section>
<section class="col-md-5">
</section>
</div>
</div>
@endif