Skip to content

Commit

Permalink
Update Helper.php
Browse files Browse the repository at this point in the history
  • Loading branch information
ah-rahimi committed Jun 26, 2024
1 parent 6bc1aec commit 2a53bf3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@

namespace T0team\LaravelPanel;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;

class Helper
{
public static function value(mixed $data, ?string $key): mixed
public static function value(mixed $data, mixed $key): mixed
{
if (is_null($key)) return null;

if ($key instanceof Model) {
return $key?->getKey();
}

return collect(explode('->', $key))->reduce(function ($carry, string $item) {
$item = Str::of($item)->trim();

Expand Down

0 comments on commit 2a53bf3

Please sign in to comment.