New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model::find and Model::findOrfail #74

Closed
moradgholi opened this Issue Mar 29, 2014 · 5 comments

Comments

Projects
None yet
6 participants
@moradgholi

moradgholi commented Mar 29, 2014

Hi,

This project is amazing !
but today i realized there is no auto suggestions for these two :
Model::find and Model::findOrfail

Can i add them manually ?

@barryvdh

This comment has been minimized.

Owner

barryvdh commented May 2, 2014

Hey, they both work for me. Could you verify it is still not working? Are you also indexing the vendor dir?

@barryvdh barryvdh closed this May 2, 2014

@abderrahmane-tj

This comment has been minimized.

abderrahmane-tj commented Mar 20, 2015

hi there. They are not working for me in Laravel 5. I had to manually add :

 * @method static \Illuminate\Database\Query\Builder|\App\Article findOrFail

to my Article Model to make sure PHPStorm recognized it in my controller when I do this :

$article = Article::findOrFail($id);
$input = Request::all();
$article->update($input);
@ababkov

This comment has been minimized.

ababkov commented Mar 31, 2015

@abderrahmane-tj Try getting your model to extend the \Eloquent alias instead.

@barryvdh It might be nice if the model helpers generated Eloquent\Builder method stubs for models that extend Illuminate\Database\Eloquent\Model.

@paslandau

This comment has been minimized.

paslandau commented Sep 28, 2015

Extending \Eloquent does the trick, although I feel a little uncomfortable to use this workaround as it couples my models to a "helper" package.

@barryvdh , any update on

@barryvdh It might be nice if the model helpers generated Eloquent\Builder method stubs for models that extend Illuminate\Database\Eloquent\Model.

?

Cheers
Pascal

//edit
Just read #168 - adding @mixin \Eloquent will also work (at least in PhpStorm). Example:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

/**
 * App\Company
 * @property integer $id
 * @property string $name
 * @property \Carbon\Carbon $created_at
 * @property \Carbon\Carbon $updated_at
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Product[] $products
 * @method static \Illuminate\Database\Query\Builder|\App\Company whereId($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Company whereName($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Company whereCreatedAt($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Company whereUpdatedAt($value)
 * @mixin \Eloquent
 *  ^-----------------------
 */
class Company extends Model
{
}
@mborges-ptc

This comment has been minimized.

mborges-ptc commented Dec 22, 2015

same issue here

matiaspub added a commit to matiaspub/laravel-ide-helper that referenced this issue Jan 12, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment