Skip to content

Commit

Permalink
2023-11-13_20-47-03
Browse files Browse the repository at this point in the history
  • Loading branch information
apsg committed Nov 13, 2023
1 parent 9814cbe commit 315664d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 7 deletions.
7 changes: 7 additions & 0 deletions app/Domains/Admin/Controllers/MaterialsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,11 @@ public function new(PresetEnum $preset, MaterialsRepository $repository): Redire

return Redirect::route('admin.materials.edit', $material);
}

public function destroy(Material $material)
{
$material->delete();

return back();
}
}
14 changes: 12 additions & 2 deletions app/Domains/Files/ZipService.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ public function ensureZipExists(Material $material): bool
return false;
}

public function path(Material $material): string
public function path(Material $material): ?string
{
if ($material->published_at === null) {
return null;
}

return '/zip/'
. $material->published_at->format('Y')
. DIRECTORY_SEPARATOR
Expand All @@ -38,7 +42,13 @@ public function path(Material $material): string

public function deleteZipForMaterial(Material $material): void
{
$this->filesystem->delete($this->path($material));
$path = $this->path($material);

if ($path === null) {
return;
}

$this->filesystem->delete($path);
}

protected function create(Material $material): void
Expand Down
20 changes: 15 additions & 5 deletions resources/js/Components/Admin/PageableTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,27 @@
<td class="px-6 py-4">
<StateBagde :state="material.state" />
</td>
<ContentAccess :permissions="[permissions.CREATE_MATERIALS]">
<td class="px-6 py-4">
<td class="px-6 py-4">
<ContentAccess :permissions="[permissions.MANAGE_MATERIALS]">
<Link
:href="route('admin.materials.edit', material.id)"
class="font-medium text-blue-600 hover:underline text-lg"
class="font-medium text-blue-600 hover:underline text-lg ml-3"
title="Edytuj"
>
<font-awesome-icon icon="fa-solid fa-pen-to-square" />
</Link>
</td>
</ContentAccess>
</ContentAccess>
<ContentAccess :permissions="[permissions.MANAGE_MATERIALS]">
<Link
:href="route('admin.materials.destroy', material.id)"
class="font-medium text-red-600 hover:underline text-lg ml-3"
title="Edytuj"
method="delete"
>
<font-awesome-icon icon="fa-solid fa-trash" />
</Link>
</ContentAccess>
</td>
</tr>
</template>
<template v-else>
Expand Down
1 change: 1 addition & 0 deletions routes/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
Route::get('/create', [MaterialsController::class, 'create'])->name('create');
Route::get('/create/{preset}', [MaterialsController::class, 'new'])->name('new');
Route::get('/{material}', [MaterialsController::class, 'edit'])->name('edit');
Route::delete('/{material}', [MaterialsController::class, 'destroy'])->name('destroy');
});

Route::prefix('/taxonomies')
Expand Down

0 comments on commit 315664d

Please sign in to comment.