Skip to content

Commit 7e5b9ea

Browse files
ORM Corrections
Corrected return types in ORM modules
1 parent e2fd029 commit 7e5b9ea

File tree

8 files changed

+33
-27
lines changed

8 files changed

+33
-27
lines changed

src/ORM/HasAll.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
*/
1818
trait HasAll
1919
{
20-
public static function all(string $columns = '*'): array
20+
public static function all(string $columns = '*'): Builder
2121
{
22-
return Facades\DB::table(static::table())->select($columns)->toArray();
22+
return Facades\DB::table(static::table())->select($columns);
2323
}
2424
}
2525
}

src/ORM/HasFind.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22

33
namespace DatabaseFactory\ORM {
4-
5-
use DatabaseFactory\Facades\DB;
4+
5+
use DatabaseFactory\Builder;
6+
use DatabaseFactory\Facades\DB;
67

78
/**
89
* Allows an entity the ability to return one record
@@ -16,9 +17,9 @@
1617
*/
1718
trait HasFind
1819
{
19-
public static function find(int $id, string $columns = '*'): array
20+
public static function find(int $id, string $columns = '*'): Builder
2021
{
21-
return DB::table(static::table())->select($columns)->where('id', '=', $id)->toArray();
22+
return DB::table(static::table())->select($columns)->where('id', '=', $id);
2223
}
2324
}
2425
}

src/ORM/HasFirst.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22

33
namespace DatabaseFactory\ORM {
4-
5-
use DatabaseFactory\Facades\DB;
4+
5+
use DatabaseFactory\Builder;
6+
use DatabaseFactory\Facades\DB;
67

78

89
/**
@@ -18,7 +19,7 @@
1819
*/
1920
trait HasFirst
2021
{
21-
public static function first(string $columns = '*'): array
22+
public static function first(string $columns = '*'): Builder
2223
{
2324
return DB::table(static::table())->select($columns)->orderBy('id', 'ASC')->limit(1);
2425
}

src/ORM/HasJoin.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22

33
namespace DatabaseFactory\ORM {
4-
5-
use DatabaseFactory\Facades\DB;
4+
5+
use DatabaseFactory\Builder;
6+
use DatabaseFactory\Facades\DB;
67

78
/**
89
* Allows an entity the ability to join tables
@@ -16,9 +17,9 @@
1617
*/
1718
trait HasJoin
1819
{
19-
public static function join(string $table, array $on, string $columns = '*'): array
20+
public static function join(string $table, array $on, string $columns = '*'): Builder
2021
{
21-
return DB::table(static::table())->join($table, $on, $columns)->toArray();
22+
return DB::table(static::table())->join($table, $on, $columns);
2223
}
2324
}
2425
}

src/ORM/HasLast.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22

33
namespace DatabaseFactory\ORM {
4-
5-
use DatabaseFactory\Facades\DB;
4+
5+
use DatabaseFactory\Builder;
6+
use DatabaseFactory\Facades\DB;
67

78

89
/**
@@ -18,9 +19,9 @@
1819
*/
1920
trait HasLast
2021
{
21-
public static function last(string $columns = '*'): array
22+
public static function last(string $columns = '*'): Builder
2223
{
23-
return DB::table(static::table())->select($columns)->orderBy('id', 'DESC')->limit(1)->toArray();
24+
return DB::table(static::table())->select($columns)->orderBy('id', 'DESC')->limit(1);
2425
}
2526
}
2627
}

src/ORM/HasLike.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
*/
1919
trait HasLike
2020
{
21-
public static function like(string $field, string $pattern, string $columns = '*'): array
21+
public static function like(string $field, string $pattern, string $columns = '*'): Builder
2222
{
23-
return DB::table(static::table())->select($columns)->like($field, $pattern)->toArray();
23+
return DB::table(static::table())->select($columns)->like($field, $pattern);
2424
}
2525
}
2626
}

src/ORM/HasNot.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22

33
namespace DatabaseFactory\ORM {
4-
5-
use DatabaseFactory\Facades\DB;
4+
5+
use DatabaseFactory\Builder;
6+
use DatabaseFactory\Facades\DB;
67

78
/**
89
* Allows an entity the ability to return records
@@ -17,9 +18,9 @@
1718
*/
1819
trait HasNot
1920
{
20-
public static function whereNot($key = null, $value = null, string $columns = '*'): array
21+
public static function whereNot($key = null, $value = null, string $columns = '*'): Builder
2122
{
22-
return DB::table(static::table())->select($columns)->whereNot($key, $value)->toArray();
23+
return DB::table(static::table())->select($columns)->whereNot($key, $value);
2324
}
2425
}
2526
}

src/ORM/HasWhere.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22

33
namespace DatabaseFactory\ORM {
4-
5-
use DatabaseFactory\Facades\DB;
4+
5+
use DatabaseFactory\Builder;
6+
use DatabaseFactory\Facades\DB;
67

78

89
/**
@@ -18,9 +19,9 @@
1819
*/
1920
trait HasWhere
2021
{
21-
public static function where($key, $is = null, $value = null, string $columns = '*'): array
22+
public static function where($key, $is = null, $value = null, string $columns = '*'): Builder
2223
{
23-
return DB::table(static::table())->select($columns)->where($key, $is, $value)->toArray();
24+
return DB::table(static::table())->select($columns)->where($key, $is, $value);
2425
}
2526
}
2627
}

0 commit comments

Comments
 (0)