Метод создания не работает должным образом. Всегда возвращать статус ОК, с нулевыми данными и без вставки в БД. К сожалению, ошибки не отображаются, поэтому я не знаю, что делать.
protected function addBooking(Request $request)
{
$data = $request->all();
if ($this->validator($data)->fails()) {
return $this->sendError('Validation Error.', $this->validator($data)->errors());
}
Booking::create($data);
return $data;
}
Это миграция
public function up()
{
Schema::create('bookings', function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('booker_id')->nullable(false)->unsigned();
$table->bigInteger('classroom_id')->nullable(false)->unsigned();
$table->string('name');
$table->string('color')->default("#ff0000");
$table->string('file')->default(NULL);
$table->string('start')->nullable(false);
$table->string('end')->nullable(false);
$table->timestamps();
$table->foreign('booker_id')->references('id')->on('users');
$table->foreign('classroom_id')->references('id')->on('classrooms');
});
}
Модель
class Booking extends Model
{
protected $fillable = [
'booker_id', 'classroom_id', 'name', 'color', 'file', 'start', 'end'
];
protected $hidden = [
];
protected $casts = [
];
}
Как мне отправить запрос
{
"booker_id": 10,
"classroom_id": 4,
"name": "Microsoft",
"start": "2019-04-25 14:45",
"end": "2019-04-25 16:45",
"color": "#ff0000",
"file": "test"
}