Files
GSB-Construction/Modules/ProjectDocuments/app/Http/Controllers/ProjectDocumentsController.php
Christopher Boyles 64d4b331a8
Some checks failed
Tests / PHP 8.3 (push) Has been cancelled
Tests / PHP 8.4 (push) Has been cancelled
Tests / PHP 8.5 (push) Has been cancelled
Additional Changes
2026-06-02 22:04:03 +08:00

95 lines
2.5 KiB
PHP

<?php
namespace Modules\ProjectDocuments\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ProjectDocumentsController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index(Request $request)
{
$projectUlid = $request->query('project');
$project = $projectUlid ? \Modules\ProjectManagement\Models\Project::where('ulid', $projectUlid)->firstOrFail() : null;
$query = \Modules\DocumentManagement\Models\Document::with(['uploader:id,name', 'category', 'project', 'approvals.approver']);
if ($project) {
$query->where('project_id', $project->id);
}
if ($search = $request->search) {
$query->where('title', 'like', "%{$search}%");
}
if ($categoryId = $request->category_id) {
$query->where('category_id', $categoryId);
}
if ($status = $request->status) {
$query->where('status', $status);
}
$documents = $query->latest()->paginate(20)->withQueryString();
$categories = \Modules\DocumentManagement\Models\DocumentCategory::all();
$projects = \Modules\ProjectManagement\Models\Project::with('parentProject:id,ulid,name,code')->get(['id', 'ulid', 'name', 'code', 'project_type', 'parent_project_id']);
return \Inertia\Inertia::render('ProjectManagement::Projects/Modules/Documents', [
'project' => $project,
'documents' => $documents,
'categories' => $categories,
'projects' => $projects,
'filters' => $request->only(['search', 'category_id', 'status']),
'currentTab' => 'documents',
]);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
return view('projectdocuments::create');
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
//
}
/**
* Show the specified resource.
*/
public function show($id)
{
return view('projectdocuments::show');
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
return view('projectdocuments::edit');
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy($id)
{
//
}
}