app/Http/Controllers/LaporanController.php
/**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
Display a listing of the resource.
@return \Illuminate\Http\Response
Display a listing of the resource . @return \ Illuminate \ Http \ Response
public function index()
    {
        $mahasiswa = auth()->user()->mahasiswa;
        $data = DB::table('master_capaian')->where('jurusan',$mahasiswa->jurusan)->get();
        $is_enabled = auth()->user()->pemagang->laporan_weekend??0;
        $excepted_days = [];
        if(!$is_enabled){
            $excepted_days=['Sat','Sun'];
        }
        $this_day=date('D');
        $hari_libur=in_array($this_day,$excepted_days);
        $hasLaporanToday=!is_null(auth()->user()->mahasiswa->pemagangan)?
                    Laporan::where('id_data_bimbingan',auth()->user()->mahasiswa->pemagangan->id)
                            ->whereDate('tanggal_laporan', '=', date('Y-m-d'))->get()
                    :collect([]);
        $masa_magang=Pemagangan::where('mahasiswa_id',auth()->user()->mahasiswa->id)
                                ->whereDate('mulai_magang','<=',date('Y-m-d'))
                                ->whereDate('selesai_magang','>=',date('Y-m-d'))->first();
        $view = request()->is('lupa-laporan')?'laporan.lupa':'laporan.index';
        return view($view, compact('data','hari_libur','hasLaporanToday','masa_magang'));
    }
public function index ( ) { $ mahasiswa = auth ( ) -> user ( ) -> mahasiswa ; $ data = DB :: table ( 'master_capaian' ) -> where ( 'jurusan' , $ mahasiswa -> jurusan ) -> get ( ) ; $ is_enabled = auth ( ) -> user ( ) -> pemagang -> laporan_weekend ?? 0 ; $ excepted_days = [ ] ; if ( ! $ is_enabled ) { $ excepted_days = [ 'Sat' , 'Sun' ] ; } $ this_day = date ( 'D' ) ; $ hari_libur = in_array ( $ this_day , $ excepted_days ) ; $ hasLaporanToday = ! is_null ( auth ( ) -> user ( ) -> mahasiswa -> pemagangan ) ? Laporan :: where ( 'id_data_bimbingan' , auth ( ) -> user ( ) -> mahasiswa -> pemagangan -> id ) -> whereDate ( 'tanggal_laporan' , '=' , date ( 'Y-m-d' ) ) -> get ( ) : collect ( [ ] ) ; $ masa_magang = Pemagangan :: where ( 'mahasiswa_id' , auth ( ) -> user ( ) -> mahasiswa -> id ) -> whereDate ( 'mulai_magang' , '<=' , date ( 'Y-m-d' ) ) -> whereDate ( 'selesai_magang' , '>=' , date ( 'Y-m-d' ) ) -> first ( ) ; $ view = request ( ) -> is ( 'lupa-laporan' ) ? 'laporan.lupa' : 'laporan.index' ; return view ( $ view , compact ( 'data' , 'hari_libur' , 'hasLaporanToday' , 'masa_magang' ) ) ; }
Display a listing of the resource.
Display a listing of the resource .
//ambil data master_capaian // Hari yang dikecualikan untuk laporan ['sabtu','minggu']; // Cek apakah hari ini sudah melakukan 2x laporan apa belum // Cek apakah si user nya sudah melewati masa akhir magang