我在我的应用程序中调用\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的新手。
答案 0 :(得分:11)
你忘了扩展抽象控制器:
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
答案 1 :(得分:1)
尝试扩展Controller
/**
* Class SubscriptionController
* @package App\Http\Controllers
*/
class SubscriptionController extends Controller
{