Skip to content

Commit 7300e94

Browse files
committed
Replace Laravel Str helpers with native PHP8 functions
1 parent 49ec43c commit 7300e94

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/Eloquent/Model.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public function getAttribute($key)
155155
}
156156

157157
// Dot notation support.
158-
if (Str::contains($key, '.') && Arr::has($this->attributes, $key)) {
158+
if (str_contains($key, '.') && Arr::has($this->attributes, $key)) {
159159
return $this->getAttributeValue($key);
160160
}
161161

@@ -177,7 +177,7 @@ public function getAttribute($key)
177177
protected function getAttributeFromArray($key)
178178
{
179179
// Support keys in dot notation.
180-
if (Str::contains($key, '.')) {
180+
if (str_contains($key, '.')) {
181181
return Arr::get($this->attributes, $key);
182182
}
183183

@@ -195,7 +195,7 @@ public function setAttribute($key, $value)
195195

196196
$value = $builder->convertKey($value);
197197
} // Support keys in dot notation.
198-
elseif (Str::contains($key, '.')) {
198+
elseif (str_contains($key, '.')) {
199199
// Store to a temporary key, then move data to the actual key
200200
$uniqueKey = uniqid($key);
201201
parent::setAttribute($uniqueKey, $value);

src/Query/Builder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ public function insertGetId(array $values, $sequence = null)
617617
public function update(array $values, array $options = [])
618618
{
619619
// Use $set as default operator.
620-
if (! Str::startsWith(key($values), '$')) {
620+
if (! str_starts_with(key($values), '$')) {
621621
$values = ['$set' => $values];
622622
}
623623

@@ -951,7 +951,7 @@ protected function compileWheres(): array
951951
}
952952

953953
// Convert id's.
954-
if (isset($where['column']) && ($where['column'] == '_id' || Str::endsWith($where['column'], '._id'))) {
954+
if (isset($where['column']) && ($where['column'] == '_id' || str_ends_with($where['column'], '._id'))) {
955955
// Multiple values.
956956
if (isset($where['values'])) {
957957
foreach ($where['values'] as &$value) {

0 commit comments

Comments
 (0)