Skip to content

Commit e973e4f

Browse files
authored
Merge pull request #26 from schonhoff/master
feat: Add withDefault on deleter
2 parents bf1434c + 97e152e commit e973e4f

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ build
22
composer.lock
33
docs
44
vendor
5+
.idea

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ This package automatically inserts/updates an audit log on your table on who cre
1414
composer require yajra/laravel-auditable
1515
```
1616

17+
## Publish config file
18+
19+
If you want to modify the `withDefault` option on auditable columns, you may publish the config file.
20+
21+
```bash
22+
php artisan vendor:publish --tag=auditable
23+
```
24+
1725
## Usage
1826

1927
Update your model's migration and add `created_by` and `updated_by` field using the `auditable()` blueprint macro.

src/AuditableWithDeletesTrait.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ public static function bootAuditableWithDeletesTrait()
2626
*/
2727
public function deleter()
2828
{
29-
return $this->belongsTo($this->getUserClass(), $this->getDeletedByColumn())->withDefault();
29+
return $this->belongsTo($this->getUserClass(), $this->getDeletedByColumn())
30+
->withDefault(config('auditable.defaults.deleter'));
3031
}
3132

3233
/**

src/config/auditable.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,10 @@
1111
'name' => '',
1212
// add updater default values if not set
1313
],
14+
15+
'deleter' => [
16+
'name' => '',
17+
// add deleter default values if not set
18+
],
1419
],
1520
];

0 commit comments

Comments
 (0)