简体   繁体   English

Importing Laravel Avored Package Controller in Laravel Controller

[英]Importing Laravel Avored Package Controller in Laravel Controller

I am trying to extend the package controller in my base laravel controller.我正在尝试在我的基础 laravel Z594C103F2C6E04C3DAZ8AB5E. Tried importing class using below code which shows error as class not found.尝试使用以下代码导入 class,该代码显示错误为 class 未找到。

<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Http\Controllers\ProductController as ControllersProductController;
use App\Imports\ProductsImport;
use AvoRed\Framework\AvoRedProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Validator;
use Maatwebsite\Excel\Facades\Excel;
use Avored\Framework\Catalog\Controllers\ProductController;

class ProductControllers extends Controller
{

    private $avored_product;

    public function __construct(ProductController $p) {
        $this->avored_product = $p;
    }

    public function index() {
        echo $this->avored_product;
    }

Tried multiple options by researching on it couldn't find the same.通过研究它尝试了多种选择,但找不到相同的选择。 Request all to please guide me with same.请大家以同样的方式指导我。

Could you share with us the exact error message?您能否与我们分享确切的错误信息? From your code snippet I can't see which class couldn't be found.从您的代码片段中,我看不出找不到哪个 class 。

And which Avored package are you referring to?您指的是哪个 Avored package? I guess avored-laravel-ecommerce ?我猜avored-laravel-ecommerce

If you want to extend the ProductController -from the package, you have properly extend from that controller.如果你想从 package 扩展ProductController ,你已经从 controller 正确extend

<?php

namespace App\Http\Controllers\Admin;

use Avored\Framework\Catalog\Controllers\ProductController as AvoredProductController;

class ProductControllers extends AvoredProductController
{
    public function index() {
        // Do your thing in here
    }
}

You can now override the controller methods to your liking.您现在可以根据自己的喜好覆盖 controller 方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM