PHP code example of imran / laravel-encrypted-route-params
1. Go to this page and download the library: Download imran/laravel-encrypted-route-params library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
imran / laravel-encrypted-route-params example snippets
use Illuminate\Database\Eloquent\Model;
use Imran\EncryptedRouteParams\Traits\HasEncryptedAttributes;
class Invoice extends Model
{
use HasEncryptedAttributes;
/**
* The attributes that should be encrypted in URLs and toArray().
*/
protected $encrypted = [
'id',
'customer_id',
];
}
// Only encrypt 'invoice', leave 'org' as plaintext
Route::get('/orgs/{org}/invoices/{invoice}', ...)
->encrypted(only: ['invoice']);
// Encrypt everything except the 'slug'
Route::get('/u/{user}/{slug}', ...)
->encrypted(except: ['slug']);