0
votes

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');
    }
}
3
Welcome to Stack Overflow. What is the question you are looking for an answer for?lagbox
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.abhay gajjar

3 Answers

1
votes

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

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)

-1
votes

You forgot to use controller?

use App\Http\Controllers\Controller as Controller