| 1 | <?php |
||
| 9 | trait HashidsTrait |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * Get the value of the model's route key. |
||
| 13 | * |
||
| 14 | * @return mixed |
||
| 15 | */ |
||
| 16 | public function getRouteKey() |
||
| 17 | { |
||
| 18 | $obscure = property_exists($this,'obscure') && is_array($this->obscure) ? $this->obscure : config('cortex.foundation.obscure'); |
||
| 19 | |||
| 20 | return in_array(request()->route('accessarea'), $obscure['areas']) |
||
| 21 | ? Hashids::encode($this->getAttribute($this->getKeyName()), random_int(1, 999)) |
||
| 22 | ? Hashids::encode($this->getAttribute($this->getKeyName()), $obscure['rotate'] ? random_int(1, 999) : 1) |
||
| 23 | |||
| 24 | : $this->getAttribute($this->getRouteKeyName()); |
||
|
|
|||
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Retrieve the model for a bound value. |
||
| 29 | * |
||
| 30 | * @param mixed $value |
||
| 31 | * |
||
| 32 | * @return \Illuminate\Database\Eloquent\Model|null |
||
| 33 | */ |
||
| 34 | public function resolveRouteBinding($value) |
||
| 35 | { |
||
| 36 | $obscure = property_exists($this,'obscure') && is_array($this->obscure) ? $this->obscure : config('cortex.foundation.obscure'); |
||
| 37 | |||
| 43 |