SHARE
TWEET

Untitled

fadlyshafa Jan 17th, 2020 111 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.  
  7. use App\Models\Status_pembayaran;
  8.  
  9. class Status_pembayaran_controller extends Controller
  10. {
  11.     public function index(){
  12.         $title = 'Master status pembayaran';
  13.         $data = Status_pembayaran::orderBy('nama','asc')->get();
  14.  
  15.         return view('status_pembayaran.index',compact('title','data'));
  16.     }
  17.  
  18.     public function add(){
  19.         $title = 'Tambah status pembayaran';
  20.  
  21.         return view('status_pembayaran.add',compact('title'));
  22.     }
  23.  
  24.     public function store(Request $request){
  25.         $this->validate($request,[
  26.             'nama'=>'required'
  27.         ]);
  28.  
  29.         $data['id'] = \Uuid::generate(4);
  30.         $data['nama'] = $request->nama;
  31.         $data['created_at'] = date('Y-m-d H:i:s');
  32.         $data['updated_at'] = date('Y-m-d H:i:s');
  33.  
  34.         Status_pembayaran::insert($data);
  35.  
  36.         \Session::flash('sukses','Data berhasil ditambah');
  37.         return redirect('status-pembayaran');
  38.     }
  39.  
  40.     public function edit($id){
  41.         $dt = Status_pembayaran::find($id);
  42.         $title = "Edit Status Pembayaran $dt->nama";
  43.  
  44.         return view('status_pembayaran.edit',compact('title','dt'));
  45.     }
  46.  
  47.     public function update(Request $request, $id){
  48.         $this->validate($request,[
  49.             'nama'=>'required'
  50.         ]);
  51.  
  52.         // $data['id'] = \Uuid::generate(4);
  53.         $data['nama'] = $request->nama;
  54.         // $data['created_at'] = date('Y-m-d H:i:s');
  55.         $data['updated_at'] = date('Y-m-d H:i:s');
  56.  
  57.         Status_pembayaran::where('id',$id)->update($data);
  58.  
  59.         \Session::flash('sukses','Data berhasil diupdate');
  60.         return redirect('status-pembayaran');
  61.     }
  62.  
  63.     public function delete($id){
  64.         try {
  65.             Status_pembayaran::where('id',$id)->delete();
  66.  
  67.         \Session::flash('sukses','Data berhasil dihapus');
  68.         } catch (\Exception $e) {
  69.             \Session::flash('gagal',$e->getMessage());
  70.         }
  71.         return redirect('status-pembayaran');
  72.     }
  73. }
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