I'm working with Laravel 8 and when I write the route to the __invoke controller like this:
use App\Http\Controllers\PortfolioController;
Route::get('/portfolio', 'PortfolioController')->name('portfolio');
It shows this error:
Invalid route action: [PortfolioController].
PortfolioControlleris not invokable
So it only works like this:
Route::get('/portfolio', [PortfolioController::class, '__invoke'])->name('portfolio');;
Which doesn't make sense to me because it should find the __invoke which is the only one in PortfolioController.php:
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class PortfolioController extends Controller
{
    /**
     * Handle the incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function __invoke(Request $request)
    {
      $portfolio = [
      ['title' => 'Project #1'],
      ['title' => 'Project #2'],
      ['title' => 'Project #3'],
      ['title' => 'Project #4'],
      ];
      return view('portfolio',compact('portfolio'));
    }
}
Is Laravel 8 ignoring the __invoke attribute???
 
     
    