app/Http/Controllers/GaleriController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
    {
      if (Auth::check()) {
        $file = $request->file('sampul');
        $tujuan_upload = 'img/galeri';
        $nama_file = time()."_".$file->getClientOriginalName();
        $file->move($tujuan_upload,$nama_file);
        $user_id = Auth::id();
        $user_namalengkap = Auth::user()->namalengkap;
        Galeri::create([
          'judul' => $request -> judul,
          'sampul' => $nama_file,
          'caption' => $request -> caption,
          'waktu' => $request -> waktu,
          'status' => 1,
          'linkVideo' => $request -> linkVideo,
          'user_id' => $user_id,
          'user_nama' => $user_namalengkap,
        ]);
        return redirect()->route('mine.galeri');
      } else {
        return redirect()->route('login');
      }
    }
public function store ( Request $ request ) { if ( Auth :: check ( ) ) { $ file = $ request -> file ( 'sampul' ) ; $ tujuan_upload = 'img/galeri' ; $ nama_file = time ( ) . " _ " . $ file -> getClientOriginalName ( ) ; $ file -> move ( $ tujuan_upload , $ nama_file ) ; $ user_id = Auth :: id ( ) ; $ user_namalengkap = Auth :: user ( ) -> namalengkap ; Galeri :: create ( [ 'judul' => $ request -> judul , 'sampul' => $ nama_file , 'caption' => $ request -> caption , 'waktu' => $ request -> waktu , 'status' => 1 , 'linkVideo' => $ request -> linkVideo , 'user_id' => $ user_id , 'user_nama' => $ user_namalengkap , ] ) ; return redirect ( ) -> route ( 'mine.galeri' ) ; } else { return redirect ( ) -> route ( 'login' ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .