| Package Data | |
|---|---|
| Maintainer Username: | mustafakhaleddev |
| Maintainer Contact: | MustafaKhaled.dev@gmail.com (MustafaKhaled) |
| Package Create Date: | 2017-08-20 |
| Package Last Update: | 2024-06-02 |
| Language: | PHP |
| License: | MIT |
| Last Refreshed: | 2025-11-03 03:00:51 |
| Package Statistics | |
|---|---|
| Total Downloads: | 265,076 |
| Monthly Downloads: | 2,558 |
| Daily Downloads: | 27 |
| Total Stars: | 28 |
| Total Watchers: | 1 |
| Total Forks: | 13 |
| Total Open Issues: | 0 |

Laravel unique Token Generator
// Generate unique Token From Database.
$new_token = $token->Unique($table_name, $column_name, $size);
Require this package, with Composer, in the root directory of your project.
$ composer require dirape/token
Add the service provider to config/app.php in the providers array, or if you're using Laravel 5.5, this can be done via the automatic package discovery.
Dirape\Token\TokenServiceProvider::class
If you want you can use the facade. Add the reference in config/app.php to your aliases array.
'Token'=>\Dirape\Token\Facades\Facade::class
To use new trait token you need to do some changes in the model that contain the token column.
use DirapeToken; in the model .dt_token to replace with your column name add protected $DT_Column='column_name'; in the model . ['type' => DT_Unique, 'size' => 40, 'special_chr' => false] to replace with your custom settings add protected $DT_settings=['type'=>DT_Unique,'size'=>60,'special_chr'=>false]; in the model . Const DT_Unique = 'Unique';
Const DT_UniqueNum = 'UniqueNumber';
Const DT_UniqueStr = 'UniqueString';
Const DT_Random = 'Random';
Const DT_RandomNum = 'RandomNumber';
Const DT_RandomStr = 'RandomString';
$user=User::first();
$user->setToken();
$user->save();
setToken(); function like this $user=User::first();
$user->setToken(DT_UniqueStr,100,false);
$user->save();
$user=User::first();
$user->setToken(DT_UniqueStr,100,false,'column_name');
$user->save();
WithToken() .
$user=User::WithToken()->get();
false in WithToken()
$user=User::WithToken(false)->get();
use DirapeMultiToken; in the model . protected $DMT_columns=[
'unique_id'=>['type'=>DT_Unique,'size'=>60,'special_chr'=>false],
'unique_uid'=>['type'=>DT_Unique,'size'=>30,'special_chr'=>false],
];
Const DT_Unique = 'Unique';
Const DT_UniqueNum = 'UniqueNumber';
Const DT_UniqueStr = 'UniqueString';
Const DT_Random = 'Random';
Const DT_RandomNum = 'RandomNumber';
Const DT_RandomStr = 'RandomString';
$user=User::first();
$user->setTokens();
$user->save();
With this package you can generate unqiue token not repated in database just by using unique($table_name,$column_name,$size) Function $table_name is the table name in database , $column_name is the column name in the table, $size is token size.
generate unique strings token with the same signature of unique token with function UniqueString($table_name,$column_name,$size).
generate unique integers token with the same signature of unique token with function UniqueNumber($table_name,$column_name,$size).
generate random token with function Random($size) and $size is the size of token length.
generate random integer token with function RandomNumber($size) and $size is the size of token length.
generate random string token with function RandomString($size) and $size is the size of token length.
use true to allow special characters in your token !@#$%^&*() in all functions just like Random($size,true).
Here you can see an example of just how simple this package is to use.
// Generate unique token not rebeated in database table with column name
Token::Unique($table_name, $column_name, 10 );
//Result: fCWih6TDAf
// Generate unique integer token not rebeated in database table with column name
Token::UniqueNumber($table_name, $column_name, 10 );
//Result: 9647307239
// Generate unique string token not rebeated in database table with column name
Token::UniqueString($table_name, $column_name, 10 );
//Result: SOUjkyAyxC
//You can use special characters just add "true" to the function
Token::Unique($table_name, $column_name, 10,true );
//Result: H@klU$u^3z
$size=10;
// Generate random token
Token::Random($size);
// Generate random integer token
Token::RandomNumber($size);
// Generate random string token
Token::RandomString($size);
//You can use special characters just add "true" to the function
Token::Random($size,true);