PhpStorm laravel 5 方法未找到

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34072929/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 12:46:19  来源:igfitidea点击:

PhpStorm laravel 5 method not found

phplaravelphpstorm

提问by vietnguyen09

Im f*cking crazy whith PhpStorm when tried to fix a popular error Method 'Bla bla' not found in class.

当我试图修复一个流行的错误时,我他妈的用 PhpStorm 发疯了 Method 'Bla bla' not found in class.

I have been searching for days in google whith hope to find out the way for this problem but no luck.

我已经在谷歌搜索了几天,希望能找到解决这个问题的方法,但没有运气。

Almost every singel topic I have read are pointing me to this laravel-ide-helper but after Install thousand times (with fresh laravel project), PhpStorm still not recognize those damn method.

几乎我读过的每个单一主题都指向这个 laravel-ide-helper,但是在安装一千次之后(使用新的 laravel 项目),PhpStorm 仍然无法识别那些该死的方法。

I also install laravel plugin in PhpStorm but still not work too, what can I do now?

我也在 PhpStorm 中安装了 laravel 插件,但仍然无法正常工作,我现在该怎么办?

Here is my code.

这是我的代码。

<?php

namespace App\Http\Controllers;

use App\Article;
use App\Menu;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Http\Requestst;
use Illuminate\Support\Facades\Input;

class PagesController extends Controller
{
    public function index()
    {
        $article = Article::latest('published_at')->get();
        $data = array(
            'articles' => $article
        );
        return view('pages.index' , compact($data));
    }

    public function contact()
    {
        return view('pages.contact');
    }

    public  function about()
    {
        return view('pages.about');
    }
}

Please help.

请帮忙。

采纳答案by vietnguyen09

I ran "php artisan ide-helper:models" -> Yes, it wrote some line in my models file and still not work I ran again "php artisan ide-helper:models" -> No, it created a new file called _ide_helper_models.php file but still not work.

我运行了“php artisan ide-helper:models”-> 是的,它在我的模型文件中写了一些行,但仍然无法工作我再次运行“php artisan ide-helper:models”-> 不,它创建了一个名为 _ide_helper_models 的新文件.php 文件,但仍然无法正常工作。

FINALLY

最后

I access file _ide_helper_models.phpand add this function into class Articleit work xD

我访问文件_ide_helper_models.php并将此功能添加到class Article它的工作中 xD

/**
 * Add an "order by" clause for a timestamp to the query.
 *
 * @param string $column
 * @return \Illuminate\Database\Query\Builder|static 
 * @static 
 */
public static function latest($column = 'created_at'){
    return \Illuminate\Database\Query\Builder::latest($column);
}