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

Adding @method docblocks on the Eloquent/Model.php #269

Closed
imanghafoori1 opened this issue Oct 13, 2015 · 8 comments
Closed

Adding @method docblocks on the Eloquent/Model.php #269

imanghafoori1 opened this issue Oct 13, 2015 · 8 comments

Comments

@imanghafoori1
Copy link

Hi,
I am using your great package and I see that there is no auto-completion for my models if I do not extend the \Eloquent class in the _ide_helper.php. It makes a dependency on the file which should be removed before pushing to production.

Another way of providing the auto-completion is to add the proper docblocks on the Eloquent/Model.php before the class definition.

see offical Documentation :
http://www.phpdoc.org/docs/latest/references/phpdoc/tags/method.html#examples

Here is a sample which I use for my own project.

use Illuminate\Database\Eloquent\Model as EloquentModel;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Query\Builder as QueryBuilder;

/**
 * @method EloquentModel|Collection|null static $this find($id, $columns = ['*']) Find a model by its primary key.
 * @method Collection static findMany($ids, $columns = ['*']) Find a model by its primary key.
 * @method EloquentModel|Collection static findOrFail($id, $columns = ['*']) Find a model by its primary key or throw an exception.
 * @method EloquentModel|EloquentBuilder|null first($columns = ['*']) Execute the query and get the first result.
 * @method EloquentModel|EloquentBuilder firstOrFail($columns = ['*']) Execute the query and get the first result or throw an exception.
 * @method Collection|EloquentBuilder[] get($columns = ['*']) Execute the query as a "select" statement.
 * @method mixed value($column) Get a single column's value from the first result of a query.
 * @method mixed pluck($column) Get a single column's value from the first result of a query.
 * @method void chunk($count, callable $callback) Chunk the results of the query.
 * @method \Illuminate\Support\Collection lists($column, $key = null) Get an array with the values of a given column.
 * @method \Illuminate\Contracts\Pagination\LengthAwarePaginator paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null) Paginate the given query.
 * @method \Illuminate\Contracts\Pagination\Paginator simplePaginate($perPage = null, $columns = ['*'], $pageName = 'page') Paginate the given query into a simple paginator.
 * @method int increment($column, $amount = 1, array $extra = []) Increment a column's value by a given amount.
 * @method int decrement($column, $amount = 1, array $extra = []) Decrement a column's value by a given amount.
 * @method void onDelete(Closure $callback) Register a replacement for the default delete function.
 * @method \Illuminate\Database\Eloquent\Model[] getModels($columns = ['*']) Get the hydrated models without eager loading.
 * @method array eagerLoadRelations(array $models) Eager load the relationships for the models.
 * @method array loadRelation(array $models, $name, Closure $constraints) Eagerly load the relationship on a set of models.
 * @method EloquentBuilder where($column, $operator = null, $value = null, $boolean = 'and') Add a basic where clause to the query.
 * @method EloquentBuilder orWhere($column, $operator = null, $value = null) Add an "or where" clause to the query.
 * @method EloquentBuilder has($relation, $operator = '>=', $count = 1, $boolean = 'and', Closure $callback = null) Add a relationship count condition to the query.
 *
 *
 * @method QueryBuilder where($column, $operator = null, $value = null)
 * @method QueryBuilder whereRaw($sql, array $bindings = [])
 * @method QueryBuilder whereBetween($column, array $values)
 * @method QueryBuilder whereNotBetween($column, array $values)
 * @method QueryBuilder whereNested(Closure $callback)
 * @method QueryBuilder addNestedWhereQuery($query)
 * @method QueryBuilder whereExists(Closure $callback)
 * @method QueryBuilder whereNotExists(Closure $callback)
 * @method QueryBuilder whereIn($column, $values)
 * @method QueryBuilder whereNotIn($column, $values)
 * @method QueryBuilder whereNull($column)
 * @method QueryBuilder whereNotNull($column)
 * @method static QueryBuilder where($column, $operator = null, $value = null)
 * @method static QueryBuilder whereRaw($sql, array $bindings = [])
 * @method static QueryBuilder whereBetween($column, array $values)
 * @method static QueryBuilder whereNotBetween($column, array $values)
 * @method static QueryBuilder whereNested(Closure $callback)
 * @method static QueryBuilder addNestedWhereQuery($query)
 * @method static QueryBuilder whereExists(Closure $callback)
 * @method static QueryBuilder whereNotExists(Closure $callback)
 * @method static QueryBuilder whereIn($column, $values)
 * @method static QueryBuilder whereNotIn($column, $values)
 * @method static QueryBuilder whereNull($column)
 * @method static QueryBuilder whereNotNull($column)
 * @method QueryBuilder orWhere($column, $operator = null, $value = null)
 * @method QueryBuilder orWhereRaw($sql, array $bindings = [])
 * @method QueryBuilder orWhereBetween($column, array $values)
 * @method QueryBuilder orWhereNotBetween($column, array $values)
 * @method QueryBuilder orWhereExists(Closure $callback)
 * @method QueryBuilder orWhereNotExists(Closure $callback)
 * @method QueryBuilder orWhereIn($column, $values)
 * @method QueryBuilder orWhereNotIn($column, $values)
 * @method QueryBuilder orWhereNull($column)
 * @method QueryBuilder orWhereNotNull($column)
 * @method QueryBuilder whereDate($column, $operator, $value)
 * @method QueryBuilder whereDay($column, $operator, $value)
 * @method QueryBuilder whereMonth($column, $operator, $value)
 * @method QueryBuilder whereYear($column, $operator, $value)
 *
 * Class Model
 *
 * @package Illuminate\Database\Eloquent
 */
abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializable, QueueableEntity, UrlRoutable
{
@brazenvoid
Copy link

wow, I never thought that this many functions were excluded... Though I think it would be best that someone adds a PR of it rather than requesting the authors as its low on their priority list.

@shehi
Copy link

shehi commented Oct 13, 2015

Why don't you do it with @mixin \Eloquent and be done with it? I don't really want that load of mumbo jumbo in my code.

@imanghafoori1
Copy link
Author

I didn't use @mixin in my code because I have never heard of that.:D
Thank you. I works...

@imanghafoori1
Copy link
Author

Any way it was better for @mixin \Eloquent to be automatically added when issuing

php artisan ide-helper:models

on the models.
I think it was not a problem in laravel 4 days.

@antriver
Copy link

A workaround is to have all your models extend a base class which itself extends Illuminate\Database\Eloquent\Model and add @mixin \Eloquent in the phpDoc for that base class.

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

Does anyone knows why Taylor don't add those methods and properties in the laravel source ?

@pjona
Copy link

pjona commented Mar 29, 2017

@adaojunior I saw his answer, that he doesn't like IDE mess in code.

@mfn
Copy link
Collaborator

mfn commented Jun 25, 2020

@barryvdh another issue which was solved some time ago due to @mixin support, I vote for closing this :}

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

8 participants