Anons79 Mini Shell

Directory : /home/aplikasiposinfo/.trash/app.2/Http/Controllers/
Upload File :
Current File : /home/aplikasiposinfo/.trash/app.2/Http/Controllers/RealisasiAnggaranController.php

<?php

namespace App\Http\Controllers;

use App\Models\IndukOpd;
use App\Models\SubKegiatan;
use Illuminate\Http\Request;
use App\Models\detailKegiatan;
use App\Models\visiRpjmd;
use Illuminate\Support\Facades\Auth;

class RealisasiAnggaranController extends Controller
{
    protected $routeName = 'realisasi_anggaran';
    protected $viewName = 'realisasi_anggaran';
    protected $title = 'Realisasi Anggaran';

    public function index()
    {
        //
        $route = $this->routeName;
        $title = $this->title;
        
        
        
        $tahun = visiRpjmd::get();
        
        $tahunArray = [];
        
        foreach ($tahun as $item) {
            $range = range($item->tahun_awal, $item->tahun_akhir);
            $tahunArray = array_merge($tahunArray, $range);
        }

        // Hilangkan duplikat (karena 2025-2026 muncul dua kali)
        $tahunArray = array_unique($tahunArray);
        sort($tahunArray); // Urutkan lagi
        
        if(isset($_GET['tahun'])) {
            $results = visiRpjmd::where('tahun_awal', '<=', $_GET['tahun'])
                    ->where('tahun_akhir', '>=', $_GET['tahun'])
                    ->get();
        } else {
        $results = visiRpjmd::where('tahun_awal', '<=', date('Y'))
                    ->where('tahun_akhir', '>=', date('Y'))
                    ->get();            
        }
        
        $indukOpd = IndukOpd::pluck('nama', 'id');
        if(Auth::user()->roles->first()->name !== "Admin"){
            $indukOpd = IndukOpd::where('id', Auth::user()->induk_opd_id)->pluck('nama', 'id');
        }
        $induk_opd_arr = $indukOpd;
        return view('realisasi_anggaran.index',compact('route','title', 'induk_opd_arr', 'tahunArray'));

    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
        try {
            //code...
            $detailKegiatan = SubKegiatan::find($id)->first();
            $detailKegiatan->update([
                'rp_tri_1' => $request->tw_1,
                'rp_tri_2' => $request->tw_2,
                'rp_tri_3' => $request->tw_3,
                'rp_tri_4' => $request->tw_4,
            ]);

            return redirect(route('realisasi_anggaran.index'))->with(['success'=>'Berhasil Menambah data Realisasi Anggaran']);
        } catch (\Throwable $th) {
            //throw $th;
        }
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
}

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]