Skip to content
This repository has been archived by the owner on Jun 1, 2019. It is now read-only.

Commit

Permalink
add laravel 5.2 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Dec 25, 2015
1 parent 7046327 commit 821e703
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

All Notable changes to `activitylog` will be documented in this file

### 2.3.0
- Add compatibility with Laravel 5.2

### 2.2.1
- Use database_path

Expand Down
18 changes: 17 additions & 1 deletion src/Spatie/Activitylog/Models/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Eloquent;
use Config;
use Exception;

class Activity extends Eloquent
{
Expand All @@ -21,7 +22,22 @@ class Activity extends Eloquent
*/
public function user()
{
return $this->belongsTo(Config::get('auth.model'), 'user_id');
return $this->belongsTo($this->getAuthModelName(), 'user_id');
}

public function getAuthModelName()
{
//laravel 5.0 - 5.1
if (! is_null(config('auth.model'))) {
return config('auth.model');
}

//laravel 5.2
if (! is_null(config('auth.providers.users.model'))) {
return config('auth.providers.users.model');
}

throw new Exception('could not determine the model name for users');
}

protected $guarded = ['id'];
Expand Down

0 comments on commit 821e703

Please sign in to comment.