fadlyshafa

Untitled

Aug 10th, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.69 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Http\Controllers\Admin;
  4.  
  5. use Illuminate\Http\Request;
  6. use App\Http\Controllers\Controller;
  7.  
  8. class Iklan_controller extends Controller
  9. {
  10.     public function index(){
  11.         $title = 'Manage iklan';
  12.  
  13.         return view('admin.iklan.iklan_index',compact('title'));
  14.     }
  15.  
  16.     public function store(Request $request){
  17.         $file = $request->file('image');
  18.         \DB::table('iklan')->truncate();
  19.  
  20.         if($file){
  21.             //Move Uploaded File
  22.             $destinationPath = 'uploads';
  23.             $file->move($destinationPath,$file->getClientOriginalName());
  24.  
  25.             \DB::table('iklan')->insert([
  26.                 'url'=>$request->url,
  27.                 'gambar'=>$file->getClientOriginalName()
  28.             ]);
  29.         }
  30.  
  31.         return redirect('admin/iklan');
  32.     }
  33. }
Add Comment
Please, Sign In to add comment