3

Basically what's described in this post.

In PHPStorm there is no code hinting for the eloquent methods - which is quite confusing (I am just learning Eloquent).

None of the provided solutions are working for Laravel 6+ it seems. Currently using Laravel 8. Wanted to push this topic again - maybe someone found a fitting solution already.

Code Example:

app\Models\Article.php

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;


class Article extends Model
{
    use HasFactory;
}

Controller:

use App\Models\Article;

$article = Article::where(...); //no code hint

Happens to pretty much all methods.

Syllz
  • 290
  • 6
  • 22

2 Answers2

2

You should use laravel-ide-helper package (https://github.com/barryvdh/laravel-ide-helper).

Install:

composer require --dev barryvdh/laravel-ide-helper

Hinting for models:

php artisan ide-helper:models

php artisan ide-helper:models --reset

Use --reset option to replace whole phpdoc block in models.

Code hinting for facades methods:

php artisan ide-helper:generate

Code hinting for classes called through containers:

php artisan ide-helper:meta
IndianCoding
  • 2,602
  • 1
  • 6
  • 12
0

you have to use get for fetch data after search with where sentence , so you have to use get at the end . $articles = Article::where(...)->get();

nasrin.mkh
  • 91
  • 1
  • 2
  • 8