app/Http/Controllers/Admin/ArtigoController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, $id)
    {
        $dados = $request->all();
        $validacao = Validator::make($dados, [
            'titulo' => 'required',
            'descricao' => 'required',
            'conteudo' => 'required',
            'data' => 'required'
        ]);
        if($validacao->fails()){
            return redirect()
                ->back()
                ->withErrors($validacao)
                ->withInput();
        }
        $artigos = new Artigo();
        $user = auth()->user();
        $user->artigos()->find($id)->update($dados);
        return redirect()->back();
    }
public function update ( Request $ request , $ id ) { $ dados = $ request -> all ( ) ; $ validacao = Validator :: make ( $ dados , [ 'titulo' => 'required' , 'descricao' => 'required' , 'conteudo' => 'required' , 'data' => 'required' ] ) ; if ( $ validacao -> fails ( ) ) { return redirect ( ) -> back ( ) -> withErrors ( $ validacao ) -> withInput ( ) ; } $ artigos = new Artigo ( ) ; $ user = auth ( ) -> user ( ) ; $ user -> artigos ( ) -> find ( $ id ) -> update ( $ dados ) ; return redirect ( ) -> back ( ) ; }
Update the specified resource in storage.
Update the specified resource in storage .