当前位置: 首页 > 知识库问答 >
问题:

对未定义方法app\http\controllers\subscriptioncontroller::GetMiddleware()的调用

壤驷麒
2023-03-14

我在应用程序中调用\prelaunch路由,这是在我的routes.php中定义它的方式:

`Route::get('/prelaunch', [ 'uses' => 'SubscriptionController@getReferrer', 'as' => 'subscriber.referral'], function () {
    return view('prelaunch');
});`

但不幸的是,我得到了:

namespace App\Http\Controllers;

use App\Http\Manager\SubscriptionManager;
use Illuminate\Support\Facades\Request;


/**
 * Class SubscriptionController
 * @package App\Http\Controllers
 */
class SubscriptionController
{
    /**
     * @var \SubscriptionManager $subscriptionManager
     */
    protected $subscriptionManager;

    /**
     * SubscriptionController constructor.
     */
    //public function __construct(SubscriptionManager $subscriptionManager)
    public function __construct(SubscriptionManager $subscriptionManager)
    {
        $this->subscriptionManager = $subscriptionManager;
    }

    /**
     * @param Request $request
     * @return void
     */
    public function subscribe(Request $request)
    {
        $this->subscriptionManager->subscribeToList($request);
    }

    /**
     * @param Request $request
     * @return void
     */
    public function unsubscribe(Request $request)
    {
        $this->subscriptionManager->unsubscribeFromList($request);
    }

    /**
     * @return void
     */
    public function getReferrer()
    {
        print_r(Input::all());
        die;
        $utm_source = \Input::get('utm_source');


        return view('prelaunch');
    }
}

共有1个答案

督建柏
2023-03-14

您忘记扩展抽象控制器:

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use App\Http\Manager\SubscriptionManager;
use Illuminate\Support\Facades\Request;

/**
 * Class SubscriptionController
 * @package App\Http\Controllers
 */

class SubscriptionController extends Controller
 类似资料: