Search code examples
laravelphpstorm

Update the plugin will be something wrong


When I update the Laravel plugin, if I use some static method e.g. User::find($id) it will show a warning: "Non-static method User::find() should not be called statically", this very bad!

Example:

namespace App\Http\Controllers\Web;

use App\Model\User;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use EasyWeChat\Foundation\Application;

class TestController extends Controller
{
    public function __construct(Application $wechat)
    {
        parent::__construct($wechat);
    }

    public function index(Request $request)
    {
        $user = User::find(12);
        dd($user);
    }
}

Solution

  • public function index(Request $request)
    {
        $user = User::all()->find(12);
        dd($user);
    }