public function log($type, $text, $entity_id = null, $icon = null, $class = null, $assets = null)
{
//Type can be id or name
if (is_numeric($type)) {
$type = HistoryType::findOrFail($type);
} else {
$type = HistoryType::where('name', $type)->first();
}
if ($type instanceof HistoryType) {
return History::create(['type_id' => $type->id, 'text' => $text, 'user_id' => access()->id(), 'entity_id' => $entity_id, 'icon' => $icon, 'class' => $class, 'assets' => is_array($assets) && count($assets) ? json_encode($assets) : null]);
}
return false;
}