feat: implement comprehensive dashboard controller and modular administrative and project management interfaces
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

This commit is contained in:
Ajjj
2026-08-03 18:28:52 +08:00
parent 42ba980f7a
commit 936ae1c6b2
48 changed files with 1832 additions and 385 deletions

View File

@@ -45,16 +45,37 @@ class ProjectController extends Controller
->where('current_wizard_step', '<', 7)
->with(['contractor:id,company_name', 'personnel:id,name']);
// Non-platform admins only see projects they are assigned to
if ($user && !$user->hasRole('Super Admin')) {
$query->whereHas('personnel', function ($q) use ($user) {
$q->where('users.id', $user->id);
// Filter non-admin users to assigned projects or company projects
if ($user && $user->user_type !== 'admin' && ! $user->hasRole('Super Admin')) {
$query->where(function ($q) use ($user) {
$q->whereHas('personnel', function ($pq) use ($user) {
$pq->where('users.id', $user->id);
});
if ($user->contractor_id) {
$q->orWhere('contractor_id', $user->contractor_id);
} else {
$q->orWhereNull('contractor_id');
}
});
$historyQuery->whereHas('personnel', function ($q) use ($user) {
$q->where('users.id', $user->id);
$historyQuery->where(function ($q) use ($user) {
$q->whereHas('personnel', function ($pq) use ($user) {
$pq->where('users.id', $user->id);
});
if ($user->contractor_id) {
$q->orWhere('contractor_id', $user->contractor_id);
} else {
$q->orWhereNull('contractor_id');
}
});
$draftsQuery->whereHas('personnel', function ($q) use ($user) {
$q->where('users.id', $user->id);
$draftsQuery->where(function ($q) use ($user) {
$q->whereHas('personnel', function ($pq) use ($user) {
$pq->where('users.id', $user->id);
});
if ($user->contractor_id) {
$q->orWhere('contractor_id', $user->contractor_id);
} else {
$q->orWhereNull('contractor_id');
}
});
}
@@ -64,7 +85,7 @@ class ProjectController extends Controller
->latest()
->paginate(15, ['*'], 'page')
->withQueryString()
->through(fn ($p) => $p->append(['capitalization_percentage', 'is_over_budget']));
->through(fn ($p) => $p->append(['capitalization_percentage', 'is_over_budget', 'milestone_completion']));
$history = $historyQuery
->when($request->search, fn ($q, $s) => $q->where('name', 'like', "%{$s}%")->orWhere('code', 'like', "%{$s}%"))
@@ -72,7 +93,7 @@ class ProjectController extends Controller
->latest()
->paginate(15, ['*'], 'history_page')
->withQueryString()
->through(fn ($p) => $p->append(['capitalization_percentage', 'is_over_budget']));
->through(fn ($p) => $p->append(['capitalization_percentage', 'is_over_budget', 'milestone_completion']));
$drafts = $draftsQuery->latest()->get();
@@ -90,7 +111,16 @@ class ProjectController extends Controller
public function create()
{
$employees = User::whereIn('user_type', ['admin', 'employee'])->with('employeeProfile')->select('id', 'ulid', 'name', 'email', 'profile_picture')->get();
$employees = User::whereIn('user_type', ['admin', 'employee'])
->where(function ($q) {
$q->whereIn('user_type', ['admin'])
->orWhereHas('roles', function ($rq) {
$rq->whereIn('name', ['Project Manager', 'Main Contractor Admin', 'Super Admin', 'admin', 'Contractor']);
});
})
->with('employeeProfile')
->select('id', 'ulid', 'name', 'email', 'profile_picture')
->get();
$projects = Project::active()->with('parentProject:id,ulid,name,code')->get(['id', 'ulid', 'name', 'code', 'parent_project_id', 'project_type']);
return Inertia::render('ProjectManagement::Projects/Create', [
@@ -241,7 +271,16 @@ class ProjectController extends Controller
'materialsEstimates.material',
]);
$employees = User::whereIn('user_type', ['admin', 'employee'])->with('employeeProfile')->select('id', 'ulid', 'name', 'email', 'profile_picture')->get();
$employees = User::whereIn('user_type', ['admin', 'employee'])
->where(function ($q) {
$q->whereIn('user_type', ['admin'])
->orWhereHas('roles', function ($rq) {
$rq->whereIn('name', ['Project Manager', 'Main Contractor Admin', 'Super Admin', 'admin', 'Contractor']);
});
})
->with('employeeProfile')
->select('id', 'ulid', 'name', 'email', 'profile_picture')
->get();
$projects = Project::active()->with('parentProject:id,ulid,name,code')->where('id', '!=', $project->id)->get(['id', 'ulid', 'name', 'code', 'parent_project_id', 'project_type']);
$materials = \Modules\MasterData\Models\Material::where('type', 'single')
@@ -412,7 +451,16 @@ class ProjectController extends Controller
'personnel:id,ulid,name,email',
]);
$employees = User::whereIn('user_type', ['admin', 'employee'])->with('employeeProfile')->select('id', 'ulid', 'name', 'email', 'profile_picture')->get();
$employees = User::whereIn('user_type', ['admin', 'employee'])
->where(function ($q) {
$q->whereIn('user_type', ['admin'])
->orWhereHas('roles', function ($rq) {
$rq->whereIn('name', ['Project Manager', 'Main Contractor Admin', 'Super Admin', 'admin', 'Contractor']);
});
})
->with(['employeeProfile', 'roles'])
->select('id', 'ulid', 'name', 'email', 'user_type', 'profile_picture')
->get();
$parentProjects = Project::active()->with('parentProject:id,ulid,name,code')->where('id', '!=', $project->id)->get(['id', 'ulid', 'name', 'code', 'parent_project_id', 'project_type']);
$materials = \Modules\MasterData\Models\Material::where('type', 'single')
->where('status', 'active')