找不到PhpStorm Laravel 5方法 [英] PhpStorm laravel 5 method not found

查看:300
本文介绍了找不到PhpStorm Laravel 5方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试修复常见错误Method 'Bla bla' not found in class.

我一直在Google搜寻了几天,希望能找到解决这个问题的方法,但是没有运气.

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

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

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.

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

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

这是我的代码.

<?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');
    }
}

请帮助.

推荐答案

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

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.

最后

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

I access file _ide_helper_models.php and add this function into class Article it work 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);
}

这篇关于找不到PhpStorm Laravel 5方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆