1. Go to this page and download the library: Download tpenaranda/aiditokens 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/ */
class User extends Model
{
use TPenaranda\Aiditokens\Traits\Tokens;
public function generateToken(): string
{
return str_random(); // Your custom logic goes here.
}
class RouteServiceProvider extends ServiceProvider
{
public function boot()
{
Route::pattern('userToken', '^.{40}$'); // Watch out this regex if you're using custom tokens.
Route::bind('userToken', function ($value) {
return User::firstByToken($value) ?? abort(404);
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.