Skip to content

Commit

Permalink
add timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
Nur Wachid committed Jun 25, 2024
1 parent 5189d36 commit d6e41af
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
10 changes: 10 additions & 0 deletions config/counter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

return [
'models' => [

'counter' => Turahe\Counters\Models\Counter::class,
'pivot' => Turahe\Counters\Models\Counterable::class,

],
];
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCountersTables extends Migration
return new class extends Migration
{
/**
* Run the migrations.
Expand Down Expand Up @@ -44,4 +44,4 @@ public function down()
Schema::dropIfExists('counterables');
Schema::dropIfExists('counters');
}
}
};
5 changes: 5 additions & 0 deletions src/CountersServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public function boot()
__DIR__.'/../database/migrations/0000_00_00_000000_create_counters_tables.php' => $this->app->databasePath().'/migrations/0000_00_00_000000_create_counters_tables.php',
], 'migrations');

if ($this->app instanceof \Illuminate\Foundation\Application) {
$databasePath = __DIR__ . '/../database/migrations';
$this->loadMigrationsFrom($databasePath);
}

if ($this->app->runningInConsole()) {
$this->commands([Commands\MakeCounter::class]);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Traits/HasCounter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public function counters()
Counter::class,
'counterable',
'counterables'
)->withPivot('value', 'id');
)->withPivot('value', 'id')
->withTimestamps();
}

/**
Expand Down

0 comments on commit d6e41af

Please sign in to comment.