Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit c0e4425

Browse files
committed
Conditionally obscure IDs for if enabled for accessarea
1 parent eb945c9 commit c0e4425

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Traits/HashidsTrait.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ trait HashidsTrait
1515
*/
1616
public function getRouteKey()
1717
{
18-
return Hashids::encode($this->getAttribute($this->getRouteKeyName()), random_int(1, 999));
18+
return in_array(request()->route('accessarea'), config('cortex.foundation.obscure'))
19+
? Hashids::encode($this->getAttribute($this->getKeyName()), random_int(1, 999))
20+
: $this->getAttribute($this->getRouteKeyName());
1921
}
2022

2123
/**
@@ -27,8 +29,8 @@ public function getRouteKey()
2729
*/
2830
public function resolveRouteBinding($value)
2931
{
30-
$value = Hashids::decode($value)[0];
31-
32-
return $this->where($this->getRouteKeyName(), $value)->first();
32+
return in_array(request()->route('accessarea'), config('cortex.foundation.obscure'))
33+
? $this->where($this->getKeyName(), optional(Hashids::decode($value))[0])->first()
34+
: $this->where($this->getRouteKeyName(), $value)->first();
3335
}
3436
}

0 commit comments

Comments
 (0)