@@ -10,12 +10,12 @@ discard block |
||
| 10 | 10 | class QueryBuilder extends \Doctrine\DBAL\Query\QueryBuilder |
| 11 | 11 | { |
| 12 | 12 | private string $table; |
| 13 | - private array $relations= []; |
|
| 13 | + private array $relations = []; |
|
| 14 | 14 | |
| 15 | 15 | private AbstractSchemaManager $SchemaManager; |
| 16 | 16 | private ModelManager $modelManager; |
| 17 | 17 | |
| 18 | - public function __construct(\Doctrine\DBAL\Connection $connection,ModelManager $modelManager) |
|
| 18 | + public function __construct(\Doctrine\DBAL\Connection $connection, ModelManager $modelManager) |
|
| 19 | 19 | { |
| 20 | 20 | $this->modelManager = $modelManager; |
| 21 | 21 | $this->SchemaManager = $connection->createSchemaManager(); |
@@ -31,12 +31,12 @@ discard block |
||
| 31 | 31 | public function from($table, $alias = null): QueryBuilder |
| 32 | 32 | { |
| 33 | 33 | $this->table = $table; |
| 34 | - return parent::from($table,$alias); |
|
| 34 | + return parent::from($table, $alias); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | public function get(): Collection |
| 38 | 38 | { |
| 39 | - if(!$this->SchemaManager->tableExists($this->table)){ |
|
| 39 | + if (!$this->SchemaManager->tableExists($this->table)) { |
|
| 40 | 40 | return Collection::fromIterable([]); |
| 41 | 41 | } |
| 42 | 42 | $model = $this->modelManager->create($this->table); |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | ->map(static fn($value): Model => ($model)->setProperties($value)->with($relations)->setLoaded()); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - public function first(): Model|null |
|
| 53 | + public function first(): Model | null |
|
| 54 | 54 | { |
| 55 | - if(!$this->SchemaManager->tableExists($this->table)){ |
|
| 55 | + if (!$this->SchemaManager->tableExists($this->table)) { |
|
| 56 | 56 | return null; |
| 57 | 57 | } |
| 58 | 58 | $relations = $this->relations; |
@@ -69,15 +69,15 @@ |
||
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | - * Get single record by id |
|
| 73 | - * |
|
| 74 | - */ |
|
| 72 | + * Get single record by id |
|
| 73 | + * |
|
| 74 | + */ |
|
| 75 | 75 | public function getById($table, mixed $id): Model|null |
| 76 | 76 | { |
| 77 | 77 | $query = (new QueryBuilder($this->connection,$this->modelManager)) |
| 78 | - ->select('*') |
|
| 79 | - ->from($table, 't') |
|
| 80 | - ->where("t.id = '".$id."'"); |
|
| 78 | + ->select('*') |
|
| 79 | + ->from($table, 't') |
|
| 80 | + ->where("t.id = '".$id."'"); |
|
| 81 | 81 | return $query->first(); |
| 82 | 82 | } |
| 83 | 83 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | /** |
| 23 | 23 | * Create RecordManager |
| 24 | 24 | */ |
| 25 | - public function __construct(Connection $connection, ModelManager $modelManager,bool $isUsingUUID = false) |
|
| 25 | + public function __construct(Connection $connection, ModelManager $modelManager, bool $isUsingUUID = false) |
|
| 26 | 26 | { |
| 27 | 27 | $this->connection = $connection; |
| 28 | 28 | $this->isUsingUUID = $isUsingUUID; |
@@ -72,9 +72,9 @@ discard block |
||
| 72 | 72 | * Get single record by id |
| 73 | 73 | * |
| 74 | 74 | */ |
| 75 | - public function getById($table, mixed $id): Model|null |
|
| 75 | + public function getById($table, mixed $id): Model | null |
|
| 76 | 76 | { |
| 77 | - $query = (new QueryBuilder($this->connection,$this->modelManager)) |
|
| 77 | + $query = (new QueryBuilder($this->connection, $this->modelManager)) |
|
| 78 | 78 | ->select('*') |
| 79 | 79 | ->from($table, 't') |
| 80 | 80 | ->where("t.id = '".$id."'"); |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function getAll(string $tableName): Collection |
| 90 | 90 | { |
| 91 | - return (new QueryBuilder($this->connection,$this->modelManager)) |
|
| 91 | + return (new QueryBuilder($this->connection, $this->modelManager)) |
|
| 92 | 92 | ->select('*') |
| 93 | 93 | ->from($tableName, 't') |
| 94 | 94 | ->get(); |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | public function find(String $name) : QueryBuilder |
| 102 | 102 | { |
| 103 | - return (new QueryBuilder($this->connection,$this->modelManager)) |
|
| 103 | + return (new QueryBuilder($this->connection, $this->modelManager)) |
|
| 104 | 104 | ->select('*') |
| 105 | 105 | ->from($name, 't'); |
| 106 | 106 | } |