When I save() the “AppPost” returns the 500 error

Welcome to Programming Tutorial official website. Today - we are going to cover how to solve / find the solution of this error When I save() the “AppPost” returns the 500 error on this date .

Well, i got some very strange error, this very simple code returns the 500 error.


namespace AppHttpControllers;

use AppUser;
use AppComment;
use IlluminateHttpRequest;
use IlluminateHttpResponse;
use IlluminateSupportFacadesDB;
use IlluminateSupportFacadesAuth;
use IlluminateSupportFacadesStorage;
use AppHttpControllersController;

class CommentController extends Controller

   public function NewComment(Request $request) {
     $cText = $request->commentText;

     $comment = new Comment;
     $comment->author_id = Auth::user()->id;
     $comment->current_text = $cText;
     return $comment;

When I comment the $comment->save(); Returns:

  author_id: 1
  current_text: "fsdfdfd"

OBS: “fsdfdfd” is the text I typed in the <‘textarea’> in the page.

As you can see returns the object normally, but when I try to save returns the error:

500 (Internal Server Error)

Migration file of the Comments:

Schema::create('comments', function (Blueprint $table) {
        $table->enum('edited', ['yes','no'])->default('no');
        $table->string('history', 8000);



namespace App;

use IlluminateDatabaseEloquentModel;

class Comment extends Model
    protected $fillable = [

    protected $guarded = [

    function author(){
      return $this->belongsTo('AppUser');


I found what was wrong!!

The error was before any of those scripts, was in the AJAX function. The object that was sending the data, was something like this:

var objectComment = {
  'commentText': textComment

Because of it, I was getting a json like this in my php file:

{'commentText : Lorem ipsun' : null}

And was trying to get some value through this… #facepalm

Other thing that was wrong, is that i forget to configure the CSRF Token, it was disturbing the data sending and helping to drive me crazy a little more.

Hope I could help some of you with this error caused by a little daydream 🙂