| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | namespace LaravelUi5\OData\Service\Resolver; |
| 6: | |
| 7: | use Illuminate\Database\Query\Builder; |
| 8: | use Illuminate\Support\Facades\DB; |
| 9: | use LaravelUi5\OData\Driver\Sql\SqlEntitySetResolver; |
| 10: | use LaravelUi5\OData\Http\CustomQueryOptions; |
| 11: | use LaravelUi5\OData\Service\Contracts\EntitySetResolverInterface; |
| 12: | use LaravelUi5\OData\Service\Contracts\EntitySetSourceInterface; |
| 13: | use LaravelUi5\OData\Service\Contracts\ResolverBindingInterface; |
| 14: | |
| 15: | |
| 16: | |
| 17: | |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | final readonly class SqlBinding implements ResolverBindingInterface, EntitySetSourceInterface |
| 23: | { |
| 24: | public function __construct( |
| 25: | public string $table, |
| 26: | public ?string $connection = null, |
| 27: | ) {} |
| 28: | |
| 29: | public function query(CustomQueryOptions $options): Builder |
| 30: | { |
| 31: | return DB::connection($this->connection)->table($this->table); |
| 32: | } |
| 33: | |
| 34: | public function createResolver(): EntitySetResolverInterface |
| 35: | { |
| 36: | return new SqlEntitySetResolver($this); |
| 37: | } |
| 38: | |
| 39: | |
| 40: | |
| 41: | |
| 42: | |
| 43: | public function getSourceClass(): ?string |
| 44: | { |
| 45: | return null; |
| 46: | } |
| 47: | } |
| 48: | |