Skip to content

Dependency injection on nested resources #806

Answered by loureirorg
loureirorg asked this question in Ideas
Discussion options

You must be logged in to vote

Here's my solution in case anyone is interested:

<?php
// app/Providers/QueryBuilderRouteBindingServiceProvider.php

namespace App\Providers;

use Illuminate\Container\Container;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Http\Request;
use Illuminate\Routing\ImplicitRouteBinding;
use Illuminate\Routing\Route;
use Illuminate\Support\ServiceProvider;
use ReflectionClass;
use ReflectionMethod;
use Spatie\QueryBuilder\QueryBuilder;

class QueryBuilderRouteBindingServiceProvider extends ServiceProvider
{
    public function boot() : void
    {
        $this->registerRouteBindingResolver();
    }

    public function registerRouteBindingResolver() : void
    {
        $this->

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by loureirorg
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
1 participant