diff --git a/src/OData/BaseResource.php b/src/OData/BaseResource.php index e3fdbcb..39d0984 100644 --- a/src/OData/BaseResource.php +++ b/src/OData/BaseResource.php @@ -26,19 +26,19 @@ abstract class BaseResource implements ArrayAccess, Arrayable public string $endpoint; - final public function __construct(?string $connection = null, ?string $endpoint = null) + final public function __construct(string $connection = null, string $endpoint = null) { $this->connection ??= $connection ?? config('dynamics.connection'); $this->endpoint ??= $endpoint ?? config('dynamics.resources.'.static::class, Str::afterLast(static::class, '\\')); } - public static function new(?string $connection = null, ?string $endpoint = null): static + public static function new(string $connection = null, string $endpoint = null): static { return new static($connection, $endpoint); } - public static function query(?string $connection = null, ?string $endpoint = null): QueryBuilder + public static function query(string $connection = null, string $endpoint = null): QueryBuilder { return static::new($connection, $endpoint)->newQuery(); } @@ -128,7 +128,7 @@ public function etag(bool $force = false): string : $this->data['odata.etag']; } - public function client(?string $etag = null): ODataClient + public function client(string $etag = null): ODataClient { $factory = ClientFactory::make($this->connection); diff --git a/src/Query/QueryBuilder.php b/src/Query/QueryBuilder.php index 0371270..e9aa9d0 100644 --- a/src/Query/QueryBuilder.php +++ b/src/Query/QueryBuilder.php @@ -12,7 +12,34 @@ use SaintSystems\OData\ODataClient; use SaintSystems\OData\Query\Builder; -/** @mixin Builder */ +/** + * @method static select(array|mixed $properties = []) + * @method static addSelect(array|mixed $select) + * @method static from(string $entitySet) + * @method static whereKey(string $id) + * @method static expand(array $properties = []) + * @method static order(array|mixed $properties = []) + * @method static orderBySQL(string $sql = '') + * @method static mergeWheres(array $wheres, array $bindings) + * @method static where(string|array|\Closure $column, string $operator = null, mixed $value = null, string $boolean = 'and') + * @method static orWhere(string|array|\Closure $column, string $operator = null, mixed $value = null) + * @method static whereRaw(string $rawString, string $boolean = 'and') + * @method static orWhereRaw(string $rawString) + * @method static whereDate(string|array|\Closure $column, string $operator = null, mixed $value = null, string $boolean = 'and') + * @method static orWhereDate(string|array|\Closure $column, string $operator = null, mixed $value = null) + * @method static whereColumn(string|array $first, string $operator = null, string $second = null, string $boolean = 'and') + * @method static orWhereColumn(string|array $first, string $operator = null, string $second = null) + * @method static whereNested(\Closure $callback, string $boolean = 'and') + * @method static forNestedWhere() + * @method static addNestedWhereQuery(self $query, string $boolean = 'and') + * @method static whereNull(string $column, string $boolean = 'and', bool $not = false) + * @method static orWhereNull(string $column) + * @method static whereNotNull(string $column, string $boolean = 'and') + * @method static orWhereNotNull(string $column) + * @method static skip(int $value) + * @method static take(int $value) + * @method static addBinding(mixed $value, string $type = 'where') + */ class QueryBuilder { protected Builder $builder; @@ -123,7 +150,7 @@ public function firstOrCreate(array $attributes = [], array $values = []): BaseR return $this->newResourceInstance()->create($data); } - public function lazy(?int $pageSize = null): LazyCollection + public function lazy(int $pageSize = null): LazyCollection { return LazyCollection::make(function () use ($pageSize): Generator { $pageSize ??= (int) config('dynamics.connections.'.$this->connection.'.page_size');