Skip to content

Commit

Permalink
Merge pull request #787 from spatie/v4
Browse files Browse the repository at this point in the history
V4
  • Loading branch information
Gummibeer authored May 4, 2021
2 parents aa6b0fc + 27e63a2 commit f2f42c2
Show file tree
Hide file tree
Showing 59 changed files with 2,677 additions and 633 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
ref: ${{ github.head_ref }}

- name: Run PHP CS Fixer
uses: docker://oskarstark/php-cs-fixer-ga
uses: docker://oskarstark/php-cs-fixer-ga:2.19.0
with:
args: --config=.php_cs.dist --allow-risky=yes

Expand Down
18 changes: 5 additions & 13 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,15 @@ on:
jobs:
test:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ["8.0", "7.4", "7.3"]
laravel: [8.*, 7.*, 6.*]
php: ["8.0"]
laravel: ["^8.0"]
dependency-version: [prefer-lowest, prefer-stable]
os: [ubuntu-latest, windows-latest]
include:
- laravel: 8.*
testbench: 6.*
- laravel: 7.*
testbench: 5.*
- laravel: 6.*
testbench: 4.*

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}

steps:
- name: Checkout code
Expand All @@ -46,7 +38,7 @@ jobs:

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer require "laravel/framework:${{ matrix.laravel }}" --dev --no-interaction --no-update
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
- name: Execute tests
Expand Down
37 changes: 15 additions & 22 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -1,37 +1,30 @@
<?php

$finder = Symfony\Component\Finder\Finder::create()
$finder = \PhpCsFixer\Finder::create()
->notPath('bootstrap/*')
->notPath('storage/*')
->notPath('resources/view/mail/*')
->in([
__DIR__ . '/src',
__DIR__ . '/tests',
__DIR__.'/src',
__DIR__.'/tests',
])
->name('*.php')
->notName('*.blade.php')
->ignoreDotFiles(true)
->ignoreVCS(true);

return PhpCsFixer\Config::create()
->setRules([
return \PhpCsFixer\Config::create()
->setRules(array_merge(require '.php_cs.laravel', [
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sortAlgorithm' => 'alpha'],
'@PSR12' => true,
'no_unused_imports' => true,
'not_operator_with_successor_space' => true,
'trailing_comma_in_multiline_array' => true,
'phpdoc_scalar' => true,
'unary_operator_spaces' => true,
'binary_operator_spaces' => true,
'blank_line_before_statement' => [
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
],
'phpdoc_single_line_var_spacing' => true,
'phpdoc_var_without_name' => true,
'method_argument_space' => [
'on_multiline' => 'ensure_fully_multiline',
'keep_multiple_spaces_after_comma' => true,
]
])
'phpdoc_to_comment' => false,
'phpdoc_order' => true,
'phpdoc_separation' => true,
'simplified_null_return' => false,
]))
->setLineEnding("\n")
->setIndent(str_repeat(' ', 4))
->setUsingCache(false)
->setRiskyAllowed(true)
->setFinder($finder);
126 changes: 126 additions & 0 deletions .php_cs.laravel
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?php

/**
* @link https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200
*/

return [
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'default' => 'single_space',
'operators' => ['=>' => null]
],
'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => true,
'blank_line_before_statement' => [
'statements' => ['return']
],
'braces' => true,
'cast_spaces' => true,
'class_attributes_separation' => [
'elements' => ['method']
],
'class_definition' => true,
'concat_space' => [
'spacing' => 'none'
],
'declare_equal_normalize' => true,
'elseif' => true,
'encoding' => true,
'full_opening_tag' => true,
'fully_qualified_strict_types' => true, // added by Shift
'function_declaration' => true,
'function_typehint_space' => true,
'heredoc_to_nowdoc' => true,
'include' => true,
'increment_style' => ['style' => 'post'],
'indentation_type' => true,
'linebreak_after_opening_tag' => true,
'line_ending' => true,
'lowercase_cast' => true,
'lowercase_constants' => true,
'lowercase_keywords' => true,
'lowercase_static_reference' => true, // added from Symfony
'magic_method_casing' => true, // added from Symfony
'magic_constant_casing' => true,
'method_argument_space' => true,
'native_function_casing' => true,
'no_alias_functions' => true,
'no_extra_blank_lines' => [
'tokens' => [
'extra',
'throw',
'use',
'use_trait',
]
],
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_closing_tag' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_mixed_echo_print' => [
'use' => 'echo'
],
'no_multiline_whitespace_around_double_arrow' => true,
'multiline_whitespace_before_semicolons' => [
'strategy' => 'no_multi_line'
],
'no_short_bool_cast' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_after_function_name' => true,
'no_spaces_around_offset' => true,
'no_spaces_inside_parenthesis' => true,
'no_trailing_comma_in_list_call' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'no_unneeded_control_parentheses' => true,
'no_unreachable_default_argument_value' => true,
'no_useless_return' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'normalize_index_brace' => true,
'not_operator_with_successor_space' => true,
'object_operator_without_whitespace' => true,
'ordered_imports' => ['sortAlgorithm' => 'alpha'],
'phpdoc_indent' => true,
'phpdoc_inline_tag' => true,
'phpdoc_no_access' => true,
'phpdoc_no_package' => true,
'phpdoc_no_useless_inheritdoc' => true,
'phpdoc_scalar' => true,
'phpdoc_single_line_var_spacing' => true,
'phpdoc_summary' => true,
'phpdoc_to_comment' => true,
'phpdoc_trim' => true,
'phpdoc_types' => true,
'phpdoc_var_without_name' => true,
'psr4' => true,
'self_accessor' => true,
'short_scalar_cast' => true,
'simplified_null_return' => true,
'single_blank_line_at_eof' => true,
'single_blank_line_before_namespace' => true,
'single_class_element_per_statement' => true,
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_line_comment_style' => [
'comment_types' => ['hash']
],
'single_quote' => true,
'space_after_semicolon' => true,
'standardize_not_equals' => true,
'switch_case_semicolon_to_colon' => true,
'switch_case_space' => true,
'ternary_operator_spaces' => true,
'trailing_comma_in_multiline_array' => true,
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'visibility_required' => [
'elements' => ['method', 'property']
],
'whitespace_after_comma_in_array' => true,
];
18 changes: 15 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

All notable changes to `spatie/laravel-activitylog` will be documented in this file

## 4.0 - 2021-04-09

Reference - [#866](/~https://github.com/spatie/laravel-activitylog/pull/866) and [#787](/~https://github.com/spatie/laravel-activitylog/pull/787)

- Drop Laravel 6 and 7 support.
- Drop PHP 7.x support.
- Add `LogOptions` configuration object to replace all configuration properties.
- Add ability to batch activity logs [#560](/~https://github.com/spatie/laravel-activitylog/issues/560)
- Add Pipeline to customize logged changes data.
- Deep diff array/JSON sub-keys and respect for only-dirty, no-empty ... [#692](/~https://github.com/spatie/laravel-activitylog/issues/692) using new pipeline. See implementation in the tests.
- Implement a `CauserResolver` to define causer for current runtime [#582](/~https://github.com/spatie/laravel-activitylog/issues/582).

## 3.17.0 - 2021-03-02

- drop PHP 7.2 support - [#855](/~https://github.com/spatie/laravel-activitylog/pull/855)
Expand Down Expand Up @@ -166,8 +178,8 @@ Please use `v3.14.1` instead - this release is breaking because of the new colum

- add `$logUnguarded`

## 3.0.0 - 2018-10-16
- the preferred way to get changes on an `Activity` model is through the `changes` property instead of the `changes()` function
## 3.0.0 - 2018-10-16
- the preferred way to get changes on an `Activity` model is through the `changes` property instead of the `changes()` function
- the `activity` relation of the `CausesActivity` trait has been renamed to `actions`
- the `activity` relation of the `LogsActivity` trait has been renamed to `activities`
- the deprecated `loggedActivity` relation has been removed
Expand Down Expand Up @@ -289,7 +301,7 @@ Please use `v3.14.1` instead - this release is breaking because of the new colum
## 1.10.0 - 2016-10-10
- add support for `restored` event

## 1.9.2 - 2016-09-27
## 1.9.2 - 2016-09-27
- fixed a bug where the delete event would not be logged

## 1.9.1 - 2016-09-16
Expand Down
15 changes: 14 additions & 1 deletion UPGRADING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## From v3 to v4

### Model event Logging

- All models now need to define a `getActivitylogOptions()` method to configure and return the models options as a `LogOptions` instance.
- To control what attributes are logged, instead of defining a `$logAttributes` property this is defined in the `getActivitylogOptions()` method using the `logOnly()` method of `LogOptions`.
- The `getDescriptionForEvent()` method is no longer used to customize the description. Instead, use the `setDescriptionForEvent()` method for `LogOptions` class.
- When customizing the log's name instead of defining a `$logName` property, call the `useLogName()` method when configuring the `LogOptions`.
- Instead of the `$ignoreChangedAttributes` property the ` dontLogIfAttributesChangedOnly()` method should be used.
- If you only need to log the dirty attributes use `logOnlyDirty()` since the `$logOnlyDirty` property is no longer used.
- For instances where you do not want to store empty log events use `dontSubmitEmptyLogs()` instead of setting `$submitEmptyLogs` to `false`.
- When you use a `*` (wildcard) and want to ignore specific elements use the `dontLogIfAttributesChangedOnly()` method instead of the `$logAttributesToIgnore` property.

## From v2 to v3

- if you are using a custom `Activity` model, you should let it implement the new `Spatie\Activitylog\Contracts\Activity` interface
Expand All @@ -6,4 +19,4 @@
- the `activity` relation of the `CausesActivity` trait has been renamed to `actions`. Rename all uses from `$user->activity` to `$user->actions`
- the `activity` relation of the `LogsActivity` trait has been renamed to `activities`. Rename all uses from `$yourModel->activity` to `$yourModel->activities`.
- the deprecated `loggedActivity` relation has been removed. Use `activities` instead.
- the `HasActivity` trait has been removed. Use both `CausesActivity` and `LogsActivity` traits instead.
- the `HasActivity` trait has been removed. Use both `CausesActivity` and `LogsActivity` traits instead.
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@
}
],
"require": {
"php": "^7.3 || ^8.0",
"illuminate/config": "^6.0 || ^7.0 || ^8.0",
"illuminate/database": "^6.0 || ^7.0 || ^8.0",
"illuminate/support": "^6.0 || ^7.0 || ^8.0"
"php": "^8.0",
"illuminate/config": "^8.0",
"illuminate/database": "^8.0",
"illuminate/support": "^8.0",
"spatie/laravel-package-tools": "^1.6.3"
},
"require-dev": {
"ext-json": "*",
"orchestra/testbench": "^4.0 || ^5.0 || ^6.0",
"orchestra/testbench": "^6.0",
"phpunit/phpunit": "^9.3"
},
"config": {
Expand Down
22 changes: 22 additions & 0 deletions database/migrations/AddBatchUuidColumnToActivityLogTable.php.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddBatchUuidColumnToActivityLogTable extends Migration
{
public function up()
{
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
$table->uuid('batch_uuid')->nullable()->after('properties');
});
}

public function down()
{
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
$table->dropColumn('batch_uuid');
});
}
}
22 changes: 22 additions & 0 deletions database/migrations/AddEventColumnToActivityLogTable.php.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddEventColumnToActivityLogTable extends Migration
{
public function up()
{
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
$table->string('event')->nullable()->after('subject_type');
});
}

public function down()
{
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
$table->dropColumn('event');
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ use Illuminate\Database\Migrations\Migration;

class CreateActivityLogTable extends Migration
{
/**
* Run the migrations.
*/
public function up()
{
Schema::connection(config('activitylog.database_connection'))->create(config('activitylog.table_name'), function (Blueprint $table) {
Expand All @@ -23,9 +20,6 @@ class CreateActivityLogTable extends Migration
});
}

/**
* Reverse the migrations.
*/
public function down()
{
Schema::connection(config('activitylog.database_connection'))->dropIfExists(config('activitylog.table_name'));
Expand Down
2 changes: 1 addition & 1 deletion docs/_index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: v3
title: v4
slogan: Log the activities of your users
githubUrl: /~https://github.com/spatie/laravel-activitylog
branch: master
Expand Down
10 changes: 5 additions & 5 deletions docs/about-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ weight: 8

[Spatie](https://spatie.be) is a webdesign agency based in Antwerp, Belgium.

Open source software is used in all projects we deliver. Laravel, Nginx, Ubuntu are just a few
of the free pieces of software we use every single day. For this, we are very grateful.
When we feel we have solved a problem in a way that can help other developers,
Open source software is used in all projects we deliver. Laravel, Nginx, Ubuntu are just a few
of the free pieces of software we use every single day. For this, we are very grateful.
When we feel we have solved a problem in a way that can help other developers,
we release our code as open source software [on GitHub](https://spatie.be/opensource).

This activitylog package was made and is maintained by [Freek Van der Herten](https://twitter.com/freekmurze)
and [Sebastian De Deyne](https://twitter.com/sebdedeyne). There are
This activitylog package was made and is maintained by [Freek Van der Herten](https://twitter.com/freekmurze)
and [Sebastian De Deyne](https://twitter.com/sebdedeyne). There are
[many other contributors](/~https://github.com/spatie/laravel-activitylog/graphs/contributors) as well.
Loading

0 comments on commit f2f42c2

Please sign in to comment.