topclaudy / compoships

Multi-columns relationships for Laravel's Eloquent ORM
MIT License
1.12k stars 132 forks source link

stripos() expects parameter 1 to be string, array given #111

Open LionTouch opened 3 years ago

LionTouch commented 3 years ago

Hi, when i try to execute this code i got this error stripos() expects parameter 1 to be string, array given i use laravel 5.8 and compoships ^2.0 i do not know how and why this last is showing error description

exception: "ErrorException" file: "/var/www/html/intemporel/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php" line: 1047 message: "stripos() expects parameter 1 to be string, array given"

  1. my first model

` use \Awobaz\Compoships\Compoships;

public function last_message(){
    return $this->hasMany(MessageriesModuleModel::class, ['ID_RECEIVER', 'ID_SENDER'],['ID_USER', 'ID_USER']);
}

`

  1. my second model

` use \Awobaz\Compoships\Compoships;

public function user()
{
    return $this->belongsTo(UsersModuleModel::class, ['ID_USER','ID_USER'],[ 'ID_RECEIVER','ID_SENDER']);
}

`

tspesh commented 3 years ago

Seeing this on Lumen 8.x as well

topclaudy commented 3 years ago

That's weird! Can you provide a simple Laravel project to reproduce this?

mShbieb commented 3 years ago

@topclaudy Did you solve it?

matalina commented 3 years ago

I am seeing this as well... specifically when eager loading multi level relationships .ie:

Inventory::with('models.brands')->get();

I can fetch the $inventory->models[0]->brand without the eager loading so it's working.

I am using laravel 8 on php 8. The same code is working in the latest laravel 7 on php 7.2

topclaudy commented 3 years ago

Please provide a Laravel project to reproduce your issues

matalina commented 3 years ago

Please provide a Laravel project to reproduce your issues

I'm attempting to create a simple app that reflects this issue. However its not doing it with an sqlite database.

My repo I'm seeing the error in is an MSSQL database. So that might be the underlying difference, but I cant easily test the MSSQL database as I don't have one locally installed and production is not write accessible.

I have narrowed it down to hasMany relationship. But still unable to reproduce it on an sqlite install -- still only happening on MSSQL. It happens on a single level eager loading hasMany relationship.

fabriciozeferino commented 3 years ago

Hi guys, I get the same with this relation:

public function subscription(): HasOne
    {
        return $this->hasOne(Subscription::class, 'member_id');
    }

    public function subscriptionsAdmin(): HasMany
    {
        return $this->hasMany(Subscription::class, 'admin_id');
    }

    public function subscriptions()
    {
        return $this->hasMany(Subscription::class, ['member_id', 'admin_id'], ['id', 'id']);
    }

Anyone sport what I'm missing here?

Thanks

ib-ganz commented 2 years ago

i get this error too. i'm using laravel 8.53.0

BaloccoDev commented 2 years ago

Same problem here laravel 8.83, using chunk instead of get, it happens when using multiple primary keys