Skip to content

Commit b1fde9a

Browse files
authored
Merge pull request #18 from Spargon/add-install-command
Adds install command
2 parents ee320a7 + ac00dab commit b1fde9a

File tree

4 files changed

+71
-22
lines changed

4 files changed

+71
-22
lines changed

CHANGELOG.md

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,54 @@
22

33
All notable changes to `laravel-auth-logger` will be documented in this file
44

5+
## 1.4.0 - 2022-09-08
6+
7+
- Added a new Install Command.
8+
9+
## 1.3.0 - 2022-02-23
10+
11+
- Added Support for Laravel 9.
12+
13+
## 1.2.2 - 2021-03-17
14+
15+
- Added Location Tagging (Dev - Experimental) Release Version.
16+
17+
## 1.2.2 - 2021-03-11
18+
19+
- Adds Support for Laravel 7.
20+
21+
## 1.2.1 - 2021-03-06
22+
23+
- Fixes Composer Require Issue.
24+
25+
## 1.2.0 - 2021-03-06
26+
27+
- This release completely revamps the ServiceProvider that ships with this package. Along with that comes new commands for publishing assets (refer to the readme file for details).
28+
- Added config option to change the default auth_logs table name.
29+
- Added much-needed Slack customization option and improvements.
30+
31+
## 1.1.1 - 2021-03-06
32+
33+
- Added Icons for User Devices.
34+
35+
## 1.1.0 - 2021-02-25
36+
37+
- Adding Support for Laravel's logoutOtherDevices Method.
38+
39+
## 1.0.7 - 2021-01-30
40+
41+
- Parsing user created_at column.
42+
43+
## 1.0.6 - 2020-12-21
44+
45+
- Minor variable name change.
46+
547
## 1.0.5 - 2020-12-14
648

7-
- Added Multi-Language Support
8-
- Fixed Minor Issues & Typos
49+
- Added Multi-Language Support.
50+
- Fixed Minor Issues & Typos.
951

1052

1153
## 1.0.0 - 2020-11-21
1254

13-
- Initial release
55+
- Initial release.

README.md

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,24 @@ Laravel Auth Logger stores user authentication logs and sends out notifications
1010

1111
## Installation
1212

13-
> Laravel Auth Logger requires PHP 7.0+ and currently supports Laravel 7, 8.
13+
> Laravel Auth Logger requires PHP 7.0+ and currently supports Laravel 7, 8 & 9.
1414
1515
You can install the package via composer:
1616

1717
```bash
1818
composer require spargon/laravel-auth-logger
1919
```
2020

21-
After installing the Laravel-Auth-Logger package, you need to publish the `auth-logger` config file using the artisan command below in your console:
21+
After installing the **Laravel-Auth-Logger** package, you need run the install command which will take care of everything you need to get started. Type the following artisan command in your console:
2222

2323
```bash
24-
php artisan vendor:publish --tag=auth-logger-config
24+
php artisan auth-logger:install
2525
```
26+
This will publish the `config/auth-logger.php` file, publish the necessary migration files and ask you for permission to run said migrations.
2627

27-
Next, you need to publish the migration file using the `vendor:publish` command in your console:
28+
![Install Command Sample](install-command.jpg)
2829

29-
```bash
30-
php artisan vendor:publish --tag=auth-logger-migrations
31-
```
32-
33-
If you want to change the name of the auth-logger table, you can do so by changing the vaule of `table_name` in the `config/auth-logger.php` file (this step is optional).
34-
35-
After that you need to migrate the recently published file to your database using the artisan command below (this will create a new table in your database for your app to use).
36-
37-
```bash
38-
php artisan migrate
39-
```
40-
41-
Lastly, you need to add the **`AuthLogable`** and **`Notifiable`** traits to your authenticatable model (by default its, `App\Models\User` model). These traits provides you with various methods to get the data generated by the auth logger, such as last login time, last login IP address, and sets the channels to notify the user when they login from a new device:
30+
Once installed, you need to add the **`AuthLogable`** and **`Notifiable`** traits to your authenticatable model (by default its, `App\Models\User` model). These traits provides you with various methods to get the data generated by the auth logger, such as last login time, last login IP address, and sets the channels to notify the user when they login from a new device:
4231

4332
``` php
4433
use Illuminate\Notifications\Notifiable;
@@ -159,11 +148,15 @@ php artisan vendor:publish --tag=auth-logger-translations
159148
```
160149
*These are optional files. You don't need to publish them for the package to work. They exist only for cases where you want to make any changes to the files yourself.*
161150

151+
#### Change Database Table Name
152+
153+
If you want to change the name of the auth-logger table, you can do so by changing the vaule of `table_name` in the `config/auth-logger.php` file (this step is optional - you must also update the table name in the migrations/database to reflect the same).
154+
162155
## Experimental (dev-geoip)
163156

164157
Currently we are experimenting with an implention of Location Tagging (using GeoIP package from Torann). You can checkout the `geoip` branch to play around with it or get the dev-geoip release from packagist using `composer require spargon/laravel-auth-logger:dev-geoip`
165158

166-
*This is an experimental release of location tagging. Accuracy is not 100% guaranteed. Use it at your own risk.*
159+
*This is an experimental release of location tagging. Accuracy is not 100% guaranteed. Use it at your own risk. PS> This experimental version does not contain the install command.*
167160

168161
## Testing
169162

install-command.jpg

45.5 KB
Loading

src/AuthLoggerServiceProvider.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Spargon\AuthLogger\Commands\AuthLoggerCommand;
66
use Spargon\AuthLogger\Providers\EventServiceProvider;
7+
use Spatie\LaravelPackageTools\Commands\InstallCommand;
78
use Spatie\LaravelPackageTools\Package;
89
use Spatie\LaravelPackageTools\PackageServiceProvider;
910

@@ -17,7 +18,20 @@ public function configurePackage(Package $package): void
1718
->hasViews()
1819
->hasTranslations()
1920
->hasMigration('create_auth_logs_table')
20-
->hasCommand(AuthLoggerCommand::class);
21+
->hasCommand(AuthLoggerCommand::class)
22+
->hasInstallCommand(function (InstallCommand $command) {
23+
$command
24+
->startWith(function (InstallCommand $command) {
25+
$command->info('Setting up the Laravel Auth Logger package by Spargon!');
26+
})
27+
->publishConfigFile()
28+
->publishMigrations()
29+
->askToRunMigrations()
30+
->askToStarRepoOnGitHub('spargon/laravel-auth-logger')
31+
->endWith(function (InstallCommand $command) {
32+
$command->info('Have a great day fellow tinkerers!');
33+
});
34+
});
2135
}
2236

2337
public function packageRegistered()

0 commit comments

Comments
 (0)