我收到内部错误
in AdminController.php line 85
at HandleExceptions->handleError('8', 'Undefined index: name', 'C:\wamp64\www\laravel\dev.oasis-portal.my\app\Http\Controllers\AdminController.php', '85', array('data' => array())) in AdminController.php line 85
当我跑
时public function courseDelete()
{
$data = Input::all();
$student = Course::where('name', '=', $data["name"]);
if($student->delete()) {
User::find($data["name"])->delete();
return json_encode(array('success' => true));
} else {
return json_encode(array('success' => false, 'errors' => "Unable to remove student."));
}
}
我的路线是:Route :: get('/ course / delete /','AdminController @ courseDelete');
答案 0 :(得分:0)
$data["name"]
未设置,因此抛出异常。更好的解决方案是使用request()
简写:
即。 request()->get('name'); //will return null if not set