LaravelTreats
LaravelTreats copied to clipboard
declaration mismatch in laravel 8
Declaration of LaravelTreats\Model\Traits\HasCompositePrimaryKey::setKeysForSaveQuery(Illuminate\Database\Eloquent\Builder $query) should be compatible with Illuminate\Database\Eloquent\Model::setKeysForSaveQuery($query)
As a workarround I update the declaration inside vendor to: protected function setKeysForSaveQuery($query)
Thanks for making this issue. I was looking into whether I could use this in my project.
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);
}
}
I will try that in my next project!!!!!
Thanx!!
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); } }