无法从数据库中删除记录。它说找不到资源。
服务:
public function delete(Location $location): Location
{
if ($this->deleteById($location->id)) {
return $location;
}
}
控制器:
public function destroy(Location $location) {
$this->locationService->delete($location);
return redirect()->route('admin.location.index');
}
我存储它的方式就是这种方式。其中一些数据来自通过JS脚本存储的Google地图
服务:
public function store(array $data = []): Location
{
DB::beginTransaction();
try {
$location = $this->createLocation([
'name' => $data['name'],
'address_latitude' => $data['address_latitude'],
'address_longitude' => $data['address_longitude'],
]);
} catch (Exception $e) {
DB::rollBack();
throw new GeneralException(__('There was a problem creating this resource. Please try again.'));
}
DB::commit();
return $location;
}
控制器:
public function store(Request $request) {
$location = $this->locationService->store($request->all());
return redirect()->route('admin.location.index', $location)->withFlashSuccess(__('The location was successfully added.'));
}
答案 0 :(得分:0)
public function destroy(Location $location) {
$location->delete();
return redirect()->route('admin.location.index');
}