Skip to content

Commit 37f3ac9

Browse files
Add support Laravel 12
1 parent 376f813 commit 37f3ac9

File tree

5 files changed

+54
-49
lines changed

5 files changed

+54
-49
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@
1717
/CONTRIBUTING.md export-ignore
1818
/bump-version.sh export-ignore
1919
/.github export-ignore
20+
.phpunit.cache

.github/workflows/run-tests.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,18 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
php: [ 8.3, 8.2 ]
13-
laravel: [ 10.*, 11.* ]
13+
laravel: [ 10.*, 11.* , 12.* ]
1414
stability: [ prefer-stable ]
1515
include:
16-
- laravel: 11.*
17-
testbench: 9.*
18-
carbon: ^2.63
19-
- laravel: 10.*
20-
testbench: 8.*
21-
carbon: ^2.63
16+
- laravel: 11.*
17+
testbench: 9.*
18+
carbon: ^2.63
19+
- laravel: 10.*
20+
testbench: 8.*
21+
carbon: ^2.63
22+
- laravel: 12.*
23+
testbench: 10.*
24+
carbon: ^3.8
2225

2326
steps:
2427
- name: Checkout code

README.md

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Laravel OTP(One-Time Password)
2+
23
[![Latest Version on Packagist](https://img.shields.io/packagist/v/fouladgar/laravel-otp.svg)](https://packagist.org/packages/fouladgar/laravel-otp)
34
![Test Status](https://img.shields.io/github/actions/workflow/status/mohammad-fouladgar/laravel-otp/run-tests.yml?label=tests)
45
![Code Style Status](https://img.shields.io/github/actions/workflow/status/mohammad-fouladgar/laravel-otp/php-cs-fixer.yml?label=code%20style)
@@ -11,14 +12,16 @@ send/resend and validate OTP for users authentication with user-friendly methods
1112

1213
## Version Compatibility
1314

14-
Laravel | Laravel-OTP
15-
:---------|:----------
16-
11.0.x | 4.2.x
17-
10.0.x | 4.0.x
18-
9.0.x | 3.0.x
19-
6.0.x to 8.0.x | 1.0.x
15+
| Laravel | Laravel-OTP |
16+
|:---------------|:------------|
17+
| 12.0.x | 4.4.x |
18+
| 11.0.x | 4.2.x |
19+
| 10.0.x | 4.0.x |
20+
| 9.0.x | 3.0.x |
21+
| 6.0.x to 8.0.x | 1.0.x |
2022

2123
## Basic Usage:
24+
2225
```php
2326
<?php
2427

@@ -85,6 +88,7 @@ OTP()->indicator('custom_indicator')
8588
->onlyConfirmToken()
8689
->validate('+98900000000', 'token_123');
8790
```
91+
8892
## Installation
8993

9094
You can install the package via composer:
@@ -129,7 +133,8 @@ one yet or have not planned to do it you can use `database` instead.
129133

130134
It means after migrating, a table will be created which your application needs to store verification tokens.
131135

132-
> If you’re using another column name for `mobile` phone or even `otp_tokens` table, you can customize their values in config file:
136+
> If you’re using another column name for `mobile` phone or even `otp_tokens` table, you can customize their values in
137+
> config file:
133138
134139
```php
135140
// config/otp.php
@@ -156,10 +161,13 @@ All right! Now you should migrate the database:
156161
php artisan migrate
157162
```
158163

159-
> **Note:** When you are using OTP to login user, consider all columns must be nullable except for the `mobile` column. Because, after verifying OTP, a user record will be created if the user does not exist.
164+
> **Note:** When you are using OTP to login user, consider all columns must be nullable except for the `mobile` column.
165+
> Because, after verifying OTP, a user record will be created if the user does not exist.
160166
161167
### Token Life Time
162-
You can specify an OTP `token_lifetime`, ensuring that once an OTP token is sent to the user, no new OTP token will be generated or sent until the current token has expired.
168+
169+
You can specify an OTP `token_lifetime`, ensuring that once an OTP token is sent to the user, no new OTP token will be
170+
generated or sent until the current token has expired.
163171

164172
```php
165173
// config/otp.php
@@ -175,6 +183,7 @@ return [
175183
//...
176184
];
177185
```
186+
178187
### User providers
179188

180189
You may wish to use the OTP for variant users. Laravel OTP allows you to define and manage many user providers that you
@@ -207,7 +216,8 @@ return [
207216
];
208217
```
209218

210-
> **Note:** You may also change the default repository and replace your own repository. however, every repository must implement `Fouladgar\OTP\Contracts\NotifiableRepositoryInterface` interface.
219+
> **Note:** You may also change the default repository and replace your own repository. however, every repository must
220+
> implement `Fouladgar\OTP\Contracts\NotifiableRepositoryInterface` interface.
211221
212222
#### Model Preparation
213223

@@ -356,7 +366,8 @@ return [
356366
];
357367
```
358368

359-
> **Note:** If you change the default sms channel, the `sms_client` will be an optional config. Otherwise, you must define your sms client.
369+
> **Note:** If you change the default sms channel, the `sms_client` will be an optional config. Otherwise, you must
370+
> define your sms client.
360371
361372
### Notification SMS and Email Customization
362373

@@ -382,7 +393,8 @@ public function boot()
382393
// SMS Customization
383394
OTPNotification::toSMSUsing(fn($notifiable, $token) =>(new OTPMessage())
384395
->to($notifiable->mobile)
385-
->content('Your OTP Token is: '.$token));
396+
->content('Your OTP Token is: '.$token))
397+
->template('OTP_TEMPLATE');
386398

387399
//Email Customization
388400
OTPNotification::toMailUsing(fn ($notifiable, $token) =>(new MailMessage)

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
"license": "MIT",
2525
"require": {
2626
"php": "^8.2",
27-
"illuminate/database": "^10.0|^11.0",
28-
"illuminate/support": "^10.0|^11.0",
29-
"illuminate/notifications": "^10.0|^11.0"
27+
"illuminate/database": "^10.0|^11.0|^12.0",
28+
"illuminate/support": "^10.0|^11.0|^12.0",
29+
"illuminate/notifications": "^10.0|^12.0"
3030
},
3131
"require-dev": {
32-
"phpunit/phpunit": "^10.5.17",
33-
"orchestra/testbench": "^7.0|^8.0",
32+
"phpunit/phpunit": "^10.5.17|^11.5.3",
33+
"orchestra/testbench": "^7.0|^8.0|^10.0",
3434
"mockery/mockery": "^1.4",
3535
"php-coveralls/php-coveralls": "^2.1"
3636
},
@@ -49,7 +49,7 @@
4949
}
5050
},
5151
"scripts": {
52-
"test": "vendor/bin/phpunit --testdox --coverage-text",
52+
"test": "vendor/bin/phpunit",
5353
"test-coverage": "vendor/bin/php-coveralls -v"
5454
},
5555
"extra": {

phpunit.xml

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,15 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
3-
<testsuites>
4-
<testsuite name="Unit">
5-
<directory suffix="Test.php">./tests</directory>
6-
</testsuite>
7-
</testsuites>
8-
<php>
9-
<env name="APP_ENV" value="testing"/>
10-
<!-- <env name="DB_CONNECTION" value="testing"/>-->
11-
<env name="DB_CONNECTION" value="sqlite"/>
12-
<env name="DB_DATABASE" value=":memory:"/>
13-
<env name="APP_KEY" value="base64:AyJGOtNkX6q4z+XaeZv11xdtseDc4P0ZL5gw2fS2aMw="/>
14-
</php>
15-
<source>
16-
<include>
17-
<directory suffix=".php">./src</directory>
18-
</include>
19-
<exclude>
20-
<file>src/Events/Verified.php</file>
21-
<file>src/Notifications/Messages/Payload.php</file>
22-
<file>src/ServiceProvider.php</file>
23-
<file>src/Exceptions/SMSClientNotFoundException.php</file>
24-
</exclude>
25-
</source>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" colors="true" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
3+
<testsuites>
4+
<testsuite name="Test Unit">
5+
<directory suffix="Test.php">./tests</directory>
6+
</testsuite>
7+
</testsuites>
8+
<php>
9+
<env name="APP_ENV" value="testing"/>
10+
<env name="DB_CONNECTION" value="sqlite"/>
11+
<env name="DB_DATABASE" value=":memory:"/>
12+
<env name="APP_KEY" value="base64:AyJGOtNkX6q4z+XaeZv11xdtseDc4P0ZL5gw2fS2aMw="/>
13+
</php>
2614
</phpunit>
15+

0 commit comments

Comments
 (0)