Skip to content

Commit a071683

Browse files
author
Mike Harrison
committed
change: replace deprecated functions
1 parent eeb78e0 commit a071683

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/CacheKey.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
use GeneaLabs\LaravelModelCaching\Traits\CachePrefixing;
44
use Illuminate\Database\Eloquent\Model;
55
use Illuminate\Database\Query\Builder;
6+
use Illuminate\Support\Arr;
67
use Illuminate\Support\Collection;
78
use Illuminate\Database\Query\Expression;
89
use Illuminate\Database\Eloquent\Relations\HasMany;
10+
use Illuminate\Support\Str;
911

1012
class CacheKey
1113
{
@@ -62,13 +64,13 @@ protected function getLimitClause() : string
6264

6365
protected function getTableSlug() : string
6466
{
65-
return str_slug($this->model->getTable())
67+
return Str::slug($this->model->getTable())
6668
. ":";
6769
}
6870

6971
protected function getModelSlug() : string
7072
{
71-
return str_slug(get_class($this->model));
73+
return Str::slug(get_class($this->model));
7274
}
7375

7476
protected function getOffsetClause() : string
@@ -87,7 +89,7 @@ protected function getOrderByClauses() : string
8789
return $orders
8890
->reduce(function ($carry, $order) {
8991
if (($order["type"] ?? "") === "Raw") {
90-
return $carry . "_orderByRaw_" . str_slug($order["sql"]);
92+
return $carry . "_orderByRaw_" . Str::slug($order["sql"]);
9193
}
9294

9395
return $carry . "_orderBy_" . $order["column"] . "_" . $order["direction"];
@@ -127,7 +129,7 @@ protected function getValuesClause(array $where = null) : string
127129

128130
protected function getValuesFromWhere(array $where) : string
129131
{
130-
if (array_get($where, "query")) {
132+
if (Arr::get($where, "query")) {
131133
$prefix = $this->getCachePrefix();
132134
$subKey = (new self($this->eagerLoad, $this->model, $where["query"]))
133135
->make();
@@ -139,11 +141,11 @@ protected function getValuesFromWhere(array $where) : string
139141
return $subKey;
140142
}
141143

142-
if (is_array(array_get($where, "values"))) {
144+
if (is_array(Arr::get($where, "values"))) {
143145
return implode("_", collect($where["values"])->flatten()->toArray());
144146
}
145147

146-
return array_get($where, "value", "");
148+
return Arr::get($where, "value", "");
147149
}
148150

149151
protected function getValuesFromBindings(array $where, string $values) : string

src/CacheTags.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Database\Eloquent\Model;
66
use Illuminate\Database\Eloquent\Relations\Relation;
77
use Illuminate\Database\Query\Builder;
8+
use Illuminate\Support\Str;
89

910
class CacheTags
1011
{
@@ -32,7 +33,7 @@ public function make() : array
3233
$relation = $this->getRelation($relationName);
3334

3435
return $this->getCachePrefix()
35-
. str_slug(get_class($relation->getQuery()->getModel()));
36+
. Str::slug(get_class($relation->getQuery()->getModel()));
3637
})
3738
->prepend($this->getTagName())
3839
->values()
@@ -64,6 +65,6 @@ protected function getRelation(string $relationName) : Relation
6465
protected function getTagName() : string
6566
{
6667
return $this->getCachePrefix()
67-
. str_slug(get_class($this->model));
68+
. Str::slug(get_class($this->model));
6869
}
6970
}

0 commit comments

Comments
 (0)