first commit
Some checks failed
Build / run (push) Has been cancelled

This commit is contained in:
maher
2025-10-29 11:42:25 +01:00
commit 703f50a09d
4595 changed files with 385164 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
<?php
namespace Common\Files\Actions\Deletion;
use Arr;
use Common\Files\FileEntry;
use Gate;
class DeleteEntries
{
public function execute(array $params, $authorize = true): void
{
$entryIds =
$params['entryIds'] ?? $this->idsFromPaths($params['paths']);
if (count($entryIds)) {
if ($authorize) {
Gate::authorize('destroy', [FileEntry::class, $entryIds]);
}
if (Arr::get($params, 'soft')) {
app(SoftDeleteEntries::class)->execute($entryIds);
} else {
app(PermanentlyDeleteEntries::class)->execute($entryIds);
}
}
}
private function idsFromPaths(array $paths): array
{
$filenames = array_map(function ($path) {
return basename($path);
}, $paths);
return app(FileEntry::class)
->whereIn('file_name', $filenames)
->pluck('id')
->toArray();
}
}