diff --git a/config/manageable.php b/config/manageable.php new file mode 100644 index 0000000..69a2eea --- /dev/null +++ b/config/manageable.php @@ -0,0 +1,7 @@ + true, + 'foreign_table' => 'users', + 'foreign_key' => 'id', +]; \ No newline at end of file diff --git a/src/ManageableServiceProvider.php b/src/ManageableServiceProvider.php index e411a3d..4459d60 100644 --- a/src/ManageableServiceProvider.php +++ b/src/ManageableServiceProvider.php @@ -14,7 +14,11 @@ class ManageableServiceProvider extends ServiceProvider */ public function boot() { - Blueprint::macro('manageable', function ($bigIntegers = true, $foreignTable = 'users', $foreignKey = 'id') { + $bigIntegers = config('manageable.big_integers', true); + $foreignTable = config('manageable.foreign_table', 'users'); + $foreignId = config('manageable.foreign_id', 'id'); + + Blueprint::macro('manageable', function ($bigIntegers, $foreignTable, $foreignKey) { $bigIntegers ? $this->unsignedBigInteger('created_by')->nullable()->index() : $this->unsignedInteger('created_by')->nullable()->index(); @@ -32,6 +36,10 @@ public function boot() ->on($foreignTable) ->onDelete('set null'); }); + + $this->publishes([ + __DIR__.'/../config/manageable.php' => config_path('manageable.php') + ], 'config'); } /**