Navigation Menu

Skip to content
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
Closed

Model::find and Model::findOrfail #74

moradgholi opened this issue Mar 29, 2014 · 5 comments

Comments

@moradgholi
Copy link

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
Copy link
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 as completed May 2, 2014
@atahrijouti
Copy link

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
Copy link

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
Copy link

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
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants