I'm having problems with and invoke type controller. After I create the controller with php artisan make:controller -i and add the route, when go to the route it tells me that the Invoke function doesn't exist.
Here is the route I'm using:
Route::get('/portfolio','PortfolioController');
And here is the code of the controller:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class PortfolioController extends Controller
{
public function __invoke(Request $request)
{
/** @var array $portafolio */
$portafolio = [
["title" => "Proyecto #1"],
["title" => "Proyecto #2"],
["title" => "Proyecto #3"],
["title" => "Proyecto #4"],
];
return view("portfolio", compact("portafolio"));
}
}
I don't really get why this error occurs, because the invoke function is clearly there, so if anyone knows what could be the problem I will be really grateful. I'm using the last version of Laravel.
Route::get('/portfolio',PortfolioController::class);
(might need ause
somewhere in there too) – apokryfos