Skip to content

Commit

Permalink
Replace greensight with ensi
Browse files Browse the repository at this point in the history
  • Loading branch information
arrilot committed Oct 5, 2021
1 parent 1a04af7 commit 622494c
Show file tree
Hide file tree
Showing 58 changed files with 224 additions and 224 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
The MIT License (MIT)
Copyright (C) 2015-2018 Antério Vieira, Quetzy Garcia, Raphael França, 2021 Greensight [email protected]
Copyright (C) 2015-2018 Antério Vieira, Quetzy Garcia, Raphael França, 2021 Ensi [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ Opiniated fork of [owen-it/laravel-auditing](https://github.com/owen-it/laravel-

## Установка

1. `composer require greensight/laravel-auditing`
2. `php artisan vendor:publish --provider="Greensight\LaravelAuditing\LaravelAuditingServiceProvider"`
3. Добавьте в `config/app` класс провайдера `Greensight\LaravelAuditing\LaravelAuditingServiceProvider::class`
1. `composer require ensi/laravel-auditing`
2. `php artisan vendor:publish --provider="Ensi\LaravelAuditing\LaravelAuditingServiceProvider"`
3. Добавьте в `config/app` класс провайдера `Ensi\LaravelAuditing\LaravelAuditingServiceProvider::class`

## Использование

По-умолчанию никакая история изменения для моделей не сохраняется.
Чтобы включить логирование для конкретной модели надо добавить ей трейт `SupportsAudit` и интерфейс `Auditable`

```php
use Greensight\LaravelAuditing\Contracts\Auditable;
use Greensight\LaravelAuditing\SupportsAudit;
use Ensi\LaravelAuditing\Contracts\Auditable;
use Ensi\LaravelAuditing\SupportsAudit;

class Something extends Model implements Auditable {
use SupportsAudit;
Expand All @@ -24,7 +24,7 @@ class Something extends Model implements Auditable {
```

В случае, если мы меняем данные дочерних с логической точки зрения моделей и хотим чтобы в истории это изменение проходило под родительской моделью, необходимо в транзакции до изменения данных задать корневую сущность (т.е модель).
Делается это через фасад `Transaction` или менеджер `\\Greensight\\LaravelAuditing\\Transactions\\ExtendedTransactionManager`
Делается это через фасад `Transaction` или менеджер `\\Ensi\\LaravelAuditing\\Transactions\\ExtendedTransactionManager`

```php
DB::transaction(function () {
Expand All @@ -34,10 +34,10 @@ DB::transaction(function () {
});
```

Для добавления в историю данных о том кто произвел изменения (конкретный пользователь, или, например, консольная команда) опять же нужно это сделать до изменения данных, но уже через фасад `Subject` или инъекцию `\\Greensight\\LaravelAuditing\\Resolvers\\SubjectManager`
Для добавления в историю данных о том кто произвел изменения (конкретный пользователь, или, например, консольная команда) опять же нужно это сделать до изменения данных, но уже через фасад `Subject` или инъекцию `\\Ensi\\LaravelAuditing\\Resolvers\\SubjectManager`

```php
Subject::attach($subject); // $subject - объект реализующий Greensight\LaravelAuditing\Contracts
Subject::attach($subject); // $subject - объект реализующий Ensi\LaravelAuditing\Contracts
```

Субъект не отвязывается после завершения транзакции.
Expand All @@ -46,7 +46,7 @@ Subject::attach($subject); // $subject - объект реализующий Gre
При обработке http запросов, можно задавать субъекта в middleware. В консольных командах и
обработчиках очереди событий переназначать в процессе выполнения.

Субъектом может являться любая сущность, поддерживающая интерфейс `\Greensight\LaravelAuditing\Contracts\Principal`.
Субъектом может являться любая сущность, поддерживающая интерфейс `\Ensi\LaravelAuditing\Contracts\Principal`.
Если субъектом является выполняемое задание, например, импорт из файла, то оно может возвращать идентификатор
пользователя, создавшего задание в методе `getUserIdentifier()`, а в качестве наименования возвращать имя
импортируемого файла.
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "greensight/laravel-auditing",
"name": "ensi/laravel-auditing",
"description": "",
"type": "library",
"license": "MIT",
Expand All @@ -19,19 +19,19 @@
},
"autoload": {
"psr-4": {
"Greensight\\LaravelAuditing\\": "src/"
"Ensi\\LaravelAuditing\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Greensight\\LaravelAuditing\\Tests\\": "tests/",
"Greensight\\LaravelAuditing\\Database\\Factories\\": "tests/database/factories/"
"Ensi\\LaravelAuditing\\Tests\\": "tests/",
"Ensi\\LaravelAuditing\\Database\\Factories\\": "tests/database/factories/"
}
},
"extra": {
"laravel": {
"providers": [
"Greensight\\LaravelAuditing\\LaravelAuditingServiceProvider"
"Ensi\\LaravelAuditing\\LaravelAuditingServiceProvider"
]
}
},
Expand Down
10 changes: 5 additions & 5 deletions config/laravel-auditing.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
|
*/

'implementation' => Greensight\LaravelAuditing\Models\Audit::class,
'implementation' => Ensi\LaravelAuditing\Models\Audit::class,

/*
|--------------------------------------------------------------------------
Expand All @@ -37,10 +37,10 @@
|
*/
'resolver' => [
'user' => Greensight\LaravelAuditing\Facades\Subject::class,
'ip_address' => Greensight\LaravelAuditing\Resolvers\IpAddressResolver::class,
'user_agent' => Greensight\LaravelAuditing\Resolvers\UserAgentResolver::class,
'url' => Greensight\LaravelAuditing\Resolvers\UrlResolver::class,
'user' => Ensi\LaravelAuditing\Facades\Subject::class,
'ip_address' => Ensi\LaravelAuditing\Resolvers\IpAddressResolver::class,
'user_agent' => Ensi\LaravelAuditing\Resolvers\UserAgentResolver::class,
'url' => Ensi\LaravelAuditing\Resolvers\UrlResolver::class,
],

/*
Expand Down
6 changes: 3 additions & 3 deletions src/Audit.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

namespace Greensight\LaravelAuditing;
namespace Ensi\LaravelAuditing;

use DateTimeInterface;
use Greensight\LaravelAuditing\Contracts\Principal;
use Ensi\LaravelAuditing\Contracts\Principal;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Config;
use Illuminate\Database\Eloquent\Model;
use Greensight\LaravelAuditing\Contracts\AttributeEncoder;
use Ensi\LaravelAuditing\Contracts\AttributeEncoder;

trait Audit
{
Expand Down
18 changes: 9 additions & 9 deletions src/AuditableObserver.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace Greensight\LaravelAuditing;
namespace Ensi\LaravelAuditing;

use Greensight\LaravelAuditing\Contracts\Auditable;
use Greensight\LaravelAuditing\Facades\Auditor;
use Ensi\LaravelAuditing\Contracts\Auditable;
use Ensi\LaravelAuditing\Facades\Auditor;

class AuditableObserver
{
Expand All @@ -17,7 +17,7 @@ class AuditableObserver
/**
* Handle the retrieved event.
*
* @param \Greensight\LaravelAuditing\Contracts\Auditable $model
* @param \Ensi\LaravelAuditing\Contracts\Auditable $model
*
* @return void
*/
Expand All @@ -29,7 +29,7 @@ public function retrieved(Auditable $model)
/**
* Handle the created event.
*
* @param \Greensight\LaravelAuditing\Contracts\Auditable $model
* @param \Ensi\LaravelAuditing\Contracts\Auditable $model
*
* @return void
*/
Expand All @@ -41,7 +41,7 @@ public function created(Auditable $model)
/**
* Handle the updated event.
*
* @param \Greensight\LaravelAuditing\Contracts\Auditable $model
* @param \Ensi\LaravelAuditing\Contracts\Auditable $model
*
* @return void
*/
Expand All @@ -56,7 +56,7 @@ public function updated(Auditable $model)
/**
* Handle the deleted event.
*
* @param \Greensight\LaravelAuditing\Contracts\Auditable $model
* @param \Ensi\LaravelAuditing\Contracts\Auditable $model
*
* @return void
*/
Expand All @@ -68,7 +68,7 @@ public function deleted(Auditable $model)
/**
* Handle the restoring event.
*
* @param \Greensight\LaravelAuditing\Contracts\Auditable $model
* @param \Ensi\LaravelAuditing\Contracts\Auditable $model
*
* @return void
*/
Expand All @@ -83,7 +83,7 @@ public function restoring(Auditable $model)
/**
* Handle the restored event.
*
* @param \Greensight\LaravelAuditing\Contracts\Auditable $model
* @param \Ensi\LaravelAuditing\Contracts\Auditable $model
*
* @return void
*/
Expand Down
20 changes: 10 additions & 10 deletions src/Auditor.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php

namespace Greensight\LaravelAuditing;
namespace Ensi\LaravelAuditing;

use Greensight\LaravelAuditing\Contracts\Auditable;
use Greensight\LaravelAuditing\Contracts\AuditDriver;
use Greensight\LaravelAuditing\Drivers\Database;
use Greensight\LaravelAuditing\Events\Audited;
use Greensight\LaravelAuditing\Events\Auditing;
use Greensight\LaravelAuditing\Exceptions\AuditingException;
use Ensi\LaravelAuditing\Contracts\Auditable;
use Ensi\LaravelAuditing\Contracts\AuditDriver;
use Ensi\LaravelAuditing\Drivers\Database;
use Ensi\LaravelAuditing\Events\Audited;
use Ensi\LaravelAuditing\Events\Auditing;
use Ensi\LaravelAuditing\Exceptions\AuditingException;
use Illuminate\Support\Manager;
use InvalidArgumentException;

Expand Down Expand Up @@ -78,7 +78,7 @@ public function execute(Auditable $model)
/**
* Create an instance of the Database audit driver.
*
* @return \Greensight\LaravelAuditing\Drivers\Database
* @return \Ensi\LaravelAuditing\Drivers\Database
*/
protected function createDatabaseDriver(): Database
{
Expand All @@ -88,8 +88,8 @@ protected function createDatabaseDriver(): Database
/**
* Fire the Auditing event.
*
* @param \Greensight\LaravelAuditing\Contracts\Auditable $model
* @param \Greensight\LaravelAuditing\Contracts\AuditDriver $driver
* @param \Ensi\LaravelAuditing\Contracts\Auditable $model
* @param \Ensi\LaravelAuditing\Contracts\AuditDriver $driver
*
* @return bool
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Console/AuditDriverCommand.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Greensight\LaravelAuditing\Console;
namespace Ensi\LaravelAuditing\Console;

use Illuminate\Console\GeneratorCommand;

Expand Down
6 changes: 3 additions & 3 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Greensight\LaravelAuditing\Console;
namespace Ensi\LaravelAuditing\Console;

use Illuminate\Console\Command;
use Illuminate\Container\Container;
Expand Down Expand Up @@ -45,13 +45,13 @@ protected function registerAuditingServiceProvider()

$appConfig = file_get_contents(config_path('app.php'));

if (Str::contains($appConfig, 'Greensight\\LaravelAuditing\\LaravelAuditingServiceProvider::class')) {
if (Str::contains($appConfig, 'Ensi\\LaravelAuditing\\LaravelAuditingServiceProvider::class')) {
return;
}

file_put_contents(config_path('app.php'), str_replace(
"{$namespace}\\Providers\EventServiceProvider::class,".PHP_EOL,
"{$namespace}\\Providers\EventServiceProvider::class,".PHP_EOL." Greensight\LaravelAuditing\LaravelAuditingServiceProvider::class,".PHP_EOL,
"{$namespace}\\Providers\EventServiceProvider::class,".PHP_EOL." Ensi\LaravelAuditing\LaravelAuditingServiceProvider::class,".PHP_EOL,
$appConfig
));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Contracts/AttributeEncoder.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Greensight\LaravelAuditing\Contracts;
namespace Ensi\LaravelAuditing\Contracts;

interface AttributeEncoder extends AttributeModifier
{
Expand Down
2 changes: 1 addition & 1 deletion src/Contracts/AttributeModifier.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Greensight\LaravelAuditing\Contracts;
namespace Ensi\LaravelAuditing\Contracts;

interface AttributeModifier
{
Expand Down
2 changes: 1 addition & 1 deletion src/Contracts/AttributeRedactor.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Greensight\LaravelAuditing\Contracts;
namespace Ensi\LaravelAuditing\Contracts;

interface AttributeRedactor extends AttributeModifier
{
Expand Down
2 changes: 1 addition & 1 deletion src/Contracts/Audit.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Greensight\LaravelAuditing\Contracts;
namespace Ensi\LaravelAuditing\Contracts;

interface Audit
{
Expand Down
8 changes: 4 additions & 4 deletions src/Contracts/AuditDriver.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<?php

namespace Greensight\LaravelAuditing\Contracts;
namespace Ensi\LaravelAuditing\Contracts;

interface AuditDriver
{
/**
* Perform an audit.
*
* @param \Greensight\LaravelAuditing\Contracts\Auditable $model
* @param \Ensi\LaravelAuditing\Contracts\Auditable $model
*
* @return \Greensight\LaravelAuditing\Contracts\Audit
* @return \Ensi\LaravelAuditing\Contracts\Audit
*/
public function audit(Auditable $model): Audit;

/**
* Remove older audits that go over the threshold.
*
* @param \Greensight\LaravelAuditing\Contracts\Auditable $model
* @param \Ensi\LaravelAuditing\Contracts\Auditable $model
*
* @return bool
*/
Expand Down
6 changes: 3 additions & 3 deletions src/Contracts/Auditable.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Greensight\LaravelAuditing\Contracts;
namespace Ensi\LaravelAuditing\Contracts;

use Illuminate\Database\Eloquent\Relations\MorphMany;

Expand Down Expand Up @@ -46,7 +46,7 @@ public function readyForAuditing(): bool;
/**
* Return data for an Audit.
*
* @throws \Greensight\LaravelAuditing\Exceptions\AuditingException
* @throws \Ensi\LaravelAuditing\Exceptions\AuditingException
*
* @return array
*/
Expand Down Expand Up @@ -123,7 +123,7 @@ public function generateTags(): array;
* @param Audit $audit
* @param bool $old
*
* @throws \Greensight\LaravelAuditing\Exceptions\AuditableTransitionException
* @throws \Ensi\LaravelAuditing\Exceptions\AuditableTransitionException
*
* @return Auditable
*/
Expand Down
6 changes: 3 additions & 3 deletions src/Contracts/Auditor.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php

namespace Greensight\LaravelAuditing\Contracts;
namespace Ensi\LaravelAuditing\Contracts;

interface Auditor
{
/**
* Get an audit driver instance.
*
* @param \Greensight\LaravelAuditing\Contracts\Auditable $model
* @param \Ensi\LaravelAuditing\Contracts\Auditable $model
*
* @return AuditDriver
*/
Expand All @@ -16,7 +16,7 @@ public function auditDriver(Auditable $model): AuditDriver;
/**
* Perform an audit.
*
* @param \Greensight\LaravelAuditing\Contracts\Auditable $model
* @param \Ensi\LaravelAuditing\Contracts\Auditable $model
*
* @return void
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Contracts/IpAddressResolver.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Greensight\LaravelAuditing\Contracts;
namespace Ensi\LaravelAuditing\Contracts;

interface IpAddressResolver
{
Expand Down
Loading

0 comments on commit 622494c

Please sign in to comment.