src/Controllers/ChatterPostController.php
public function update(Request $request, $id)
    {
        $stripped_tags_body = ['body' => strip_tags($request->body)];
        $validator = Validator::make($stripped_tags_body, [
            'body' => 'required|min:10',
        ],[
			'body.required' => trans('chatter::alert.danger.reason.content_required'),
			'body.min' => trans('chatter::alert.danger.reason.content_min'),
		]);

        if ($validator->fails()) {
            return back()->withErrors($validator)->withInput();
        }

        $post = Models::post()->find($id);
        if (!Auth::guest() && (Auth::user()->id == $post->user_id)) {
            if ($post->markdown) {
                $post->body = $request->body;
            } else {
 	        $post->body = Purifier::clean($request->body);
            }
            $post->save();

            $discussion = Models::discussion()->find($post->chatter_discussion_id);

            $category = Models::category()->find($discussion->chatter_category_id);
            if (!isset($category->slug)) {
                $category = Models::category()->first();
            }

            $chatter_alert = [
                'chatter_alert_type' => 'success',
                'chatter_alert'      => trans('chatter::alert.success.reason.updated_post'),
                ];

            return redirect('/'.config('chatter.routes.home').'/'.config('chatter.routes.discussion').'/'.$category->slug.'/'.$discussion->slug)->with($chatter_alert);
        } else {
            $chatter_alert = [
                'chatter_alert_type' => 'danger',
                'chatter_alert'      => trans('chatter::alert.danger.reason.update_post'),
                ];

            return redirect('/'.config('chatter.routes.home'))->with($chatter_alert);
        }
    }
public function update(Request $request, $id)
    {
        $stripped_tags_body = ['body' => strip_tags($request->body)];
        $validator = Validator::make($stripped_tags_body, [
            'body' => 'required|min:10',
        ],[
			'body.required' => trans('chatter::alert.danger.reason.content_required'),
			'body.min' => trans('chatter::alert.danger.reason.content_min'),
		]);

        if ($validator->fails()) {
            return back()->withErrors($validator)->withInput();
        }

        $post = Models::post()->find($id);
        if (!Auth::guest() && (Auth::user()->id == $post->user_id)) {
            if ($post->markdown) {
                $post->body = $request->body;
            } else {
 	        $post->body = Purifier::clean($request->body);
            }
            $post->save();

            $discussion = Models::discussion()->find($post->chatter_discussion_id);

            $category = Models::category()->find($discussion->chatter_category_id);
            if (!isset($category->slug)) {
                $category = Models::category()->first();
            }

            $chatter_alert = [
                'chatter_alert_type' => 'success',
                'chatter_alert'      => trans('chatter::alert.success.reason.updated_post'),
                ];

            return redirect('/'.config('chatter.routes.home').'/'.config('chatter.routes.discussion').'/'.$category->slug.'/'.$discussion->slug)->with($chatter_alert);
        } else {
            $chatter_alert = [
                'chatter_alert_type' => 'danger',
                'chatter_alert'      => trans('chatter::alert.danger.reason.update_post'),
                ];

            return redirect('/'.config('chatter.routes.home'))->with($chatter_alert);
        }
    }
public function update ( Request $ request , $ id ) { $ stripped_tags_body = [ 'body' => strip_tags ( $ request -> body ) ] ; $ validator = Validator :: make ( $ stripped_tags_body , [ 'body' => 'required|min:10' , ] , [ 'body.required' => trans ( 'chatter::alert.danger.reason.content_required' ) , 'body.min' => trans ( 'chatter::alert.danger.reason.content_min' ) , ] ) ; if ( $ validator -> fails ( ) ) { return back ( ) -> withErrors ( $ validator ) -> withInput ( ) ; } $ post = Models :: post ( ) -> find ( $ id ) ; if ( ! Auth :: guest ( ) && ( Auth :: user ( ) -> id == $ post -> user_id ) ) { if ( $ post -> markdown ) { $ post -> body = $ request -> body ; } else { $ post -> body = Purifier :: clean ( $ request -> body ) ; } $ post -> save ( ) ; $ discussion = Models :: discussion ( ) -> find ( $ post -> chatter_discussion_id ) ; $ category = Models :: category ( ) -> find ( $ discussion -> chatter_category_id ) ; if ( ! isset ( $ category -> slug ) ) { $ category = Models :: category ( ) -> first ( ) ; } $ chatter_alert = [ 'chatter_alert_type' => 'success' , 'chatter_alert' => trans ( 'chatter::alert.success.reason.updated_post' ) , ] ; return redirect ( '/' . config ( 'chatter.routes.home' ) . '/' . config ( 'chatter.routes.discussion' ) . '/' . $ category -> slug . '/' . $ discussion -> slug ) -> with ( $ chatter_alert ) ; } else { $ chatter_alert = [ 'chatter_alert_type' => 'danger' , 'chatter_alert' => trans ( 'chatter::alert.danger.reason.update_post' ) , ] ; return redirect ( '/' . config ( 'chatter.routes.home' ) ) -> with ( $ chatter_alert ) ; } }
Update the specified resource in storage.

@param \Illuminate\Http\Request $request
@param int                      $id

@return \Illuminate\Http\Response
Update the specified resource in storage .