You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you want you can use the [facade](http://laravel.com/docs/facades). Add the reference in `config/app.php` to your aliases array.
26
27
27
28
```php
28
-
'Token' => \Dirape\Token\Facades\Facade::class
29
+
'Token'=>\Dirape\Token\Facades\Facade::class
29
30
```
30
31
31
-
## Usage
32
+
## Documentation
32
33
33
-
If you want to use a token in you model, you have to add the `DirapeToken` or `DirapeMultiToken` trait to your Eloquent model, depending on if you want to use multiple tokens per model.
34
-
To use trait token you need to do some changes in the model that contain the token column.
34
+
### ★ New Token Trait ★
35
+
##### setup in model
36
+
To use new trait token you need to do some changes in the model that contain the token column.
37
+
##### One Column Token
35
38
36
-
###Single token
39
+
##### One token Trait allow you to generate token for one columns in the table
37
40
38
-
* The token gets stored in the database. The column is called `dt_token` by default. To change this, you can add a `protected $DT_column` property to your model.
39
-
* Token settings are set by default to this value `['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.
41
+
* To use one column token you need to add `` use DirapeToken;`` in the model .
42
+
* In database we use default column called ``dt_token`` to replace with your column name add `` protected $DT_Column='column_name';`` in the model .
43
+
* Token settings are set by default to this value `` ['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 .
40
44
* you should know that we use custom constants for our token type
41
45
```php
42
-
const DT_Unique = 'Unique';
43
-
const DT_UniqueNum = 'UniqueNumber';
44
-
const DT_UniqueStr = 'UniqueString';
45
-
const DT_Random = 'Random';
46
-
const DT_RandomNum = 'RandomNumber';
47
-
const DT_RandomStr = 'RandomString';
48
-
```
46
+
Const DT_Unique = 'Unique';
47
+
Const DT_UniqueNum = 'UniqueNumber';
48
+
Const DT_UniqueStr = 'UniqueString';
49
+
Const DT_Random = 'Random';
50
+
Const DT_RandomNum = 'RandomNumber';
51
+
Const DT_RandomStr = 'RandomString';
52
+
```
49
53
* after preparing the model to use our trait token in your code you can set the token with your custom column and settings like this
50
54
```php
51
-
$user = User::first();
52
-
$user->setToken();
53
-
$user->save();
55
+
$user=User::first();
56
+
$user->setToken();
57
+
$user->save();
54
58
```
55
-
* you can use your custom settings in `setToken();` function like this
59
+
* you can use your custom settings in ``setToken();`` function like this
* you should know that we use custom constants for our token type
93
-
```php
94
-
const DT_Unique = 'Unique';
95
-
const DT_UniqueNum = 'UniqueNumber';
96
-
const DT_UniqueStr = 'UniqueString';
97
-
const DT_Random = 'Random';
98
-
const DT_RandomNum = 'RandomNumber';
99
-
const DT_RandomStr = 'RandomString';
100
-
```
93
+
```php
94
+
Const DT_Unique = 'Unique';
95
+
Const DT_UniqueNum = 'UniqueNumber';
96
+
Const DT_UniqueStr = 'UniqueString';
97
+
Const DT_Random = 'Random';
98
+
Const DT_RandomNum = 'RandomNumber';
99
+
Const DT_RandomStr = 'RandomString';
100
+
```
101
101
* after preparing the model to use our trait multi token in your code you can set the tokens with only one function
102
-
```php
103
-
$user = User::first();
104
-
$user->setTokens();
105
-
$user->save();
106
-
```
107
-
## Methods
102
+
```php
103
+
$user=User::first();
104
+
$user->setTokens();
105
+
$user->save();
106
+
```
107
+
108
+
109
+
### ★ The old way ★
110
+
#### Generate unique token
108
111
109
-
Here you can see an example of just how simple this package is to use.
112
+
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.
110
113
111
-
### Random tokens
112
114
113
-
```php
114
-
// Generate random token with upper- and lowercase letter and numbers. (a-z, A-Z, 0-9)
0 commit comments