Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call to undefined method App\Http\Controllers\SubscriptionController::getMiddleware()

Tags:

php

laravel-5

I am calling the \prelaunchroute in my application and this is how it is defined in my routes.php:

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

But unfortunately, I am getting:

Call to undefined method App\Http\Controllers\SubscriptionController::getMiddleware()

This is a draft of my SubscriptionController code:

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');
    }
}

Any thoughts on this one? Please bare in mind that I am fairly new to Laravel.

like image 488
thitami Avatar asked Mar 30 '16 13:03

thitami


2 Answers

You forgot to extend the abstract 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
like image 164
Mihai Matei Avatar answered Nov 14 '22 00:11

Mihai Matei


Try to extends Controller

/**
* Class SubscriptionController
* @package App\Http\Controllers
*/
class SubscriptionController extends Controller
{
like image 44
Maxime Dupaul Avatar answered Nov 14 '22 00:11

Maxime Dupaul