SHARE
TWEET

Suketpengajuancontroller.php

ramadhanf_ Aug 25th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. namespace App\Http\Controllers;
  4.  
  5. use Illuminate\Http\Request;
  6. use App\Suketpengajuan;
  7. use App\User;
  8.  
  9.  
  10. class SuketpengajuanController extends Controller
  11. {
  12.     /**
  13.      * Display a listing of the resource.
  14.      *
  15.      * @return \Illuminate\Http\Response
  16.      */
  17.     public function index()
  18.     {
  19.         //
  20.         return view('suketpengajuan.save');
  21.     }
  22.  
  23.  
  24.  
  25.     /**
  26.      * Show the form for creating a new resource.
  27.      *
  28.      * @return \Illuminate\Http\Response
  29.      */
  30.     public function create()
  31.     {
  32.         //
  33.         return view('suketpengajuan.save');
  34.     }
  35.  
  36.     /**
  37.      * Store a newly created resource in storage.
  38.      *
  39.      * @param  \Illuminate\Http\Request  $request
  40.      * @return \Illuminate\Http\Response
  41.      */
  42.     public function store(Request $request)
  43.     {
  44.         //
  45.         // return $request->all(); => untuk membaca data JSON yang datanya telah dimasukkan
  46.         // return $request->nama_lengkap(); => untuk membaca data JSON yang munculnya hanya data nama lengkapnya saja
  47.  
  48.         $request->validate(['keperluan' => 'required|unique:suketpengajuan|min:5']);
  49.        
  50.         $suketpengajuan = New suketpengajuan();
  51.         //$suketpengajuan->create($request->all());
  52.         //return redirect('/suketpengajuan');
  53.  
  54.  
  55.         $getNoSK = \DB::select("SELECT NoSK FROM suketpengajuan ORDER BY NoSK DESC LIMIT 1");
  56.        
  57.         $NoSK = $getNoSK[0]->NoSK;
  58.         $getYear = date('y');
  59.         $NoSK = str_replace("SK","",$NoSK) + 1;
  60.         $NoSK = "SK".$NoSK;
  61.         $dataSet = [
  62.                 'NoSK' => $NoSK,
  63.                 'id' => $request->id,
  64.                 'nama_lengkap'  => $request->nama_lengkap,
  65.                 'TglSurat' => date('d:m:Y'),
  66.                 'Alamat'    => $request->alamat,
  67.                 'Keperluan'   => $request->keperluan,
  68.                 'Status' => $request->status
  69.             ];
  70.         //\DB::table('suketpengajuan')->insert($dataSet);
  71.         return view('suketpengajuan.submit', $dataSet);
  72.        
  73.     }
  74.  
  75.     public function simpanpengajuan(Request $request, $NoSK){
  76.         $dataSet = [
  77.             'NoSK' => $request->NoSK,
  78.             'id' => $request->id,
  79.             'nama_lengkap'  => $request->nama_lengkap,
  80.             'TglSurat' => $request->TglSurat,
  81.             'Alamat'    => $request->alamat,
  82.             'Keperluan'   => $request->keperluan,
  83.             'Status' => 'Sudah Diterima HRD',
  84.             'TglSubmit' => Carbon\Carbon::now()
  85.         ];
  86.    
  87.         $save = \DB::table('suketpengajuan')->insert($dataSet);
  88.         if($save){
  89.  
  90.            
  91.             $datafix = DB::select("SELECT * FROM suketpengajuan WHERE NoSK == $NoSK")->get();
  92.  
  93.             $datask = [
  94.  
  95.                 'NoSK' => $datafix->NoSK,
  96.                 'nama_lengkap' => $datafix->nama_lengkap,
  97.                 'TglSurat' => $datafix->TglSurat,
  98.                 'Alamat' => $datafix->Alamat,
  99.                 'Keperluan' => $datafix->Keperluan,
  100.                 'Status' => $datafix->Status
  101.             ];
  102.           return view('suketpengajuan.receive', $datask);
  103.        
  104.         }else{
  105.             echo "Gagal Menyimpan";    
  106.         }
  107.     }
  108.  
  109.  
  110.     public function selesaisubmit($NoSK){
  111.  
  112.         $aftersubmit = DB::table('suketpengajuan')
  113.                        ->where('NoSK', '=', $NoSK)
  114.                        ->get();
  115.  
  116.         $aftersubmit = [
  117.  
  118.             'NoSK' => $aftersubmit->NoSK,
  119.             'nama_lengkap' => $aftersubmit->nama_lengkap,
  120.             'TglSurat' => $aftersubmit->TglSurat,
  121.             'Alamat' => $aftersubmit->Alamat,
  122.             'Keperluan' => $aftersubmit->Keperluan,
  123.             'Status' => $aftersubmit->Status
  124.         ];
  125.  
  126.         return view('suketpengajuan.receive', $aftersubmit);
  127.     }
  128.     /**
  129.      * Display the specified resource.
  130.      *
  131.      * @param  int  $id
  132.      * @return \Illuminate\Http\Response
  133.      */
  134.     public function show($id)
  135.     {
  136.         //
  137.     }
  138.  
  139.     /**
  140.      * Show the form for editing the specified resource.
  141.      *
  142.      * @param  int  $id
  143.      * @return \Illuminate\Http\Response
  144.      */
  145.     public function edit($id)
  146.     {
  147.         //
  148.     }
  149.  
  150.     /**
  151.      * Update the specified resource in storage.
  152.      *
  153.      * @param  \Illuminate\Http\Request  $request
  154.      * @param  int  $id
  155.      * @return \Illuminate\Http\Response
  156.      */
  157.     public function update(Request $request, $id)
  158.     {
  159.         //
  160.     }
  161.  
  162.     /**
  163.      * Remove the specified resource from storage.
  164.      *
  165.      * @param  int  $id
  166.      * @return \Illuminate\Http\Response
  167.      */
  168.     public function destroy($id)
  169.     {
  170.         //
  171.     }
  172. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top