compoships icon indicating copy to clipboard operation
compoships copied to clipboard

HasOne results to an error

Open pndjike opened this issue 3 years ago • 7 comments

Error message

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

image

The code

use Awobaz\Compoships\Compoships;

public function transfer(): HasOne
    {
        return $this->hasOne(
            Transfer::class,
            ['withdraw_id', 'deposit_id'],
            ['id', 'id']
        );
    }

Version of the package : 2.1.2 Laravel Version : 8.6

pndjike avatar Nov 27 '21 08:11 pndjike

I got this error using MySql

undjike avatar Nov 30 '21 05:11 undjike

@undjike Did you import the trait in the Transfer class? Can you please show how you use the transfer relationship?

topclaudy avatar Nov 30 '21 13:11 topclaudy

Yes, I imported the trait on both classes

undjike avatar Nov 30 '21 13:11 undjike

@undjike Can you please show a usage of the transfer relationship?

topclaudy avatar Nov 30 '21 13:11 topclaudy

@undjike Did you import the trait in the Transfer class? Can you please show how you use the transfer relationship?

I just eager loaded the transfer relation

$user->transactions()->with('transfer')->latest()->get()

undjike avatar Nov 30 '21 13:11 undjike

@undjike A similar issue has been reported here https://github.com/topclaudy/compoships/issues/111. But I wasn't able to reproduce. Can you please share a simple Laravel project to reproduce the issue?

topclaudy avatar Nov 30 '21 13:11 topclaudy

OK, I'll share later this evening.

undjike avatar Nov 30 '21 13:11 undjike