laravel报错405响应码,怎么解决?
Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException: The GET method is not supported for this route. Supported methods: POST. in file D:\phpstudy_pro\WWW\wy\vendor\laravel\framework\src\Illuminate\Routing\RouteCollection.php on line 256
报错路由问题,路由请求方式是对的,跑接口请求一段时间后就报错
Route::post('/people_import', 'PeopleController@import')->name('导入');
public function collection(Collection $rows)
{
$admin = (new BaseService())->getThisAdmin(request()->token);
unset($rows[0]);
$images = $this->getImages();
$file = '';
$village_id = $admin->village_id;
$village = VillageList::where('id', $village_id)->first();
$insertUrl = config('myconfig.domain') . '/api/admin/wuye/addUser';
foreach ($rows as $row) {
$check = PeopleList::with('hpds')->where('people_tel', $row[1])->first();
// 所属房屋,房屋里会包含该房屋所属栋数
$hpd = HpdList::query()->where('hpd_name', $row[5])->first();
if (is_null($check)) {
if (isset($images[$row[2]])) {
$up = new UpMyFile();
$res = json_decode($up->ToFileOSS($images[$row[2]], '临时'), true);
if ($res['code'] == 200) {
$file = $res['data'];
// 移动人脸
$url = config('myconfig.domain') . '/api/admin/wuye/moveface';
$res = json_decode(curl($url, [
'img' => $file,
'name' => $row[1] . $row[0] . '_0',
'path' => 'people/' . $village->village_name
]), true);
if ($res['code'] == 200) {
$file = $res['data'];
} else {
$file = '';
}
}
}
$arr = [
'village_id' => $village_id,
'village_name' => $village->village_name,
'people_name' => $row[0],
'people_tel' => $row[1],
'people_type' => $row[3],
'people_id_no' => isset($row[4]) ? $row[4] : '',
'people_image' => $file,
'people_add_time' => date('Y-m-d H:i:s')
];
$people = PeopleList::create($arr);
if (!is_null($hpd)) {
SyncData::dispatch($people, $hpd->id, $hpd->arch_id);
// 关联房屋
/*$people->hpds()->sync($hpd->id);
// 关联栋数
$people->archs()->sync($hpd->arch_id);*/
}
$insert = $arr;
$insert['area'] = $village->village_no;
// AddUser::dispatch($insert, $insertUrl);
} else {
$archIds = [];
$hpdIds = [];
if (empty($check->toArray()['hpds'])) {
SyncData::dispatch($check, $hpd->id, $hpd->arch_id);
} else {
foreach ($check->toArray()['hpds'] as $v) {
// 没有该房屋关联
if ($row[5] != $v['hpd_name']) {
$hpdIds[] = $v['hpd_id']; // 已有房屋的id
if (!is_null($hpd)) {
$hpdIds[] = $hpd->id; // 新的房屋id
}
$archIds[] = $v['arch_id']; // 栋数id
}
}
if (!empty($archIds) && !empty($hpdIds)) {
SyncData::dispatch($check, $hpdIds, $archIds);
}
}
}
}
}
推荐文章: