app/Http/Controllers/PostController.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)
    {
        $this->validate($request, [
            'title' => 'required',
            'content' => 'required',
        ]);
        $post = new Post;
        $post->users_id = auth()->user()->id;
        $post->title = $request->input('title');
        $post->content = $request->input('content');
        $post->created_at = now();
        $post->updated_at = now();
        $post->save();
        return redirect('/dashboard')->with('status', 'Post Created');
    }
public function store ( Request $ request ) { $ this -> validate ( $ request , [ 'title' => 'required' , 'content' => 'required' , ] ) ; $ post = new Post ; $ post -> users_id = auth ( ) -> user ( ) -> id ; $ post -> title = $ request -> input ( 'title' ) ; $ post -> content = $ request -> input ( 'content' ) ; $ post -> created_at = now ( ) ; $ post -> updated_at = now ( ) ; $ post -> save ( ) ; return redirect ( '/dashboard' ) -> with ( 'status' , 'Post Created' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .