0

I am using laravel 5.6, when create controller and when run controller through route, I am facing error like

Declaration of App\Http\Controllers\XyzController::xyz(Illuminate\Http\Request $request) should be compatible with App\Http\Controllers\Controller::xyz($job)

My Code is

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class XyzController extends Controller
{

    public function xyz(Request $request)
    {
        return view('xyz.xyz');
    }
}
2
  • Welcome to Stack Overflow. What is the question you are looking for an answer for? Commented Aug 8, 2018 at 4:53
  • when i had create controller file through command and then create route and blade file and in controller create function as above shown but now its not working proper. Commented Aug 8, 2018 at 5:06

3 Answers 3

1

Missing route parameter: $job

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class XyzController extends Controller
{

    public function xyz(Request $request, $job)
    {
        return view('xyz.xyz');
    }
}
Sign up to request clarification or add additional context in comments.

Comments

0

The base Controller that XyzController extends from defines a method named xyz with a different signature than the one you are defining.

You will need to adjust the method in XyzController to match the signature of xyz in the base Controller or adjust the base Controller to have a different signature.

Example of the problem:

class A
{
    public function xyz($obj) {}
}

class B extends A
{
    public function xyz(Illuminate\Http\Request $request) {}
}

Declaration of B::xyz(Illuminate/Http/Request $request) should be compatible with A::xyz($obj)

Comments

-2

You forgot to use controller?

use App\Http\Controllers\Controller as Controller

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.