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)
    {
        $request->validate([
            'nama' => 'required',
            'keterangan' => 'required',
            'jenis_file' => 'required',
            'file' => 'required|mimes:jpeg,png,jpg,gif,svg,mp4,m4v,mkv,avi,mov,mpeg|max:4096',
        ]);
        $input = $request->all();
        if ($file = $request->file('file')) {
            $destinationPath = 'file/galeri/';
            $profileFile = date('YmdHis') . "." . $file->getClientOriginalExtension();
            $file->move($destinationPath, $profileFile);
            $input['file'] = "$profileFile";
        }
        Galeri::create($input);
        return redirect()->route('galeris.index')
                        ->with('success','Tips Berhasil Dibuat !');
    }
public function store ( Request $ request ) { $ request -> validate ( [ 'nama' => 'required' , 'keterangan' => 'required' , 'jenis_file' => 'required' , 'file' => 'required|mimes:jpeg,png,jpg,gif,svg,mp4,m4v,mkv,avi,mov,mpeg|max:4096' , ] ) ; $ input = $ request -> all ( ) ; if ( $ file = $ request -> file ( 'file' ) ) { $ destinationPath = 'file/galeri/' ; $ profileFile = date ( 'YmdHis' ) . " . " . $ file -> getClientOriginalExtension ( ) ; $ file -> move ( $ destinationPath , $ profileFile ) ; $ input [ 'file' ] = " $ profileFile " ; } Galeri :: create ( $ input ) ; return redirect ( ) -> route ( 'galeris.index' ) -> with ( 'success' , 'Tips Berhasil Dibuat !' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .