-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add #381 Add hash ids instead of actual ID for model routes [WIP] #777
Changes from 16 commits
e7ed9a7
30c44c5
6f8aae1
19039e6
c780dd7
7081fbe
d04ee9a
08077a4
32a2a04
8a803e7
0d842ec
ab76894
1c266d4
74d3251
68cb57e
6710767
efaf6db
dd6c55f
b223e31
1a7a590
2ce2a03
1ea2a03
ea9220a
c876f0d
f214e74
cebbb37
9c3615f
519e655
fec6ac4
7c5c77c
c6bb801
eaec0c6
ba7e58b
9d367ba
3883879
248557d
b422563
e75133b
9d7fb9c
2367249
935fc61
1a0f526
581b64e
c5d7148
5e7fa20
3e61bba
3e41094
f8cbf01
5afc84c
ea52800
60b51aa
4178078
1a6a6d7
71bed8c
77d7d3c
5f0e6ff
c71f096
0aac673
69edef4
aa7464f
b2d68d9
17da9e1
7c1cc7a
f803a54
e94f871
3d95f4f
f685331
902a108
163efa5
29a27b3
95f8e93
527161e
3431015
154acfb
555d30a
4013774
d0f5793
6524bb7
f7453c0
b6262d4
cedb357
e893407
4fe72b2
f510302
25ffb7a
ff4ef6c
74fa565
4a6fd91
7ed87de
58f8060
f6c7613
45176d8
a84d0ce
692e42b
1f4ac37
563368d
9574f3a
84d1fbd
4b5f5cd
5b05f70
0df3854
b6832d3
7856cbe
28aa481
32dd34d
b8a66a0
f6636f0
d59e272
1b297e5
07c0563
df44ede
99deded
8e16ff8
0beea0f
f806bbf
a01af38
a4eb62d
6f037eb
a5c65c7
f311fe3
975dd79
8aadf00
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace App\Helpers; | ||
|
||
use Vinkla\Hashids\Facades\Hashids; | ||
|
||
class ID_hasher | ||
{ | ||
|
||
public function encode_id($id) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
{ | ||
return Hashids::encode($id); | ||
} | ||
|
||
public function decode_id($hash) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
{ | ||
return Hashids::decode($hash); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace App\Traits; | ||
|
||
use App\Helpers\ID_hasher; | ||
|
||
trait Hasher | ||
{ | ||
|
||
public function getRouteKey() | ||
{ | ||
$ID_hasher = new ID_hasher(); | ||
|
||
return $ID_hasher->encode_id(parent::getRouteKey()); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Laravel Hashids. | ||
* | ||
* (c) Vincent Klaiber <hello@vinkla.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
return [ | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Default Connection Name | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Here you may specify which of the connections below you wish to use as | ||
| your default connection for all work. Of course, you may use many | ||
| connections at once using the manager class. | ||
| | ||
*/ | ||
|
||
'default' => 'main', | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Hashids Connections | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Here are each of the connections setup for your application. Example | ||
| configuration has been included, but you may add as many connections as | ||
| you would like. | ||
| | ||
*/ | ||
|
||
'connections' => [ | ||
|
||
'main' => [ | ||
'salt' => 'your-salt-string', | ||
'length' => '18', | ||
], | ||
|
||
'alternative' => [ | ||
'salt' => 'your-salt-string', | ||
'length' => 'your-length-integer', | ||
], | ||
|
||
], | ||
|
||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name
ID_hasher
is not PSR1 compliant.Please change it everywhere with
idHasher
.