Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sdebacker committed Apr 21, 2015
1 parent 0feac50 commit dec2637
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions src/Traits/Historable.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?php
namespace TypiCMS\Modules\History\Traits;

use App;
use Cartalyst\Sentry\Users\UserNotFoundException;
use Exception;
use Illuminate\Database\Eloquent\Model;
use Log;
use Sentry;
use TypiCMS\Modules\History\Models\History;

trait Historable {

/**
* boot method
*
*
* @return void
*/
public static function boot()
Expand Down Expand Up @@ -47,15 +47,15 @@ public static function boot()

/**
* Write History row
*
*
* @param string $action
* @param string $title
* @param string $locale
* @return void
*/
public function writeHistory($action, $title = null, $locale = null)
{
$history = App::make('TypiCMS\Modules\History\Repositories\HistoryInterface');
$history = app('TypiCMS\Modules\History\Repositories\HistoryInterface');
$data['historable_id'] = $this->getKey();
$data['historable_type'] = get_class($this);
$data['user_id'] = $this->getAuthUserId();
Expand All @@ -69,7 +69,7 @@ public function writeHistory($action, $title = null, $locale = null)

/**
* Return icon class for each action
*
*
* @param string $action
* @return string|void
*/
Expand All @@ -79,23 +79,23 @@ private function historyIconClass($action = null)
case 'deleted':
return 'fa-trash';
break;

case 'updated':
return 'fa-edit';
break;

case 'created':
return 'fa-plus-circle';
break;

case 'set online':
return 'fa-toggle-on';
break;

case 'set offline':
return 'fa-toggle-off';
break;

default:
return null;
break;
Expand All @@ -104,7 +104,7 @@ private function historyIconClass($action = null)

/**
* Get current user id
*
*
* @return int|null
*/
private function getAuthUserId()
Expand All @@ -114,10 +114,8 @@ private function getAuthUserId()
// Get the current active/logged in user
$user = Sentry::getUser();
$userId = $user->id;
} catch (UserNotFoundException $e) {
// User wasn't found, should only happen if the user was deleted
// when they were already logged in or had a "remember me" cookie set
// and they were deleted.
} catch (Exception $e) {
Log::info($e->getMessage());
}
return $userId;
}
Expand Down

0 comments on commit dec2637

Please sign in to comment.