Skip to content
This repository has been archived by the owner on Sep 22, 2024. It is now read-only.

Commit

Permalink
feat: allow publishing config file
Browse files Browse the repository at this point in the history
  • Loading branch information
Razorsheep committed Nov 21, 2023
1 parent a2874f6 commit a67d978
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 7 additions & 0 deletions config/manageable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

return [
'big_integers' => true,
'foreign_table' => 'users',
'foreign_key' => 'id',
];
10 changes: 9 additions & 1 deletion src/ManageableServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -32,6 +36,10 @@ public function boot()
->on($foreignTable)
->onDelete('set null');
});

$this->publishes([
__DIR__.'/../config/manageable.php' => config_path('manageable.php')
], 'config');
}

/**
Expand Down

0 comments on commit a67d978

Please sign in to comment.