laravel-hashids | Laravel package for Hashids | Build Tool library
kandi X-RAY | laravel-hashids Summary
kandi X-RAY | laravel-hashids Summary
Laravel package for Hashids
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Register the hashids .
- Register the hashids .
- Get the hashids .
- Determine if the application is Laravel .
- Get the facade accessor .
laravel-hashids Key Features
laravel-hashids Examples and Code Snippets
Hashids::decode(Ri7Bi);
// Returns
array (size=1)
0 => int 1
Hashids::decode(MMtaUpSGhdA);
// Returns
array (size=5)
0 => int 1
1 => int 21
2 => int 12
3 => int 12
4 => int 666
$ composer require torann/hashids
'providers' => [
Torann\Hashids\HashidsServiceProvider::class,
]
'aliases' => [
'Hashids' => Torann\Hashids\Facade\Hashids::class,
]
Hashids::encode(1); // Returns Ri7Bi
Hashids::encode(1, 21, 12, 12, 666); // Returns MMtaUpSGhdA
Community Discussions
Trending Discussions on laravel-hashids
QUESTION
I'm looking to sort of "intercept" and change a field in a model before it's send back to the client. I have an API with endpoints similar to the following:
...ANSWER
Answered 2020-Aug-01 at 17:55You can use API Resources https://laravel.com/docs/7.x/eloquent-resources#introduction
API Resource acts as a transformation layer that sits between your Eloquent models and the JSON responses that are actually returned to your application's users.
You may create an API resource for the user and use it wherever you're returning the user in the response.
Api resources gives you a lot more control, you could manipulate whatever field you want, send some extra fields using the combination of a few fields, change the name of the fields that you want in your response (xyz => $this->name
)
UserResource
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install laravel-hashids
Hashids on GitHub
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page