refactor: replace custom CRM with Monica fork
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s
This commit is contained in:
37
app/Traits/Hasher.php
Normal file
37
app/Traits/Hasher.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
use App\Services\Instance\IdHasher;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/** @psalm-implements \App\Interfaces\Hashing */
|
||||
trait Hasher
|
||||
{
|
||||
/**
|
||||
* @psalm-suppress MethodSignatureMustProvideReturnType
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRouteKey()
|
||||
{
|
||||
return app(IdHasher::class)->encodeId(parent::getRouteKey());
|
||||
}
|
||||
|
||||
public function resolveRouteBinding($value, $field = null): ?Model
|
||||
{
|
||||
$id = $this->decodeId($value);
|
||||
|
||||
return parent::resolveRouteBinding($id, $field);
|
||||
}
|
||||
|
||||
protected function decodeId($value)
|
||||
{
|
||||
return app(IdHasher::class)->decodeId($value);
|
||||
}
|
||||
|
||||
public function hashID()
|
||||
{
|
||||
return $this->getRouteKey();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user