Started widening of activity logging

In progress, Need to implement much of the logging in controllers.
Also cleaned up base controller along the way.
This commit is contained in:
Dan Brown
2020-11-18 23:38:44 +00:00
parent 712ccd23c4
commit 3f7180fa99
11 changed files with 115 additions and 60 deletions

View File

@ -5,6 +5,7 @@ use BookStack\Auth\User;
use BookStack\Entities\Chapter;
use BookStack\Entities\Entity;
use BookStack\Entities\Page;
use BookStack\Interfaces\Loggable;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Support\Facades\Log;
@ -30,6 +31,22 @@ class ActivityService
$this->setNotification($type);
}
/**
* Add a generic activity event to the database.
* @param string|Loggable $detail
*/
public function add(string $type, $detail = '')
{
if ($detail instanceof Loggable) {
$detail = $detail->logDescriptor();
}
$activity = $this->newActivityForUser($type);
$activity->detail = $detail;
$activity->save();
$this->setNotification($type);
}
/**
* Get a new activity instance for the current user.
*/