feat: implement comprehensive dashboard controller and modular administrative and project management interfaces
This commit is contained in:
@@ -67,7 +67,7 @@ class DocumentController extends Controller
|
||||
'description' => $validated['description'] ?? null,
|
||||
'documentable_type' => $validated['documentable_type'] ?? null,
|
||||
'documentable_id' => $validated['documentable_id'] ?? null,
|
||||
'status' => 'Pending',
|
||||
'status' => 'Approved',
|
||||
'uploaded_by' => $request->user()->id,
|
||||
'current_file_path' => $path,
|
||||
'current_file_name' => $file->getClientOriginalName(),
|
||||
@@ -86,26 +86,8 @@ class DocumentController extends Controller
|
||||
'uploaded_by' => $request->user()->id,
|
||||
'change_notes' => 'Initial upload',
|
||||
]);
|
||||
|
||||
// Trigger Global Approval Workflow
|
||||
$approverIds = [];
|
||||
if (\Spatie\Permission\Models\Role::where('name', 'Main Contractor Admin')->exists()) {
|
||||
$approverIds = \App\Models\User::role('Main Contractor Admin')->pluck('id')->toArray();
|
||||
}
|
||||
if (empty($approverIds) && \Spatie\Permission\Models\Role::where('name', 'Super Admin')->exists()) {
|
||||
$approverIds = \App\Models\User::role('Super Admin')->pluck('id')->toArray();
|
||||
}
|
||||
if (!empty($approverIds)) {
|
||||
app(\Modules\ApprovalWorkflow\Services\ApprovalService::class)->createChain(
|
||||
$document,
|
||||
$approverIds,
|
||||
'document',
|
||||
$request->user()->id,
|
||||
"New document uploaded: {$document->title}"
|
||||
);
|
||||
}
|
||||
|
||||
return back()->with('success', 'Document uploaded successfully and is pending approval.');
|
||||
return back()->with('success', 'Document uploaded successfully.');
|
||||
}
|
||||
|
||||
public function uploadVersion(Request $request, Document $document)
|
||||
@@ -128,28 +110,10 @@ class DocumentController extends Controller
|
||||
$validated['change_notes'] ?? null,
|
||||
);
|
||||
|
||||
// Reset status to Pending when a new version is uploaded
|
||||
$document->update(['status' => 'Pending']);
|
||||
// Keep status as Approved when a new version is uploaded
|
||||
$document->update(['status' => 'Approved']);
|
||||
|
||||
// Trigger Global Approval Workflow for the new version
|
||||
$approverIds = [];
|
||||
if (\Spatie\Permission\Models\Role::where('name', 'Main Contractor Admin')->exists()) {
|
||||
$approverIds = \App\Models\User::role('Main Contractor Admin')->pluck('id')->toArray();
|
||||
}
|
||||
if (empty($approverIds) && \Spatie\Permission\Models\Role::where('name', 'Super Admin')->exists()) {
|
||||
$approverIds = \App\Models\User::role('Super Admin')->pluck('id')->toArray();
|
||||
}
|
||||
if (!empty($approverIds)) {
|
||||
app(\Modules\ApprovalWorkflow\Services\ApprovalService::class)->createChain(
|
||||
$document,
|
||||
$approverIds,
|
||||
'document',
|
||||
$request->user()->id,
|
||||
"New version uploaded for: {$document->title}"
|
||||
);
|
||||
}
|
||||
|
||||
return back()->with('success', 'New version uploaded. Document status reset to Pending.');
|
||||
return back()->with('success', 'New document version uploaded successfully.');
|
||||
}
|
||||
|
||||
public function download(Document $document)
|
||||
|
||||
Reference in New Issue
Block a user