Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PhpStorm laravel 5 method not found

Im f*cking crazy whith PhpStorm when tried to fix a popular error 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.

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

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.

like image 452
Johnny Nguyen Avatar asked Nov 10 '22 00:11

Johnny Nguyen


1 Answers

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.

FINALLY

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);
}
like image 56
Johnny Nguyen Avatar answered Nov 14 '22 22:11

Johnny Nguyen