fadlyshafa

Untitled

Apr 30th, 2020
426
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. namespace App\Http\Controllers\Admin;
  4.  
  5. use App\Http\Controllers\Controller;
  6. use Illuminate\Http\Request;
  7.  
  8. use App\Models\Banner;
  9.  
  10. class Banner_controller extends Controller
  11. {
  12.     public function index(){
  13.         $title = 'Manage Banner';
  14.         $dt = Banner::first();
  15.  
  16.         return view('admin.banner.index',compact('title','dt'));
  17.     }
  18.  
  19.     public function update(Request $request){
  20.         $data['judul_kecil'] = $request->judul_kecil;
  21.         $data['judul_besar'] = $request->judul_besar;
  22.         $data['keterangan'] = $request->keterangan;
  23.  
  24.         $file = $request->file('photo');
  25.         if($file){
  26.             $nama_file = $file->getClientOriginalName();
  27.             $file->move('banner_uploads',$nama_file);
  28.             $data['photo'] = 'banner_uploads/'.$nama_file;
  29.         }
  30.  
  31.         $data['created_at'] = date('Y-m-d H:i:s');
  32.         $data['updated_at'] = date('Y-m-d H:i:s');
  33.  
  34.         \DB::table('banner')->update($data);
  35.  
  36.         \Session::flash('sukses','Data berhasil diupdate');
  37.         return redirect()->back();
  38.     }
  39. }
RAW Paste Data