diff --git a/CHANGELOG.md b/CHANGELOG.md index bcae379..943b91d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,54 @@ All notable changes to `laravel-auth-logger` will be documented in this file +## 1.4.0 - 2022-09-08 + +- Added a new Install Command. + +## 1.3.0 - 2022-02-23 + +- Added Support for Laravel 9. + +## 1.2.2 - 2021-03-17 + +- Added Location Tagging (Dev - Experimental) Release Version. + +## 1.2.2 - 2021-03-11 + +- Adds Support for Laravel 7. + +## 1.2.1 - 2021-03-06 + +- Fixes Composer Require Issue. + +## 1.2.0 - 2021-03-06 + +- 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). +- Added config option to change the default auth_logs table name. +- Added much-needed Slack customization option and improvements. + +## 1.1.1 - 2021-03-06 + +- Added Icons for User Devices. + +## 1.1.0 - 2021-02-25 + +- Adding Support for Laravel's logoutOtherDevices Method. + +## 1.0.7 - 2021-01-30 + +- Parsing user created_at column. + +## 1.0.6 - 2020-12-21 + +- Minor variable name change. + ## 1.0.5 - 2020-12-14 -- Added Multi-Language Support -- Fixed Minor Issues & Typos +- Added Multi-Language Support. +- Fixed Minor Issues & Typos. ## 1.0.0 - 2020-11-21 -- Initial release +- Initial release. diff --git a/README.md b/README.md index 94f2d46..9629b65 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Laravel Auth Logger stores user authentication logs and sends out notifications ## Installation -> Laravel Auth Logger requires PHP 7.0+ and currently supports Laravel 7, 8. +> Laravel Auth Logger requires PHP 7.0+ and currently supports Laravel 7, 8 & 9. You can install the package via composer: @@ -18,27 +18,16 @@ You can install the package via composer: composer require spargon/laravel-auth-logger ``` -After installing the Laravel-Auth-Logger package, you need to publish the `auth-logger` config file using the artisan command below in your console: +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: ```bash -php artisan vendor:publish --tag=auth-logger-config +php artisan auth-logger:install ``` +This will publish the `config/auth-logger.php` file, publish the necessary migration files and ask you for permission to run said migrations. -Next, you need to publish the migration file using the `vendor:publish` command in your console: +![Install Command Sample](install-command.jpg) -```bash -php artisan vendor:publish --tag=auth-logger-migrations -``` - -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). - -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). - -```bash -php artisan migrate -``` - -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: +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: ``` php use Illuminate\Notifications\Notifiable; @@ -159,11 +148,15 @@ php artisan vendor:publish --tag=auth-logger-translations ``` *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.* +#### Change Database Table Name + +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). + ## Experimental (dev-geoip) 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` -*This is an experimental release of location tagging. Accuracy is not 100% guaranteed. Use it at your own risk.* +*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.* ## Testing diff --git a/install-command.jpg b/install-command.jpg new file mode 100644 index 0000000..d16b7d5 Binary files /dev/null and b/install-command.jpg differ diff --git a/src/AuthLoggerServiceProvider.php b/src/AuthLoggerServiceProvider.php index b042440..09f075a 100644 --- a/src/AuthLoggerServiceProvider.php +++ b/src/AuthLoggerServiceProvider.php @@ -4,6 +4,7 @@ use Spargon\AuthLogger\Commands\AuthLoggerCommand; use Spargon\AuthLogger\Providers\EventServiceProvider; +use Spatie\LaravelPackageTools\Commands\InstallCommand; use Spatie\LaravelPackageTools\Package; use Spatie\LaravelPackageTools\PackageServiceProvider; @@ -17,7 +18,20 @@ public function configurePackage(Package $package): void ->hasViews() ->hasTranslations() ->hasMigration('create_auth_logs_table') - ->hasCommand(AuthLoggerCommand::class); + ->hasCommand(AuthLoggerCommand::class) + ->hasInstallCommand(function (InstallCommand $command) { + $command + ->startWith(function (InstallCommand $command) { + $command->info('Setting up the Laravel Auth Logger package by Spargon!'); + }) + ->publishConfigFile() + ->publishMigrations() + ->askToRunMigrations() + ->askToStarRepoOnGitHub('spargon/laravel-auth-logger') + ->endWith(function (InstallCommand $command) { + $command->info('Have a great day fellow tinkerers!'); + }); + }); } public function packageRegistered()