Skip to content

Commit b873387

Browse files
author
Fredrick Peter
committed
update
1 parent 3e82cc8 commit b873387

File tree

5 files changed

+41
-30
lines changed

5 files changed

+41
-30
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ Prior to installing `php-orm-database` get the [Composer](https://getcomposer.or
119119
**Step 1** — update your `composer.json`:
120120
```composer.json
121121
"require": {
122-
"peterson/database": "^4.3.4"
122+
"peterson/database": "^4.3.5"
123123
}
124124
```
125125

src/Capsule/AppManager.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public static function envDummy()
5858
PUSHER_SCHEME=https
5959
PUSHER_APP_CLUSTER=mt1
6060
61-
#©Copyright '. date('Y', time()) .'
6261
APP_DEVELOPER=
6362
APP_DEVELOPER_EMAIL=
6463
');

src/Collections/Traits/RelatedTrait.php

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ trait RelatedTrait{
2121
*/
2222
public function offsetExists($offset): bool
2323
{
24-
return isset($this->items[$offset]);
24+
return $this->__isset($offset);
2525
}
2626

2727
/**
@@ -55,7 +55,7 @@ public function offsetSet($offset, $value): void
5555
*/
5656
public function offsetUnset($offset): void
5757
{
58-
unset($this->items[$offset]);
58+
$this->__unset($offset);
5959
}
6060

6161
/**
@@ -69,17 +69,6 @@ public function has($key)
6969
return array_key_exists($key, $this->items);
7070
}
7171

72-
/**
73-
* Check if an item exists in the collection.
74-
*
75-
* @param string $key
76-
* @return bool
77-
*/
78-
public function __isset($key)
79-
{
80-
return isset($this->items[$key]);
81-
}
82-
8372
/**
8473
* Dynamically access collection items.
8574
*
@@ -103,6 +92,28 @@ public function __set($key, $value)
10392
$this->items[$key] = $value;
10493
}
10594

95+
/**
96+
* Check if an item exists in the collection.
97+
*
98+
* @param string $key
99+
* @return bool
100+
*/
101+
public function __isset($key)
102+
{
103+
return isset($this->items[$key]);
104+
}
105+
106+
/**
107+
* Remove an item from items collection.
108+
*
109+
* @param string $key
110+
* @return void
111+
*/
112+
public function __unset($key)
113+
{
114+
unset($this->items[$key]);
115+
}
116+
106117
/**
107118
* return items collection as an array
108119
*

src/Schema/Builder.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,7 +1334,13 @@ public function toSql()
13341334
*/
13351335
public function get($limit = null)
13361336
{
1337-
return $this->limit($limit)->getBuilder(true, false, __FUNCTION__);
1337+
// only allow get limit parameter
1338+
// if limit has not been set and if not empty
1339+
if(empty($this->limit) && !empty($limit)){
1340+
$this->limit($limit);
1341+
}
1342+
1343+
return $this->getBuilder(true, false, __FUNCTION__);
13381344
}
13391345

13401346
/**
@@ -1507,18 +1513,10 @@ public function updateOrIgnore(array $values)
15071513
/**
15081514
* Delete records from the database.
15091515
*
1510-
* @param mixed $id
15111516
* @return int
15121517
*/
1513-
public function delete($id = null)
1518+
public function delete()
15141519
{
1515-
// If an ID is passed to the method, we will set the where clause to check the
1516-
// ID to let developers to simply and quickly remove a single row from this
1517-
// database without manually specifying the "where" clauses on the query.
1518-
if (! is_null($id)) {
1519-
$this->where($this->from.'.id', '=', $id);
1520-
}
1521-
15221520
$this->applyBeforeQueryCallbacks();
15231521

15241522
$sql = $this->compile()->compileDelete($this);
@@ -1535,16 +1533,19 @@ public function delete($id = null)
15351533
}
15361534

15371535
/**
1538-
* Destroy/Delete records from the database.
1536+
* Destroy records from the database.
1537+
* [performing where clause under the hood]
1538+
*
1539+
* @param mixed $id
15391540
*
1540-
* @param string|int $id
1541+
* @param string $column
15411542
* [default column name is 'id']
15421543
*
15431544
* @return int
15441545
*/
1545-
public function destroy(string|int $id)
1546+
public function destroy($id, $column = 'id')
15461547
{
1547-
return $this->where('id', $id)->delete();
1548+
return $this->where($column, $id)->delete();
15481549
}
15491550

15501551
/**

src/Schema/Traits/BuilderTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@ protected function countBuilder($columns = ['*'], $close = true)
11891189
{
11901190
$this->applyBeforeQueryCallbacks();
11911191
$this->selectRaw('count' . '(' . $this->columnize(Forge::wrap($columns)) . ') as aggregate');
1192-
1192+
11931193
$results = $this->statement(
11941194
$this->compile()->compileSelect($this),
11951195
$this->getBindings(),

0 commit comments

Comments
 (0)