Monday, February 27, 2017

Internal server error in laravel 5.3

I am trying to validate a form data if it exist in database. I'm using jquery validate plugin.But I am getting the internal server error 500. Here is my validation.js file
$(document).ready(function () {
    $("#test-form").validate({
        rules: {
            projectname:{
                required:true,
                minlength:5,
                remote:{
                    url: '/checkProject',
                    type: "post"
                }
            }
        },
        messages:{
            projectname:{
                required: "Please enter at least 5 character project name!",
                remote:"This project already exist. Please enter a diffrent name!"
            }
        }
    });

});

here is my web.php
Route::post('/checkProject','ProjectController@checkProject');

and controller
public function checkProject(Request $request){
        $RequestedProject = $request->projectname;
        $RegisteredProject = Project::all();
        $flag = "true";
        foreach ($RegisteredProject as $item){
           if( $item['name'] == $RequestedProject){
               $flag = "false";
               break;
           }
        }
        echo $flag;
    }

what is the problem


via Mutasim Fuad

Advertisement