This commit is contained in:
Mathieu Lagace
2019-09-08 16:43:34 -04:00
parent 0bd86285ca
commit 133f430445
39 changed files with 789 additions and 74 deletions

View File

@@ -11,17 +11,45 @@ class Log extends Model
return $this->belongsTo(User::class);
}
public static function saveLog($action, $user = "default")
public function logable()
{
$log = new Log;
return $this->morphTo();
}
if ($user == "default") {
$user = \Auth::User()->id;
public function typeColor()
{
switch ($this->type)
{
case 'add':
return 'success';
break;
case 'edit':
return 'primary';
break;
case 'delete':
return 'warning';
break;
case 'see':
return 'info';
break;
case 'navigate':
return 'secondary';
break;
case 'error':
return 'danger';
break;
}
$log->action = $action;
$log->user_id = $user;
}
$log->save();
public function logableURL()
{
if ($this->logable != null)
{
switch ($this->logable_type)
{
case "App\News":
return "/news/".$this->logable->id;
}
}
}
}