Skip to content

Commit d33caca

Browse files
Merge branch 'master' into bugfix/fix-for-non-integer-key-models
# Conflicts: # composer.json
2 parents 303240e + 71af2b7 commit d33caca

File tree

15 files changed

+138
-49
lines changed

15 files changed

+138
-49
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.idea
22
/vendor
33
composer.lock
4+
.vscode

.scrutinizer.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,6 @@ filter:
99

1010
build:
1111
nodes:
12-
php71:
13-
environment:
14-
php:
15-
version: 7.1.3
16-
tests:
17-
override:
18-
- php-scrutinizer-run
19-
-
20-
command: vendor/bin/phpunit --coverage-clover=coverage71
21-
coverage:
22-
file: coverage71
23-
format: php-clover
2412
php72:
2513
environment:
2614
php:

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ env:
55
language: php
66

77
php:
8-
- 7.1
98
- 7.2
109

1110
before_script:

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## v9.0.0 (2019-03-02)
2+
### Added
3+
- Illuminate 5.8 support
4+
15
## v8.0.4 (2018-11-20)
26
### Changed
37
- Make the `auditable()` and `user()` method return types loose

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ The package documentation can be found on the [official website](http://laravel-
2222
## Version Information
2323
Version | Illuminate | Status | PHP Version
2424
:----------|:--------------|:------------------------|:------------
25-
8.x | 5.2.x - 5.7.x | Active support :rocket: | >= 7.0.13
25+
9.x | 5.8.x - 6.x.x | Active support :rocket: | >= 7.1.3
26+
8.x | 5.2.x - 5.7.x | Active support | >= 7.0.13
2627
7.x | 5.2.x - 5.6.x | End of life | >= 7.0.13
2728
6.x | 5.2.x - 5.6.x | End of life | >= 7.0.13
2829
5.x | 5.2.x - 5.5.x | End of life | >= 7.0.13

composer.json

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,14 @@
3939
}
4040
],
4141
"require": {
42-
"php": ">=7.1.3",
43-
"illuminate/console": "^5.8",
44-
"illuminate/database": "^5.8",
45-
"illuminate/filesystem": "^5.8"
42+
"php": ">=7.2",
43+
"illuminate/console": "^5.8|^6.0",
44+
"illuminate/database": "^5.8|^6.0",
45+
"illuminate/filesystem": "^5.8|^6.0",
46+
"laravel/helpers": "^1.1"
4647
},
4748
"require-dev": {
48-
"phpunit/phpunit": "^7.5",
49+
"phpunit/phpunit": "^8.0",
4950
"mockery/mockery": "^1.0",
5051
"orchestra/testbench": "^3.8",
5152
"ramsey/uuid": "^3.0"
@@ -65,12 +66,14 @@
6566
},
6667
"extra": {
6768
"branch-alias": {
68-
"dev-master": "8.0-dev"
69+
"dev-master": "9.0-dev"
6970
},
7071
"laravel": {
7172
"providers": [
7273
"OwenIt\\Auditing\\AuditingServiceProvider"
7374
]
7475
}
75-
}
76+
},
77+
"minimum-stability": "dev",
78+
"prefer-stable": true
7679
}

config/audit.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
return [
44

5+
'enabled' => env('AUDITING_ENABLED', true),
6+
57
/*
68
|--------------------------------------------------------------------------
79
| Audit Implementation

database/migrations/audits.stub

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class CreateAuditsTable extends Migration
1414
public function up()
1515
{
1616
Schema::create('audits', function (Blueprint $table) {
17-
$table->increments('id');
17+
$table->bigIncrements('id');
1818
$table->string('user_type')->nullable();
1919
$table->unsignedBigInteger('user_id')->nullable();
2020
$table->string('event');
@@ -23,10 +23,10 @@ class CreateAuditsTable extends Migration
2323
$table->text('new_values')->nullable();
2424
$table->text('url')->nullable();
2525
$table->ipAddress('ip_address')->nullable();
26-
$table->string('user_agent')->nullable();
26+
$table->string('user_agent', 1023)->nullable();
2727
$table->string('tags')->nullable();
2828
$table->timestamps();
29-
29+
3030
$table->index(['user_id', 'user_type']);
3131
});
3232
}

src/Audit.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
namespace OwenIt\Auditing;
44

55
use DateTimeInterface;
6-
use Illuminate\Database\Eloquent\Model;
6+
use Illuminate\Support\Str;
77
use Illuminate\Support\Facades\Config;
8+
use Illuminate\Database\Eloquent\Model;
89
use OwenIt\Auditing\Contracts\AttributeEncoder;
910

1011
trait Audit
@@ -146,12 +147,12 @@ public function getDataValue(string $key)
146147
$value = $this->data[$key];
147148

148149
// User value
149-
if ($this->user && starts_with($key, 'user_')) {
150+
if ($this->user && Str::startsWith($key, 'user_')) {
150151
return $this->getFormattedValue($this->user, substr($key, 5), $value);
151152
}
152153

153154
// Auditable value
154-
if ($this->auditable && starts_with($key, ['new_', 'old_'])) {
155+
if ($this->auditable && Str::startsWith($key, ['new_', 'old_'])) {
155156
$attribute = substr($key, 4);
156157

157158
return $this->getFormattedValue(

src/Auditable.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ trait Auditable
4646
*/
4747
public static function bootAuditable()
4848
{
49-
if (static::isAuditingEnabled()) {
49+
if (!self::$auditingDisabled && static::isAuditingEnabled()) {
5050
static::observe(new AuditableObserver());
5151
}
5252
}
@@ -284,8 +284,8 @@ public function toAudit(): array
284284
'event' => $this->auditEvent,
285285
'auditable_id' => $this->getKey(),
286286
'auditable_type' => $this->getMorphClass(),
287-
$morphPrefix.'_id' => $user ? $user->getAuthIdentifier() : null,
288-
$morphPrefix.'_type' => $user ? $user->getMorphClass() : null,
287+
$morphPrefix . '_id' => $user ? $user->getAuthIdentifier() : null,
288+
$morphPrefix . '_type' => $user ? $user->getMorphClass() : null,
289289
'url' => $this->resolveUrl(),
290290
'ip_address' => $this->resolveIpAddress(),
291291
'user_agent' => $this->resolveUserAgent(),
@@ -488,7 +488,7 @@ public static function isAuditingEnabled(): bool
488488
return Config::get('audit.console', false);
489489
}
490490

491-
return true;
491+
return Config::get('audit.enabled', true);
492492
}
493493

494494
/**

0 commit comments

Comments
 (0)