first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-06-08 17:09:23 -04:00
commit df3a033196
17887 changed files with 8637778 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
<?php
/**
* @file classes/core/SoftDeleteTrait.php
*
* Copyright (c) 2022 Simon Fraser University
* Copyright (c) 2022 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class SoftDeleteTrait
*
* @ingroup core
*
* @brief Implements the methods for soft deletion that can be used in entity daos that support it
*/
namespace PKP\core;
use Illuminate\Support\Facades\DB;
trait SoftDeleteTrait
{
/**
* Soft delete an object from the database
*/
protected function _softDelete(DataObject $object): void
{
$this->softDeleteById($object->getId());
}
/**
* Soft delete an object from the database by its id
*/
public function softDeleteById(int $id): void
{
DB::table($this->table)
->where($this->primaryKeyColumn, '=', $id)
->update(['deleted_at' => Core::getCurrentDate()]);
}
}