Integrity constraint violation - PHP Laravel MVC 5.0

Tyrx

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
aldrin27

In your migration file:

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(); //set this to default like $table->timestamps();
    $table->string('uploader_name');
    $table->double('file_size');
    $table->string('file_type');
 });
}

In your model:

 class Files extends Model {

  public $timestamps = false; //to disable the timestamp
  // Mass assignment
  protected $fillable = ['file_title', 'file_name', 'file_description', 'file_path', 'uploader_name', 'file_size', 'file_type'];

 }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Laravel 5: SQLSTATE[23000]: Integrity constraint violation

From Dev

Laravel : Integrity constraint violation

From Dev

Integrity constraint violation in laravel

From Dev

Integrity constraint violation in laravel

From Dev

laravel Integrity constraint violation

From Dev

Integrity constraint violation: 1452 laravel

From Dev

Laravel validator - Integrity constraint violation

From Dev

Integrity constraint violation: 1452 laravel

From Dev

Laravel validator - Integrity constraint violation

From Dev

Laravel 5: Integrity constraint violation: 1062 - Many to Many

From Dev

Laravel 5: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails

From Dev

Laravel 5: SQLSTATE[23000]: Integrity constraint violation, foreign key constraint fails

From Dev

Laravel - Integrity constraint violation: 1062 Duplicate entry

From Dev

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row (laravel5)

From Dev

Laravel integrity constraint violation when saving many to many relationship

From Dev

Laravel SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry

From Dev

Laravel SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry

From Dev

Laravel Eloquent create method causing integrity constraint violation

From Dev

Referential integrity constraint violation occurred

From Dev

Integrity Constraint Violation - Null MySQL

From Dev

Referential integrity constraint violation occurred

From Dev

Integrity Constraint Violation - Null MySQL

From Dev

Integrity constraint violation, foreign key constraint fails

From Dev

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails - Laravel

From Dev

Laravel 7, SQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed when trying to add a relationship

From Dev

Laravel - Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails

From Dev

Laravel 7 Error message: 'SQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed: profiles.url

From Dev

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails - Laravel

From Dev

Laravel: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails

Related Related

  1. 1

    Laravel 5: SQLSTATE[23000]: Integrity constraint violation

  2. 2

    Laravel : Integrity constraint violation

  3. 3

    Integrity constraint violation in laravel

  4. 4

    Integrity constraint violation in laravel

  5. 5

    laravel Integrity constraint violation

  6. 6

    Integrity constraint violation: 1452 laravel

  7. 7

    Laravel validator - Integrity constraint violation

  8. 8

    Integrity constraint violation: 1452 laravel

  9. 9

    Laravel validator - Integrity constraint violation

  10. 10

    Laravel 5: Integrity constraint violation: 1062 - Many to Many

  11. 11

    Laravel 5: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails

  12. 12

    Laravel 5: SQLSTATE[23000]: Integrity constraint violation, foreign key constraint fails

  13. 13

    Laravel - Integrity constraint violation: 1062 Duplicate entry

  14. 14

    SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row (laravel5)

  15. 15

    Laravel integrity constraint violation when saving many to many relationship

  16. 16

    Laravel SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry

  17. 17

    Laravel SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry

  18. 18

    Laravel Eloquent create method causing integrity constraint violation

  19. 19

    Referential integrity constraint violation occurred

  20. 20

    Integrity Constraint Violation - Null MySQL

  21. 21

    Referential integrity constraint violation occurred

  22. 22

    Integrity Constraint Violation - Null MySQL

  23. 23

    Integrity constraint violation, foreign key constraint fails

  24. 24

    SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails - Laravel

  25. 25

    Laravel 7, SQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed when trying to add a relationship

  26. 26

    Laravel - Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails

  27. 27

    Laravel 7 Error message: 'SQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed: profiles.url

  28. 28

    SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails - Laravel

  29. 29

    Laravel: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails

HotTag

Archive