for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of the Laravel Auditing package.
*
* @author Antério Vieira <[email protected]>
* @author Quetzy Garcia <[email protected]>
* @author Raphael França <[email protected]>
* @copyright 2015-2018
* For the full copyright and license information,
* please view the LICENSE.md file that was distributed
* with this source code.
*/
namespace OwenIt\Auditing\Drivers;
use Illuminate\Support\Facades\Config;
use OwenIt\Auditing\Contracts\Audit;
use OwenIt\Auditing\Contracts\Auditable;
use OwenIt\Auditing\Contracts\AuditDriver;
class Database implements AuditDriver
{
* {@inheritdoc}
public function audit(Auditable $model): Audit
$implementation = Config::get('audit.implementation', \OwenIt\Auditing\Models\Audit::class);
return call_user_func([$implementation, 'create'], $model->toAudit());
}
public function prune(Auditable $model): bool
if (($threshold = $model->getAuditThreshold()) > 0) {
$forRemoval = $model->audits()
->latest()
->get()
->slice($threshold)
->pluck('id');
if (!$forRemoval->isEmpty()) {
return $model->audits()
->whereIn('id', $forRemoval)
->delete() > 0;
return false;