Skip to content

Commit 2a53bf3

Browse files
committed
Update Helper.php
1 parent 6bc1aec commit 2a53bf3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Helper.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22

33
namespace T0team\LaravelPanel;
44

5+
use Illuminate\Database\Eloquent\Model;
56
use Illuminate\Support\Str;
67

78
class Helper
89
{
9-
public static function value(mixed $data, ?string $key): mixed
10+
public static function value(mixed $data, mixed $key): mixed
1011
{
1112
if (is_null($key)) return null;
1213

14+
if ($key instanceof Model) {
15+
return $key?->getKey();
16+
}
17+
1318
return collect(explode('->', $key))->reduce(function ($carry, string $item) {
1419
$item = Str::of($item)->trim();
1520

0 commit comments

Comments
 (0)