mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-21 02:39:10 -04:00
3.2.1
This commit is contained in:
44
app/Log.php
44
app/Log.php
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user