Skip to content

attachToSelf() gives "stripos(): Argument #1 ($haystack) must be of type string, array given" #2

@mikebridge

Description

@mikebridge

I have this table:

Schema::create('test_nodes', function (Blueprint $table) {
    $table->increments('id');
    $table->string('name');
    $table->integer('organization_id')->index();
     // ...
 });

and this closure table:

Schema::create('test_nodes_closure', function (Blueprint $table) {
    $table->integer('ancestor_id')
        ->unsigned()
        ->index();
    $table->integer('descendant_id')
        ->unsigned()
        ->index();
    $table->integer('depth')->index()->default(0);
    $table->integer('root')->index()->default(0);
    $table->unique(['ancestor_id', 'descendant_id']);
    $table->index(['ancestor_id', 'descendant_id', 'depth']);
    $table->index(['descendant_id', 'depth']);
    $table->index(['depth', 'root']);
});

Schema::table('test_nodes_closure', function(Blueprint $table) {
    $table->foreign('ancestor_id')
        ->references('id')
        ->on('test_nodes')
        ->onDelete('cascade')
        ->onUpdate('cascade');
    $table->foreign('descendant_id')
        ->references('id')
        ->on('test_nodes')
        ->onDelete('cascade')
        ->onUpdate('cascade');
});

If I call save() on its own on a TestNode model it works ok, but if I call save() then attachToSelf() I get the error:

stripos(): Argument #1 ($haystack) must be of type string, array given {"exception":"[object] (TypeError(code: 0): stripos(): Argument #1 ($haystack) must be of type string, array given at /classy/apiv2/vendor/laravel/framework/src/Illuminate/Database/Grammar.php:62)"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions