Skip to content

Commit

Permalink
Merge pull request #18 from Spargon/add-install-command
Browse files Browse the repository at this point in the history
Adds install command
  • Loading branch information
TechTailor authored Sep 8, 2022
2 parents ee320a7 + ac00dab commit b1fde9a
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 22 deletions.
48 changes: 45 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
29 changes: 11 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,24 @@ 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:

```bash
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;
Expand Down Expand Up @@ -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

Expand Down
Binary file added install-command.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 15 additions & 1 deletion src/AuthLoggerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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()
Expand Down

0 comments on commit b1fde9a

Please sign in to comment.