<?php

namespace App\Http\Controllers;

use App\Post;
use App\Facades\PostProcessor;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Auth;

class PostController extends Controller
{
    public function newPost(Request $request)
    {
        // Ensure

        // Collect input
        $threadid = $request->input('thread', 0);
        $content = $request->input('body', '');
        if (($content == '') || ($threadid == 0)) {
            abort(400); // 400 Bad Request
        }

        // Run post through filters
        $content = PostProcessor::preProcess($content);

        // Create new post
        $post = Post::newPost($content, $threadid);

        // Generate response
        $resp = new Response(
            json_encode([
                'status' => true,
                'html' => $post->getPostView()->render() // return html of post so it can be embeded into page
            ]),
            200 // 200 OK
        );
        $resp->header('Content-Type', 'application/json');

        return $resp;
    }
}

<?php

namespace App\Http\Controllers;

use App\Post;
use App\Facades\PostProcessor;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Auth;

class PostController extends Controller
{
    public function newPost(Request $request)
    {
        // Validate input
        $this->validate($request, [
            'thread' => 'numeric|exists:threads,id',
            'body' => 'string|min:1|max:2000'
        ]);

        // Collect input
        $threadid = $request->input('thread', 0);
        $content = $request->input('body', '');
        if (($content == '') || ($threadid == 0)) {
            abort(400); // 400 Bad Request
        }

        // Run post through filters
        $content = PostProcessor::preProcess($content);

        // Create new post
        $post = Post::newPost($content, $threadid);

        // Generate response
        $resp = new Response(
            json_encode([
                'status' => true,
                'html' => $post->getPostView()->render() // return html of post so it can be embeded into page
            ]),
            200 // 200 OK
        );
        $resp->header('Content-Type', 'application/json');

        return $resp;
    }
}

Add form validation for forum posts.
Add form validation for forum posts.
