Incompatibility with Illuminate\Contracts\Routing\UrlRoutable::resolveRouteBinding()
Garrett-Sens opened this issue · 2 comments
I'm following your guide here:
https://github.com/CristalTeam/php-api-wrapper/blob/master/docs/work-with-laravel.md
however when I try to use my Cristal\ApiWrapper\Bridges\Laravel\Model class in AppServiceProvider::boot() like this
MyModel::setApi($this->app->make(Api::class));
I see this error:
Symfony\Component\ErrorHandler\Error\FatalError
Declaration of Cristal\ApiWrapper\Model::resolveRouteBinding($value) must be compatible with Illuminate\Contracts\Routing\UrlRoutable::resolveRouteBinding($value, $field = NULL)
Adding $field = NULL as the second parameter of Cristal\ApiWrapper\Model::resolveRouteBinding fixes that error, but then I see this error:
Class Cristal\ApiWrapper\Bridges\Laravel\Model contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Illuminate\Contracts\Routing\UrlRoutable::resolveChildRouteBinding)
I have to add this
/**
* Retrieve the child model for a bound value.
*
* @param string $childType
* @param mixed $value
* @param string|null $field
* @return \Illuminate\Database\Eloquent\Model|null
*/
public function resolveChildRouteBinding($childType, $value, $field)
{
return false;
}
to Cristal\ApiWrapper\Model to fix that error.
It looks like this project is not up to date with latest Illuminate\Contracts\Routing\UrlRoutable.
This is what I have in my composer.json
"repositories": [
{
"type": "vcs",
"url": "https://github.com/CristalTeam/php-api-wrapper"
}
],
"require": {
"php": "^7.2.5",
"barryvdh/laravel-debugbar": "^3.3",
"cristal/php-api-wrapper": "^5.1",
"fideloper/proxy": "^4.2",
"fruitcake/laravel-cors": "^1.0",
"guzzlehttp/guzzle": "^6.3",
"laravel/framework": "^7.0",
"laravel/tinker": "^2.0",
"laravelcollective/html": "^6.1",
"symfony/symfony": "^5.0"
},
Thank you for the feedback, indeed there was an incompatibility with Laravel 7.x
We've pushed a new release (v5.1.3) which must fix the issue.
Wonderful, thank you!