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

declaration mismatch in laravel 8 #20

Open
silverax opened this issue Apr 14, 2021 · 5 comments
Open

declaration mismatch in laravel 8 #20

silverax opened this issue Apr 14, 2021 · 5 comments

Comments

@silverax
Copy link

Declaration of LaravelTreats\Model\Traits\HasCompositePrimaryKey::setKeysForSaveQuery(Illuminate\Database\Eloquent\Builder $query) should be compatible with Illuminate\Database\Eloquent\Model::setKeysForSaveQuery($query)

@silverax
Copy link
Author

As a workarround I update the declaration inside vendor to:
protected function setKeysForSaveQuery($query)

@sudofox
Copy link

sudofox commented Apr 30, 2021

Thanks for making this issue. I was looking into whether I could use this in my project.

@royvanv
Copy link

royvanv commented May 19, 2021

I ran into the same issue.

@silverax If you need to use the trait and still be able to use the trait in your code, you can use my code below. It 'inherits' the trait and overwrites the setKeysForSaveQuery() method. Make sure to put this trait in the right folder and replace any reference to the original trait with this one.

<?php

namespace App\Traits\Models;

use LaravelTreats\Model\Traits\HasCompositePrimaryKey as LaravelTreatsHasCompositePrimaryKey;

trait HasCompositePrimaryKey
{
    use LaravelTreatsHasCompositePrimaryKey
    {
        LaravelTreatsHasCompositePrimaryKey::setKeysForSaveQuery as parentSetKeysForSaveQuery;
    }

    protected function setKeysForSaveQuery($query)
    {
        return $this->parentSetKeysForSaveQuery($query);
    }
}

@silverax
Copy link
Author

I will try that in my next project!!!!!

Thanx!!

@ghost
Copy link

ghost commented Jun 10, 2021

Your decision helped me a lot.

I ran into the same issue.

@silverax If you need to use the trait and still be able to use the trait in your code, you can use my code below. It 'inherits' the trait and overwrites the setKeysForSaveQuery() method. Make sure to put this trait in the right folder and replace any reference to the original trait with this one.

<?php

namespace App\Traits\Models;

use LaravelTreats\Model\Traits\HasCompositePrimaryKey as LaravelTreatsHasCompositePrimaryKey;

trait HasCompositePrimaryKey
{
    use LaravelTreatsHasCompositePrimaryKey
    {
        LaravelTreatsHasCompositePrimaryKey::setKeysForSaveQuery as parentSetKeysForSaveQuery;
    }

    protected function setKeysForSaveQuery($query)
    {
        return $this->parentSetKeysForSaveQuery($query);
    }
}

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