Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: PHPStan

on:
push:
pull_request:
paths:
- '**.php'
- 'phpstan.neon.dist'
Expand All @@ -10,6 +10,9 @@ jobs:
phpstan:
name: phpstan
runs-on: ubuntu-latest
timeout-minutes: 15
env:
COMPOSER_NO_INTERACTION: 1
steps:
- uses: actions/checkout@v4

Expand All @@ -24,8 +27,8 @@ jobs:

- name: Install larastan
run: |
composer require "larastan/larastan" --no-interaction --no-update
composer update --prefer-dist --no-interaction
composer require "larastan/larastan" --no-update
composer update --prefer-dist --no-suggest

- name: Run PHPStan
run: ./vendor/bin/phpstan --error-format=github
60 changes: 13 additions & 47 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,29 @@ name: run-tests

on:
push:
branches: [master]
pull_request:
branches: [master]
branches:
- '*'

jobs:
run-tests:
runs-on: ubuntu-latest
timeout-minutes: 15
env:
COMPOSER_NO_INTERACTION: 1
strategy:
fail-fast: false
matrix:
php: [7.4, 8.0, 8.1, 8.2, 8.3, 8.4]
laravel: [ 11.*, 10.*, 9.*, 8.*, 7.* ]
php: [ 8.2, 8.3, 8.4 ]
laravel: [ 11.*, 12.* ]
include:
- laravel: 12.*
testbench: 10.*
- laravel: 11.*
testbench: 9.*
- laravel: 10.*
testbench: 8.*
- laravel: 9.*
testbench: 7.*
- laravel: 8.*
testbench: 6.*
- laravel: 7.*
testbench: 5.*
exclude:
- laravel: 11.*
php: 8.1
- laravel: 11.*
php: 8.0
- laravel: 11.*
php: 7.4
- laravel: 10.*
php: 7.4
- laravel: 10.*
php: 8.0
- laravel: 9.*
php: 7.4
- laravel: 9.*
php: 8.4
- laravel: 8.*
php: 8.3
- laravel: 8.*
php: 8.4
- laravel: 7.*
php: 8.1
- laravel: 7.*
php: 8.2
- laravel: 7.*
php: 8.3
- laravel: 7.*
php: 8.4

name: PHP${{ matrix.php }} - Laravel${{ matrix.laravel }} - ${{ matrix.dependency-version }}

steps:
- name: Update apt
run: sudo apt-get update --fix-missing

- name: Checkout code
uses: actions/checkout@v4

Expand All @@ -71,11 +37,11 @@ jobs:

- name: Install dependencies
run: |
composer require "illuminate/console:${{ matrix.laravel }}" "illuminate/database:${{ matrix.laravel }}" "illuminate/filesystem:${{ matrix.laravel }}" "nesbot/carbon:^2.62.1" --no-interaction --no-update
composer require "orchestra/testbench:${{ matrix.testbench }}" --dev --no-interaction --no-update
composer update --prefer-dist --no-interaction --no-suggest
composer require "illuminate/console:${{ matrix.laravel }}" "illuminate/database:${{ matrix.laravel }}" "illuminate/filesystem:${{ matrix.laravel }}" --no-update
composer require "orchestra/testbench:${{ matrix.testbench }}" --dev --no-update
composer update --prefer-dist --no-suggest

- name: Execute tests
run: |
vendor/bin/phpunit
vendor/bin/phpunit tests/Unit/AuditTest.php --group command-line-url-resolver
vendor/bin/phpunit tests/Unit/AuditTest.php --group command-line-url-resolver
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<a href="https://discord.gg/csD9ysg"><img src="https://img.shields.io/badge/chat-on%20discord-7289DA.svg" alt="Chat"></a>
</p>

This package will help you understand changes in your Eloquent models, by providing information about possible discrepancies and anomalies that could indicate business concerns or suspect activities.
This package will help you understand changes in your Eloquent models, by providing information about possible discrepancies and anomalies that could indicate business concerns or suspect activities.

Laravel Auditing allows you to keep a history of model changes by simply using a trait. Retrieving the audited data is straightforward, making it possible to display it in various ways.

Expand All @@ -26,7 +26,8 @@ Thank you for choosing OwenIt\LaravelAuditing!

Version | Illuminate | Status | PHP Version
:----------|:---------------|:------------------------|:------------
13.x | 7.x.x - 11.x.x | Active support :rocket: | > = 7.3 \| 8.0
14.x | 11.x.x - 12.x.x | Active support :rocket: | > = 8.2
13.x | 7.x.x - 11.x.x | End of life | > = 7.3 \| 8.0
12.x | 6.x.x - 9.x.x | End of life | > = 7.3 \| 8.0
11.x | 5.8.x - 8.x.x | End of life | > = 7.3
10.x | 5.8.x - 7.x.x | End of life | > = 7.2.5
Expand Down
29 changes: 15 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "owen-it/laravel-auditing",
"description": "Audit changes of your Eloquent models in Laravel/Lumen",
"description": "Audit changes of your Eloquent models in Laravel",
"keywords": [
"accountability",
"audit",
Expand Down Expand Up @@ -39,17 +39,16 @@
}
],
"require": {
"php": "^7.3|^8.0",
"illuminate/console": "^7.0|^8.0|^9.0|^10.0|^11.0",
"illuminate/database": "^7.0|^8.0|^9.0|^10.0|^11.0",
"illuminate/filesystem": "^7.0|^8.0|^9.0|^10.0|^11.0",
"ext-json": "*"
"php": "^8.2",
"ext-json": "*",
"illuminate/console": "^11.0|^12.0",
"illuminate/database": "^11.0|^12.0",
"illuminate/filesystem": "^11.0|^12.0"
},
"require-dev": {
"phpunit/phpunit": "^9.6|^10.5|^11.0",
"mockery/mockery": "^1.0",
"orchestra/testbench": "^5.0|^6.0|^7.0|^8.0|^9.0",
"laravel/legacy-factories": "*"
"mockery/mockery": "^1.5.1",
"orchestra/testbench": "^9.0|^10.0",
"phpunit/phpunit": "^11.0"
},
"autoload": {
"psr-4": {
Expand All @@ -61,19 +60,21 @@
"OwenIt\\Auditing\\Tests\\": "tests/"
}
},
"suggest": {
"irazasyed/larasupport": "Needed to publish the package configuration in Lumen"
},
"extra": {
"branch-alias": {
"dev-master": "v13-dev"
"dev-master": "v14-dev"
},
"laravel": {
"providers": [
"OwenIt\\Auditing\\AuditingServiceProvider"
]
}
},
"scripts": {
"test": "phpunit",
"format": "composer require --dev laravel/pint --quiet && pint --config .pint.json && composer remove --dev laravel/pint --no-update",
"analyse": "composer require --dev larastan/larastan --quiet && phpstan analyse && composer remove --dev larastan/larastan --no-update"
},
"minimum-stability": "dev",
"prefer-stable": true
}
12 changes: 4 additions & 8 deletions database/migrations/audits.stub
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateAuditsTable extends Migration
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
$connection = config('audit.drivers.database.connection', config('database.default'));
$table = config('audit.drivers.database.table', 'audits');
Expand Down Expand Up @@ -39,14 +37,12 @@ class CreateAuditsTable extends Migration

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
public function down(): void
{
$connection = config('audit.drivers.database.connection', config('database.default'));
$table = config('audit.drivers.database.table', 'audits');

Schema::connection($connection)->drop($table);
}
}
};
15 changes: 6 additions & 9 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnError="false"
stopOnFailure="true"
verbose="true"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
>
<testsuites>
<testsuite name="Auditing Test Suite">
<directory suffix="Test.php">./tests</directory>
<directory>./tests</directory>
</testsuite>
</testsuites>
<groups>
Expand All @@ -27,9 +24,9 @@
<group>command-line-url-resolver</group>
</exclude>
</groups>
<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
</source>
</phpunit>
14 changes: 4 additions & 10 deletions src/Events/AuditCustom.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,12 @@

class AuditCustom
{
/**
* The Auditable model.
*
* @var \OwenIt\Auditing\Contracts\Auditable
*/
public $model;

/**
* Create a new Auditing event instance.
*/
public function __construct(Auditable $model)
{
$this->model = $model;
public function __construct(
public Auditable $model
) {
//
}
}
32 changes: 6 additions & 26 deletions src/Events/Audited.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,14 @@

class Audited
{
/**
* The Auditable model.
*
* @var \OwenIt\Auditing\Contracts\Auditable
*/
public $model;

/**
* Audit driver.
*
* @var \OwenIt\Auditing\Contracts\AuditDriver
*/
public $driver;

/**
* The Audit model.
*
* @var \OwenIt\Auditing\Contracts\Audit|null
*/
public $audit;

/**
* Create a new Audited event instance.
*/
public function __construct(Auditable $model, AuditDriver $driver, ?Audit $audit = null)
{
$this->model = $model;
$this->driver = $driver;
$this->audit = $audit;
public function __construct(
public Auditable $model,
public AuditDriver $driver,
public ?Audit $audit = null
) {
//
}
}
23 changes: 5 additions & 18 deletions src/Events/Auditing.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,13 @@

class Auditing
{
/**
* The Auditable model.
*
* @var \OwenIt\Auditing\Contracts\Auditable
*/
public $model;

/**
* Audit driver.
*
* @var \OwenIt\Auditing\Contracts\AuditDriver
*/
public $driver;

/**
* Create a new Auditing event instance.
*/
public function __construct(Auditable $model, AuditDriver $driver)
{
$this->model = $model;
$this->driver = $driver;
public function __construct(
public Auditable $model,
public AuditDriver $driver
) {
//
}
}
14 changes: 4 additions & 10 deletions src/Events/DispatchAudit.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,13 @@

class DispatchAudit
{
/**
* The Auditable model.
*
* @var Auditable
*/
public $model;

/**
* Create a new DispatchAudit event instance.
*/
public function __construct(Auditable $model)
{
$this->model = $model;
public function __construct(
public Auditable $model
) {
//
}

/**
Expand Down
Loading