Skip to content

Commit

Permalink
Activity Class refrence fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
CrashSensei committed Sep 2, 2016
1 parent 357ed39 commit a311598
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ to
composer require linearsoft/laravel-activitylog
```

For your convenience the Activity facade infrastructure has been restored in this backport.
All you need to do is register the facade:

```php
// config/app.php
'aliases' => [
...
'Activity' => Spatie\Activitylog\ActivitylogFacade::class,
];
```

### Testing

All testing has been stripped from the backport version.
Expand Down Expand Up @@ -126,16 +137,6 @@ Next, you must install the service provider:
];
```

And you must register the facade:

```php
// config/app.php
'aliases' => [
...
'Activity' => Spatie\Activitylog\ActivitylogFacade::class,
];
```

You can publish the migration with:
```bash
php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="migrations"
Expand Down
4 changes: 2 additions & 2 deletions src/ActivitylogServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function register()
*
* @return \Illuminate\Database\Eloquent\Model
*/
static public function determineActivityModel()
static public function getActivityModelClass()
{
$activityModel = config('laravel-activitylog.activity_model') != null ?
config('laravel-activitylog.activity_model') :
Expand All @@ -66,7 +66,7 @@ static public function determineActivityModel()

static public function getActivityModelInstance()
{
$activityModelClassName = self::determineActivityModel();
$activityModelClassName = self::getActivityModelClass();

return new $activityModelClassName();
}
Expand Down
2 changes: 1 addition & 1 deletion src/CleanActivitylogCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function handle()

$cutOffDate = Carbon::now()->subDays($maxAgeInDays)->format('Y-m-d H:i:s');

$amountDeleted = Activity::where('created_at', '<', $cutOffDate)->delete();
$amountDeleted = (ActivitylogServiceProvider::getActivityModelClass())::where('created_at', '<', $cutOffDate)->delete();

$this->info("Deleted {$amountDeleted} record(s) from the activity log.");

Expand Down
3 changes: 2 additions & 1 deletion src/Traits/CausesActivity.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Spatie\Activitylog\Traits;

use Illuminate\Database\Eloquent\Relations\MorphMany;
use Spatie\Activitylog\ActivitylogServiceProvider;
use Spatie\Activitylog\Models\Activity;

trait CausesActivity
Expand All @@ -12,7 +13,7 @@ trait CausesActivity
*/
public function activity()
{
return $this->morphMany(Activity::class, 'causer');
return $this->morphMany(ActivitylogServiceProvider::getActivityModelClass(), 'causer');
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Traits/LogsActivity.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Support\Collection;
use Spatie\Activitylog\ActivityLogger;
use Spatie\Activitylog\ActivitylogServiceProvider;
use Spatie\Activitylog\Models\Activity;

trait LogsActivity
Expand Down Expand Up @@ -42,7 +43,7 @@ protected static function bootLogsActivity()
*/
public function activity()
{
return $this->morphMany(Activity::class, 'subject');
return $this->morphMany(ActivitylogServiceProvider::getActivityModelClass(), 'subject');
}

/**
Expand Down

0 comments on commit a311598

Please sign in to comment.