MAke EventLog details jsonable

This commit is contained in:
Sam Georges 2014-07-31 19:35:51 +10:00
parent b10b41f3bf
commit e62f72e235
2 changed files with 20 additions and 2 deletions

View File

@ -12,8 +12,8 @@ class DbSystemRequestLogs extends Migration
{
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('url')->nullable();
$table->integer('status_code')->nullable();
$table->string('url')->nullable();
$table->text('referer')->nullable();
$table->integer('count')->default(0);
$table->timestamps();

View File

@ -13,6 +13,11 @@ class EventLog extends Model
*/
protected $table = 'system_event_logs';
/**
* @var array List of attribute names which are json encoded and decoded from the database.
*/
protected $jsonable = ['details'];
/**
* Creates a log record
* @param string $message Specifies the message text
@ -25,10 +30,23 @@ class EventLog extends Model
$record = new static;
$record->message = $message;
$record->level = $level;
$record->details = $details;
if ($details !== null)
$record->details = (array) $details;
$record->save();
return $record;
}
/**
* Beautify level value.
* @param string $level
* @return string
*/
public function getLevelAttribute($level)
{
return ucfirst($level);
}
}