How to inject a Class with constructor into Resource Class Laravel

Viewed 423

Getting error in Resource Laravel "App\Http\Resources\OrderResource::__construct(): Argument #2 ($orderLogRepository) must be of type App\Interfaces\OrderLogRepositoryInterface, int given, called in /var/www/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php on line 355"

I am injecting a class with constructor into OrderResource.php file. But it's giving the previous error! I didn't find any clue of this.

class OrderResource extends JsonResource
{
    public $orderLogRepository;

    public function __construct($resource, OrderLogRepositoryInterface $orderLogRepository)
    {
        $this->orderLogRepository = $orderLogRepository;
        parent::__construct($resource);
    }
}

Calling that resource with collection. OrderResource::collection($orders);

0 Answers
Related