Skip to content

Commit 61df6f5

Browse files
committed
add Tips for better IDE support
1 parent c17fb5c commit 61df6f5

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,36 @@ Please see [API](API.md) for more informative API documentation.
137137

138138
## Tip for better IDE support
139139

140+
For better IDE support, you should add a `query` method phpDoc annotation to your model:
141+
142+
```php
143+
/**
144+
* @method static SpatialBuilder query()
145+
*/
146+
class Place extends Model
147+
{
148+
// ...
149+
}
150+
```
151+
152+
Or alternatively override the method:
153+
154+
```php
155+
class Place extends Model
156+
{
157+
public static function query(): SpatialBuilder
158+
{
159+
return parent::query();
160+
}
161+
}
162+
```
163+
164+
In order to get IDE auto-complete you should create queries only with the `query()` static method:
165+
166+
```php
167+
Place::query()->whereDistance(...); // This is IDE-friendly
168+
Place::whereDistance(...); // This is not
169+
```
140170

141171
## Tests
142172

0 commit comments

Comments
 (0)