Skip to content

Commit

Permalink
[Feature] Make migrations publishable
Browse files Browse the repository at this point in the history
  • Loading branch information
janicerar committed Oct 19, 2018
1 parent 0e45781 commit 85bdafb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 41 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ Install via composer
$ composer require lifeonscreen/nova-google2fa
```

Run migrations
Publish config and migrations

``` bash
$ php artisan migrate
$ php artisan vendor:publish --provider="Lifeonscreen\Google2fa\ToolServiceProvider"
```

Publish config
Run migrations

``` bash
$ php artisan vendor:publish --provider="Lifeonscreen\Google2fa\ToolServiceProvider"
$ php artisan migrate
```

Add relation to User model
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ public function up()
$table->unsignedInteger('user_id');
$table->boolean('google2fa_enable')->default(false);
$table->string('google2fa_secret')->nullable();
$table->timestamp('created_at')
->default(DB::raw('CURRENT_TIMESTAMP'));
$table->timestamp('updated_at')
->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));
$table->text('recovery')->nullable();
$table->timestamps();

$table->foreign('user_id')
->references('id')
Expand Down

This file was deleted.

6 changes: 5 additions & 1 deletion src/ToolServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@ class ToolServiceProvider extends ServiceProvider
public function boot()
{
$this->loadViewsFrom(__DIR__ . '/../resources/views', 'google2fa');
$this->loadMigrationsFrom(__DIR__ . '/../resources/database');

// Publishing is only necessary when using the CLI.
if ($this->app->runningInConsole()) {
// Publishing the configuration file.
$this->publishes([
__DIR__ . '/../config/lifeonscreen2fa.php' => config_path('lifeonscreen2fa.php'),
], 'lifeonscreen2fa.config');

// Publishing the migrations.
$this->publishes([
__DIR__.'/../database/migrations/' => database_path('migrations')
], 'migrations');
}

$this->app->booted(function () {
Expand Down

0 comments on commit 85bdafb

Please sign in to comment.