Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

Commit

Permalink
Replace Laravel Str helpers with native PHP8 functions
Browse files Browse the repository at this point in the history
  • Loading branch information
GromNaN committed Aug 21, 2023
1 parent 9f1f8f3 commit 92cf02c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function getAttribute($key)
}

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

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

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

$value = $builder->convertKey($value);
} // Support keys in dot notation.
elseif (Str::contains($key, '.')) {
elseif (str_contains($key, '.')) {
// Store to a temporary key, then move data to the actual key
$uniqueKey = uniqid($key);
parent::setAttribute($uniqueKey, $value);
Expand Down
4 changes: 2 additions & 2 deletions src/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ public function insertGetId(array $values, $sequence = null)
public function update(array $values, array $options = [])
{
// Use $set as default operator.
if (! Str::startsWith(key($values), '$')) {
if (! str_starts_with(key($values), '$')) {
$values = ['$set' => $values];
}

Expand Down Expand Up @@ -951,7 +951,7 @@ protected function compileWheres(): array
}

// Convert id's.
if (isset($where['column']) && ($where['column'] == '_id' || Str::endsWith($where['column'], '._id'))) {
if (isset($where['column']) && ($where['column'] == '_id' || str_ends_with($where['column'], '._id'))) {
// Multiple values.
if (isset($where['values'])) {
foreach ($where['values'] as &$value) {
Expand Down

0 comments on commit 92cf02c

Please sign in to comment.