Permalink
Browse files

Modify using helper methods to facades (#483)

  • Loading branch information...
Te7a-Houdini authored and freekmurze committed Feb 1, 2019
1 parent 2ed89a8 commit 6188a98d698532c7052b162aef326af3e3a329dd
@@ -2,6 +2,7 @@
namespace Spatie\Activitylog;
use Illuminate\Support\Arr;
use Illuminate\Auth\AuthManager;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Traits\Macroable;
@@ -175,7 +176,7 @@ protected function replacePlaceholders(string $description, ActivityContract $ac
$attributeValue = $attributeValue->toArray();
return array_get($attributeValue, $propertyName, $match);
return Arr::get($attributeValue, $propertyName, $match);
}, $description);
}
@@ -2,6 +2,7 @@
namespace Spatie\Activitylog\Models;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
@@ -41,7 +42,7 @@ public function causer(): MorphTo
public function getExtraProperty(string $propertyName)
{
return array_get($this->properties->toArray(), $propertyName);
return Arr::get($this->properties->toArray(), $propertyName);
}
public function changes(): Collection
@@ -2,6 +2,7 @@
namespace Spatie\Activitylog\Traits;
use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Model;
use Spatie\Activitylog\Exceptions\CouldNotLogChanges;
@@ -114,7 +115,7 @@ public static function logChanges(Model $model): array
{
$changes = [];
foreach ($model->attributesToBeLogged() as $attribute) {
if (str_contains($attribute, '.')) {
if (Str::contains($attribute, '.')) {
$changes += self::getRelatedModelAttributeValue($model, $attribute);
} else {
$changes += collect($model)->only($attribute)->toArray();
@@ -2,6 +2,7 @@
namespace Spatie\Activitylog\Traits;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Spatie\Activitylog\ActivityLogger;
use Illuminate\Database\Eloquent\Model;
@@ -119,13 +120,13 @@ protected function shouldLogEvent(string $eventName): bool
return true;
}
if (array_has($this->getDirty(), 'deleted_at')) {
if (Arr::has($this->getDirty(), 'deleted_at')) {
if ($this->getDirty()['deleted_at'] === null) {
return false;
}
}
//do not log update event if only ignored attributes are changed
return (bool) count(array_except($this->getDirty(), $this->attributesToBeIgnored()));
return (bool) count(Arr::except($this->getDirty(), $this->attributesToBeIgnored()));
}
}
@@ -2,6 +2,7 @@
namespace Spatie\Activitylog\Test\Models;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
@@ -41,7 +42,7 @@ public function causer(): MorphTo
public function getExtraProperty(string $propertyName)
{
return array_get($this->properties->toArray(), $propertyName);
return Arr::get($this->properties->toArray(), $propertyName);
}
public function changes(): Collection
@@ -2,6 +2,7 @@
namespace Spatie\Activitylog\Test\Models;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
@@ -48,7 +49,7 @@ public function causer(): MorphTo
*/
public function getExtraProperty(string $propertyName)
{
return array_get($this->properties->toArray(), $propertyName);
return Arr::get($this->properties->toArray(), $propertyName);
}
public function changes(): Collection
@@ -3,6 +3,7 @@
namespace Spatie\Activitylog\Test;
use CreateActivityLogTable;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Schema;
use Spatie\Activitylog\Models\Activity;
use Spatie\Activitylog\Test\Models\User;
@@ -23,7 +24,7 @@ public function setUp()
protected function checkRequirements()
{
collect($this->getAnnotations())->filter(function ($location) {
return in_array('!Travis', array_get($location, 'requires', []));
return in_array('!Travis', Arr::get($location, 'requires', []));
})->each(function ($location) {
getenv('TRAVIS') && $this->markTestSkipped('Travis will not run this test.');
});

0 comments on commit 6188a98

Please sign in to comment.