JadwalKegiatanController.php 1.85 KB
Newer Older
1 2
<?php

novanbagus committed
3
namespace App\Http\Controllers\Operator;
4

novanbagus committed
5
use App\Http\Controllers\Controller;
6
use DB;
novanbagus committed
7

8 9 10 11 12
use URL;
use Auth;
use Uuid;
use Alert;
use Crypt;
novanbagus committed
13
use Carbon\Carbon;
14

novanbagus committed
15
use Illuminate\Http\Request;
16 17 18 19 20 21
use App\Models\JadwalKegiatan;

class JadwalKegiatanController extends Controller
{
    public function index()
    {
novanbagus committed
22 23 24 25 26 27
		$data_periode = DB::table('periode')->select('periode_id', 'nama', 'keterangan')->where('status', '1')->first();
        session(['periode_id' => $data_periode->periode_id]);

		$periode_id = session('periode_id');

        $data['jadwal_kegiatan'] = JadwalKegiatan::where('status_hapus', '0')->where('periode_id', $periode_id)->orderBy('urut')->get();
28

novanbagus committed
29
        return view('backend.operator.jadwal_kegiatan.index', compact('data'))->withTitle('Jadwal Kegiatan');
30 31 32 33 34 35 36 37 38 39 40 41 42 43
    }

    /* AJAX request */
    public function getData(Request $request){

    }

    public function create()
    {

    }

    public function store(Request $request)
    {
novanbagus committed
44 45 46 47 48 49 50 51 52 53
        foreach ($request->tanggal as $key => $value) {
            if(!empty($value))
            {
                $tanggal = explode(" - ", $value);
                $tanggal_mulai = $tanggal[0];
                $tanggal_selesai = $tanggal[1];

                JadwalKegiatan::where('jadwal_kegiatan_id', $key)->update(['tanggal_mulai'=>Carbon::createFromFormat('d-m-Y H:i', $tanggal_mulai)->format('Y-m-d H:i'), 'tanggal_selesai'=>Carbon::createFromFormat('d-m-Y H:i', $tanggal_selesai)->format('Y-m-d H:i')]);
            }
        }
54

novanbagus committed
55 56 57
        Alert::success('Data berhasil disimpan')->persistent('Ok');
        $successmessage = "Proses Setting Jadwal Berhasil.";

novanbagus committed
58
        return redirect()->route('operator.jadwal-kegiatan.index')->with('successMessage', $successmessage);
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
    }

    public function edit($id)
    {

    }

    public function update(Request $request, $id)
    {

    }

    public function destroy($id)
    {

    }
}