From 999750996289cac28d45d1f140eadb821daa6f23 Mon Sep 17 00:00:00 2001 From: Libern Date: Tue, 20 Aug 2019 14:48:46 +0800 Subject: [PATCH] Improved repository --- src/Someline/Repository/Controllers/BaseController.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Someline/Repository/Controllers/BaseController.php b/src/Someline/Repository/Controllers/BaseController.php index 1516f0c..ffa41ef 100644 --- a/src/Someline/Repository/Controllers/BaseController.php +++ b/src/Someline/Repository/Controllers/BaseController.php @@ -32,15 +32,22 @@ public function show(Request $request, $id) public function store(Request $request) { $data = $request->all(); + $data = $this->handleData($request, $data); return $this->repository->save($data)->present(); } public function update(Request $request, $id) { $data = $request->all(); + $data = $this->handleData($request, $data, $id); return $this->repository->update($id, $data)->present(); } + protected function handleData(Request $request, $data, $id = null): array + { + return $data; + } + public function destroy(Request $request, $id) { return $this->repository->destroy($id)->present();