laravel错误不允许序列化'Closure'

I am facing below error in controller on return statement

Serialization of 'Closure' is not allowed

Checked with different ideas from google search, but still not able to fix it.

public static function user_apply_job($jobid)
{
    if (Auth::check()) {
        $authid = Auth::id();
        //Check valid total credits
        $total_credits = 0;   //Initializing variable
        $total_credits = PostsController::get_allcredits();

        $message = "Total Credits are" . $total_credits;
        echo "<script type='text/javascript'>alert('$message');</script>";

        if (($total_credits - 4) < 0) {
            return view('users.buycredits_prof');
        }
        .....
    }
}

Unable to fix this serialization error. Please do help to fix this.