PHP code example of alihann / laravel-rockid
1. Go to this page and download the library: Download alihann/laravel-rockid 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/ */
alihann / laravel-rockid example snippets
'providers' => [
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
...
Alihann\LaravelRockid\RockidServiceProvider::class,
],
'aliases' => [
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
...
'Rockid' => Alihann\LaravelRockid\Facades\Rockid::class,
],
use Illuminate\Database\Eloquent\Model;
use Alihann\LaravalRockId\ObfuscatesId;
class User extends Model {
use ObfuscatesId;
}
Route::bind('user', function ($value) {
$id = Rockid::decode($value);
return \App\User::find($id);
});
Route::get('user/{user}', function ($user) {
return $user->getId();
});
public function boot(Router $router)
{
parent::boot($router);
$router->bind('user', function ($value) {
$id = app('rockid')->decode($value);
return \App\User::find($id);
});
}
bash
php artisan vendor:publish
bash
php artisan rockid:generate