Salem
Salem

Reputation: 87

Undefined type 'Request'.intelephense(1009)

Iam getting this error in Laravel 8 and Name: PHP Intelephense 1.7.1 installed.

<?php

namespace App\Http\Middleware;

use Illuminate\Auth\Middleware\Authenticate as Middleware;
use Request;


class Authenticate extends Middleware
{
    /**
     * Get the path the user should be redirected to when they are not authenticated.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return string|null
     */
    protected function redirectTo($request)
    {
        if (!$request->expectsJson()) {
            if (Request::is('admin/*'))
                return route('admin.login');
            else
                return route('login');
        }
    }
}

and i have tried to add

use Illuminate\Support\Facades\Route;

but still the same any ideas?

Thanks for help ...

Upvotes: 7

Views: 22368

Answers (3)

PHANTOM-X
PHANTOM-X

Reputation: 586

F1 -> Reload Window -> Enter

Upvotes: 0

Mitivil
Mitivil

Reputation: 19

"Laravel Snippets" - VScode install the plugin.

Maybe it will be useful to someone.

Upvotes: 1

Biswajit Biswas
Biswajit Biswas

Reputation: 1045

Solution 1: You can solve this problem by installing laravel-ide-helper package. Link is here

Solution 2: Put below code to your settings.json

  "intelephense.telemetry.enabled": false,
  "intelephense.completion.triggerParameterHints": true,
  "intelephense.completion.insertUseDeclaration": true,
  "intelephense.trace.server": "messages",
  "intelephense.diagnostics.undefinedClassConstants": false,
  "intelephense.diagnostics.undefinedFunctions": false,
  "intelephense.diagnostics.undefinedConstants": false,
  "intelephense.diagnostics.undefinedProperties": false,
  "intelephense.diagnostics.undefinedTypes": false,
  "intelephense.diagnostics.undefinedMethods": false,

And finally don't forget to restart vscode.

Upvotes: 18

Related Questions