Normally you can use where()
, find()
, get()
and other static methods. But PHPStorm isn’t auto completing these methods although these methods exist. If you want to autocomplete these methods in PHPStorm I have an idea for this.
Create an abstract class which name is AbstractModel
. Important thing is that you must add mixin
directive to phpdoc section.
/** * Class AbstractModel * @package App\Models * * Autocomplete the Builder methods (for example where(), get(), find(), findOrFail() etc...) * @mixin \Illuminate\Database\Query\Builder */ abstract class AbstractModel extends Illuminate\Database\Eloquent\Model {}
After that you must extends this class in your models. For example:
class User extends AbstractModel implements AuthenticatableContract, AuthorizableContract { use Authenticatable, Authorizable, HasFactory; ....
After that you can use all Builder static methods in your model:
Happy coding…
0 yorum