SubscriptionController

SubscriptionController

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

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

但不幸的是,我得到:
Call to undefined method App\Http\Controllers\SubscriptionController::getMiddleware()
这是我的SubscriptionController代码的草稿:
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');
    }
}

对这个有什么想法吗?请记住,我是Laravel的新手。

最佳答案

您忘了扩展抽象 Controller :

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

关于php - 调用未定义的方法App\Http\Controllers\SubscriptionController::getMiddleware(),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36310004/

10-09 09:28