Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HasOne results to an error #130

Open
pndjike opened this issue Nov 27, 2021 · 7 comments
Open

HasOne results to an error #130

pndjike opened this issue Nov 27, 2021 · 7 comments

Comments

@pndjike
Copy link

pndjike commented Nov 27, 2021

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

@undjike
Copy link

undjike commented Nov 30, 2021

I got this error using MySql

@topclaudy
Copy link
Owner

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

@undjike
Copy link

undjike commented Nov 30, 2021

Yes, I imported the trait on both classes

@topclaudy
Copy link
Owner

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

@undjike
Copy link

undjike commented Nov 30, 2021

@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()

@topclaudy
Copy link
Owner

@undjike A similar issue has been reported here #111. But I wasn't able to reproduce. Can you please share a simple Laravel project to reproduce the issue?

@undjike
Copy link

undjike commented Nov 30, 2021

OK, I'll share later this evening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants