Updated the helpdesk module
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Documentation\Http\Controllers;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Modules\Documentation\Http\Requests\StoreDocumentationCategoryRequest;
|
||||
use Modules\Documentation\Http\Requests\UpdateDocumentationCategoryRequest;
|
||||
use Modules\Documentation\Models\DocumentationCategory;
|
||||
|
||||
class DocumentationCategoryController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display category list.
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
return view('documentation::categories.index', [
|
||||
'categories' => DocumentationCategory::query()->withCount('documents')->ordered()->paginate(15),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show create form.
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
return view('documentation::categories.create', [
|
||||
'category' => new DocumentationCategory(['colour' => 'emerald', 'is_active' => true]),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a category.
|
||||
*/
|
||||
public function store(StoreDocumentationCategoryRequest $request): RedirectResponse
|
||||
{
|
||||
$data = $request->validated();
|
||||
$data['is_active'] = $request->boolean('is_active', true);
|
||||
$data['created_by'] = $request->user()?->id;
|
||||
$data['updated_by'] = $request->user()?->id;
|
||||
|
||||
DocumentationCategory::query()->create($data);
|
||||
|
||||
return redirect()->route('documentation.categories.index')->with('status', 'Category created successfully.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show edit form.
|
||||
*/
|
||||
public function edit(DocumentationCategory $category): View
|
||||
{
|
||||
return view('documentation::categories.edit', [
|
||||
'category' => $category,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a category.
|
||||
*/
|
||||
public function update(UpdateDocumentationCategoryRequest $request, DocumentationCategory $category): RedirectResponse
|
||||
{
|
||||
$data = $request->validated();
|
||||
$data['is_active'] = $request->boolean('is_active');
|
||||
$data['updated_by'] = $request->user()?->id;
|
||||
|
||||
$category->update($data);
|
||||
|
||||
return redirect()->route('documentation.categories.index')->with('status', 'Category updated successfully.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a category.
|
||||
*/
|
||||
public function destroy(DocumentationCategory $category): RedirectResponse
|
||||
{
|
||||
$category->delete();
|
||||
|
||||
return redirect()->route('documentation.categories.index')->with('status', 'Category deleted successfully.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user