Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 500内部服务器错误ajax/laravel_Php_Laravel - Fatal编程技术网

Php 500内部服务器错误ajax/laravel

Php 500内部服务器错误ajax/laravel,php,laravel,Php,Laravel,因此,我试图创建一个动态评论部分,但这个问题似乎困扰我500内部服务器错误。我读过一些关于这个问题的文章,但我无法解决它。我使用了一些代码片段来查找问题,但仍然找不到问题所在 create.blade.php- <h1>Create comment</h1> {!! Form::open(['id' => 'myForm', 'enctype' => 'multipart/form-data']) !!} <div class="form-group"

因此,我试图创建一个动态评论部分,但这个问题似乎困扰我500内部服务器错误。我读过一些关于这个问题的文章,但我无法解决它。我使用了一些代码片段来查找问题,但仍然找不到问题所在

create.blade.php-

<h1>Create comment</h1>
{!! Form::open(['id' => 'myForm',  'enctype' => 'multipart/form-data']) !!}
<div class="form-group">
    {{ Form::textarea('body', '', ['class' => 'form-control', 'id' => 'article-ckeditor', 'placeholder' => 'Share your thoughts related to this post']) }}
</div>
{{ Form::hidden('post_id', $post->id) }}
{{Form::submit('Submit', ['class' => 'btn btn-primary', 'id' => 'submitComment'])}}
{!! Form::close() !!}
CommentsController@store-

public function store(Request $request)
{

    $validator = Validator::make($request->all(), [
        'body' => 'required'
    ]);

    if ($validator->fails()) {

        if($request->ajax())
        {
            return response()->json(array(
                'success' => false,
                'message' => 'There are incorect values in the form!',
                'errors' => $validator->getMessageBag()->toArray()
            ), 422);
        }
        $this->throwValidationException(

            $request, $validator

        );
    }

    // Create Post
    $comment = new Comment;

    $comment->body = $request->body;
    $comment->user_name = auth()->user()->name;
    $comment->post_id = $request->post_id;
    $comment->profile_picture = auth()->user()->profile_picture;

    $comment->save();

    return response()->json(['success'=>'Data is successfully added']);
    //return redirect()->back()->with('success', 'Comment Created');

检查错误日志以了解实际错误及其位置thrown@Nikola请发布你的错误。。。并检查您的laravel或更深入地挖掘服务器日志。。。
Route::resource('/comments', 'CommentsController');
public function store(Request $request)
{

    $validator = Validator::make($request->all(), [
        'body' => 'required'
    ]);

    if ($validator->fails()) {

        if($request->ajax())
        {
            return response()->json(array(
                'success' => false,
                'message' => 'There are incorect values in the form!',
                'errors' => $validator->getMessageBag()->toArray()
            ), 422);
        }
        $this->throwValidationException(

            $request, $validator

        );
    }

    // Create Post
    $comment = new Comment;

    $comment->body = $request->body;
    $comment->user_name = auth()->user()->name;
    $comment->post_id = $request->post_id;
    $comment->profile_picture = auth()->user()->profile_picture;

    $comment->save();

    return response()->json(['success'=>'Data is successfully added']);
    //return redirect()->back()->with('success', 'Comment Created');