app/Http/Controllers/Admin/ArtigoController.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)
    {   
        $dados = $request->all();
        $validacao = Validator::make($dados, [
            'titulo' => 'required',
            'descricao' => 'required',
            'conteudo' => 'required',
            'data' => 'required'
        ]);
        if($validacao->fails()){
            return redirect()
                ->back()
                ->withErrors($validacao)
                ->withInput();
        }
        $user = auth()->user();
        $user->artigos()->create($dados);
        return redirect()->back();
    }
public function store ( Request $ request ) { $ dados = $ request -> all ( ) ; $ validacao = Validator :: make ( $ dados , [ 'titulo' => 'required' , 'descricao' => 'required' , 'conteudo' => 'required' , 'data' => 'required' ] ) ; if ( $ validacao -> fails ( ) ) { return redirect ( ) -> back ( ) -> withErrors ( $ validacao ) -> withInput ( ) ; } $ user = auth ( ) -> user ( ) ; $ user -> artigos ( ) -> create ( $ dados ) ; return redirect ( ) -> back ( ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
// $artigos = Artigo::find($user->id); // dd($user); // Artigo::create(['user_id' => $user->id]);