Php Laravel请求:BadMethodCallException方法getPath不存在
我试图在请求中添加一些验证,我得到“BadMethodCallException” “方法getPath不存在”错误。我只是在postman中发送空值来测试它。 例如: { “名称”:空 } 这是我的控制器:Php Laravel请求:BadMethodCallException方法getPath不存在,php,laravel,laravel-request,Php,Laravel,Laravel Request,我试图在请求中添加一些验证,我得到“BadMethodCallException” “方法getPath不存在”错误。我只是在postman中发送空值来测试它。 例如: { “名称”:空 } 这是我的控制器: namespace Modules\Settings\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Http\Response; use Illuminate\Routing\Controller; use Il
namespace Modules\Settings\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller;
use Illuminate\Http\JsonResponse;
use Modules\Settings\Repositories\SettingsInterface;
use Modules\Settings\Http\Requests\AddCommunicationType;
class SettingsController extends Controller
{
public function addCommunicationType(AddCommunicationType $request)
{
$data = json_decode(json_encode($request->all()));
$com=$this->settingRepo->addCommunicationType($data);
return response()->json($com);
}
}
AddCommunicationType请求:
namespace Modules\Settings\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class AddCommunicationType extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
'name'=>'required',
];
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
public function messages() {
return [
'name.required' => 'Name is required.',
];
}
}
路线:
Route::post('settings/addCommunicationType', 'SettingsController@addCommunicationType');
作曲家转储自动加载;composer配置:清除并确保您的配置正确namespace@LeoKelmendi试过了,还是一样。你的拉维版本是什么?@DharmaSaputra 5.5.19可能是作曲家dump autoload的副本;composer配置:清除并确保您的配置正确namespace@LeoKelmendi试过还是一样。你的拉维版本是什么?@DharmaSaputra 5.5.19可能是