I've dipped my toes into Laravel PHP for the first time, but I hit an issue that I can't seem to figure out. I keep getting the following two error messages when I attempt to post information through a form (using form facade) in an attempt to create a new row in the "files" table.
QueryException in Connection.php line 624: Integrity constraint violation: 19 NOT NULL constraint failed: files.file_description (SQL: insert into "files" ("file_title", "updated_at", "created_at") values (title test, 2015-10-02 00:18:00, 2015-10-02 00:18:00))
PDOException in Connection.php line 362: SQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed: files.file_description (SQL: insert into "files" ("file_title", "updated_at", "created_at") values (tesr, 2015-10-02 00:18:00, 2015-10-02 00:18:00))
The following are my files which relate to this issue. I have populated one row using tinker, and I can edit that row just fine through a form. Creation of new rows through a form seems to be the only issue. I've looked through other threads on this matter, but I'm I haven't found any solutions in the context of my problem. Any help will be greatly appreciated!
UPDATE 1: I've managed slim down the errors to just integrity constraint violations on the file_title value by placing public $timestamps = false; into the file model as per suggested. However, I'm still struggling to fix the constraint violation on the file_title value.
Migration File
class CreateFileManagementTables extends Migration
{
public function up()
{
Schema::create('files', function (Blueprint $table) {
$table->increments('id');
$table->string('file_title');
$table->string('file_name');
$table->string('file_description');
$table->string('file_path');
$table->nullableTimestamps();
$table->string('uploader_name');
$table->double('file_size');
$table->string('file_type');
});
}
public function down()
{
Schema::drop('files');
}
}
Files Model
class File extends Model {
// Mass assignment
protected $fillable = ['file_title', 'file_name', 'file_description', 'file_path', 'uploader_name', 'file_size', 'file_type'];
}
Create Controller Function
public function create()
{
return view('files.create');
}
Create View
@extends('app')
@section('content')
<h1>Create a new file</h1>
{!! Form::open(['url'=>'files']) !!}
@include('files.form', ['submitButtonText'=>'Create file'])
{!! Form::close() !!}
@stop
$table->nullableTimestamps();
? – aldrin27$table->timestamps();
? – aldrin27$table->nullableTimestamps();
? – aldrin27