app/Http/Controllers/FrontMeditacaoController.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)
    {
        $meditacao = new MeditacaoModel();
        $meditacao->nome = $request['nome'];
        $meditacao->categoria = $request['categoria'];
        $file = $request->file('audio');
        if ($file !=null){
            $newName = str_replace('.'.$file->getClientOriginalExtension() , '' , strtolower( preg_replace('/[ -]+/' , '_' , strtr(utf8_decode(trim($file->getClientOriginalName())), utf8_decode("áàãâéêíóôõúüñçÁÀÃÂÉÊÍÓÔÕÚÜÑÇ"), "aaaaeeiooouuncAAAAEEIOOOUUNC-")) )).'_'.uniqid().'.'.$file->getClientOriginalExtension();
            $file->move(public_path('meditacao'), $newName);
            $meditacao->audio = "meditacao/".$newName;
        }
        $meditacao->save();
        flash('Upload realizado com sucesso!')->success();
        return redirect()->route('meditacoes.index');
    }
public function store ( Request $ request ) { $ meditacao = new MeditacaoModel ( ) ; $ meditacao -> nome = $ request [ 'nome' ] ; $ meditacao -> categoria = $ request [ 'categoria' ] ; $ file = $ request -> file ( 'audio' ) ; if ( $ file != null ) { $ newName = str_replace ( '.' . $ file -> getClientOriginalExtension ( ) , '' , strtolower ( preg_replace ( '/[ -]+/' , '_' , strtr ( utf8_decode ( trim ( $ file -> getClientOriginalName ( ) ) ) , utf8_decode ( " áàãâéêíóôõúüñçÁÀÃÂÉÊÍÓÔÕÚÜÑÇ"), "aaaaeeiooouuncAAAAEEIOO O U U C -")) )).'_'.uniqid().'.'.$fil e - > e t C lie n tOrigi n a l Ext e n sion () ; $ file -> move ( public_path ( 'meditacao' ) , $ newName ) ; $ meditacao -> audio = " meditacao/ " . $ newName ; } $ meditacao -> save ( ) ; flash ( 'Upload realizado com sucesso!' ) -> success ( ) ; return redirect ( ) -> route ( 'meditacoes.index' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .