Asked  7 Months ago    Answers:  5   Viewed   61 times

Trying to get a clean environment to work on Laravel 5.4 / PhpStorm. Followed all the instructions from: https://github.com/barryvdh/laravel-ide-helper (including installing the PhpStorm Laravel plugin)

Got the file_ide_helper.php generated, added

BarryvdhLaravelIdeHelperIdeHelperServiceProvider::class,

to its proper location, cleared cache, restarted...

Please look at attached image, is the lack of intellisense I get supposed to be fixed by the ide helper ?

enter image description here

 Answers

33

Ok here is the solution, assuming you have installed the helper already:

Example:

Replace in a controller:

use IlluminateSupportFacadesValidator;

by

  use Validator

In your config/app.php you must have this alias:

'Validator' => IlluminateSupportFacadesValidator::class,

In my case it was already there.

After this, no more error message for the example shown in the image above and I can use full power of phpstorm that correctly understands the ::make method.

Source https://github.com/barryvdh/laravel-ide-helper/issues/431#issuecomment-275898789 thanks @lazyone.

Saturday, May 29, 2021
 
Kevin_Kinsey
answered 7 Months ago
87

Two possible fixes for that:

  1. Make your models extend the Eloquent facade instead of IlluminateDatabaseEloquentModel.
  2. If you prefer to keep using the "Model" facade, you can make your own alias in config/app.php, then change "eloquent" to "model" in the config/ide-helper.php under extra. This will let ide-helper include all the methods from IlluminateDatabaseEloquentBuilder and IlluminateDatabaseQueryBuilder which is where the missing methods actually live.

(Source: https://laracasts.com/discuss/channels/general-discussion/phpstorm-thinks-modelwhere-doesnt-exist-on-model-l5/replies/37661)

Saturday, May 29, 2021
 
subroutines
answered 7 Months ago
95

Since you define a foreign key on the games table, you have a one-to-many relationship between the Player and Game already. Try adding the following relation to your Player model:

// Player.php
public function won()
{
    // must specify the foreign key because it is not the usual `_id` convention.
    return $this->hasMany(Game::class, 'winner');
}

Then access it on each player like:

@foreach($players as $player)
    {{ $player->won->count() }}
@endforeach

Rather than querying in the view file, you should ideally do the following in your controller:

public function index()
{
    /*Load the view and pass the groups*/
    return View::make('players.index')->with('players', Player::with('won')->get());
}
Saturday, May 29, 2021
 
dkcwd
answered 7 Months ago
61

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 IlluminateDatabaseQueryBuilder|static 
 * @static 
 */
public static function latest($column = 'created_at'){
    return IlluminateDatabaseQueryBuilder::latest($column);
}
Tuesday, August 24, 2021
 
user3599828
answered 4 Months ago
59

In order to have PHAR archive indexed by IDE it has to have .phar extension (that's a requirement).

The easiest solution is to place phpunit.phar somewhere in your project (usually it would be PROJECT_ROOT/vendor/ folder).

If having local copy is not desired (for whatever reason; although composer and other similar kind of tools (bower/npm/etc) are primarily aimed at keeping dependency stuff/packages locally), you may use symbolic links: either create a symbolic link to that file locally (e.g. PROJECT_ROOT/phpunit.phar --> /usr/bin/phpunit) .. or place a full copy (or such symbolic link) in separate folder somewhere on your disk and then reference it via PhpStorm's Settings | PHP | Include Paths functionality.

Saturday, September 18, 2021
 
kensil
answered 3 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :
 
Share