update: latest changes to multi-tenant branch

This commit is contained in:
2026-08-12 18:44:24 +08:00
parent 80c0a2ea42
commit 3e8abf59f9
486 changed files with 28968 additions and 15306 deletions

View File

@@ -14,12 +14,13 @@ class PayrollRunController extends Controller
{
public function index(Request $request)
{
if (Auth::user()->can('manage-payroll-runs')) {
$query = PayrollRun::with(['creator'])->where(function ($q) {
if (Auth::user()->can('manage-any-payroll-runs')) {
$user = Auth::user();
if ($user->type === 'company' || $user->can('manage-payroll-runs') || $user->can('manage-payrolls') || $user->can('view-payrolls') || $user->can('manage-payroll') || $user->can('view-payroll')) {
$query = PayrollRun::with(['creator'])->where(function ($q) use ($user) {
if ($user->type === 'company' || $user->can('manage-any-payroll-runs') || $user->can('manage-payrolls') || $user->can('manage-payroll-runs')) {
$q->whereIn('created_by', getCompanyAndUsersId());
} else {
$q->where('created_by', Auth::id());
$q->whereIn('created_by', getCompanyAndUsersId());
}
});