1
votes

I am getting the error SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'times' cannot be null (SQL: insert into sa_schedule (cinema_id, movie_id, times) values (-, [], ))

this is my form

<div class="form-group">
  <label>Cinema Name</label>
  <div>
    <input type="text" id="cinemaname">
  </div>
</div>
<div>
  <label>Movie Title</label>
  <div>
    <input type="text" id="movietitle">
  </div>
</div>
<div>
  <label>Time Schedule</label>
  <div>
    <input type="text" id="timesched">
  </div>
</div>

and this is my controller

public function addcinema(Request $request)
{  //some codes here

    $addcine = new Schedule();
    $addcine->times = $request->timesched;
   //some codes here
    $addcine->save();

    return view ('dashboard');
}
2

2 Answers

2
votes

Just make times column nullable. Additionally you may define default value for it. Using migrations, direct db modification or phpmyadmin.

2
votes

The times column has to have a value unless you update the column to allow null.