Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
5.0 kB
1
Indexable
Never
     public function forOther(?array $params = []): LengthAwarePaginator
    {
        $data = [];
        $projectIds = $this->filterProject($params);

        $weeklyCollection = $this->weeklyModel->with('stakeholders', 'project')->whereIn('project_id', $projectIds)->where('active', true)
        ->orderBy('id', 'DESC');

        $weekly = \App\Helpers\QuickAccessHelper::weeklyQueue($weeklyCollection);
        if (count($weekly) > 0) {
            foreach ($weekly as $item) {
                $item = [
                    'id' => $item['id'],
                    'project_name' => $item['project_name'],
                    'document_name' => 'Progress Mingguan - '.$item['period'],
                    'created_date' => $item['created_at'],
                    'stakeholder' => $item['stakeholder'],
                    'document_url' => route('features.my-project.laporan-mingguan.index', $item['project_id']),
                    'flag' => 'mingguan',
                    
                ];
                $data[] = $item;
            }
        }

        $lkpCollection = $this->lkpModel->whereIn('project_id', $projectIds)->where('active', true)
        ->orderBy('id', 'DESC');

        $lkp = \App\Helpers\QuickAccessHelper::lkpQueue($lkpCollection);


        if (count($lkp) > 0) {
            foreach ($lkp as $item) {
                $item = [
                    'id' => $item['id'],
                    'project_name' => $item['project_name'],
                    'created_date' => $item['created_at'],
                    'document_name' => 'Progress Bulanan - '.\App\Helpers\DateHelper::convertPeriod($item['period']),
                    'stakeholder' => $item['stakeholder'],
                    'document_url' => route('features.my-project.laporan-bulanan.index', $item['project_id']),
                    'flag' => 'lkp',
                    'latestProgresRencana' => $item['latestProgresRencana'],
                ];
                $data[] = $item;
            }
        }


        $termynCollection = $this->termynModel->whereIn('project_id', $projectIds)->where('active', true)
        ->orderBy('id', 'DESC');
        $termyn = \App\Helpers\QuickAccessHelper::termynQueue($termynCollection);

        if (count($termyn) > 0) {
            foreach ($termyn as $item) {
                $item = [
                    'id' => $item['id'],
                    'project_name' => $item['project_name'],
                    'created_date' => $item['created_at'],
                    'document_name' => 'Laporan Termyn - '.$item['frequency'],
                    'stakeholder' => $item['stakeholder'],
                    'document_url' => route('features.my-project.laporan-termyn.index', $item['project_id']),
                    'flag' => 'termyn',
                ];
                $data[] = $item;
            }
        }

        if ((Auth::user()->role->id != 11) && (Auth::user()->role->id != 13)) {
            $bappCollection = $this->bappModel->whereIn('project_id', $projectIds)
            ->orderBy('id', 'DESC');
            $bapp = \App\Helpers\QuickAccessHelper::bappQueue($bappCollection);

            if (count($bapp) > 0) {
                foreach ($bapp as $item) {
                    $item = [
                        'id' => $item['id'],
                        'project_name' => $item['project_name'],
                        'created_date' => $item['created_at'],
                        'document_name' => 'BA Pemeriksaan Pekerjaan - Termyn '.$item['termyn'],
                        'stakeholder' => $item['stakeholder'],
                        'document_url' => route('features.my-project.bapp.index', $item['project_id']),
                        'flag' => 'bapp',
                    ];
                    $data[] = $item;
                }
            }

            $bapCollection = $this->bapModel->whereIn('project_id', $projectIds)
            ->orderBy('id', 'DESC');
            $bap = \App\Helpers\QuickAccessHelper::bapQueue($bapCollection);

            if (count($bap) > 0) {
                foreach ($bap as $item) {
                    $bap = [
                        'id' => $item['id'],
                        'project_name' => $item['project_name'],
                        'created_date' => $item['created_at'],
                        'document_name' => 'BA Pembayaran - '.$item['number'],
                        'stakeholder' => $item['stakeholder'],
                        'document_url' => route('features.my-project.bap.index', $item['project_id']),
                        'flag' => 'bap',
                    ];

                    if ($item['number'] == -1) {
                        $bap['document_name'] = 'Down Payment';
                    }

                    $data[] = $bap;
                }
            }
        }

        return $this->paginate($data);
    }
Leave a Comment