Commit 45aadf57 by Aan Choesni Herlingga

jika sudah ada berita kategori tidak bisa dihapus

parent f8a698ff
......@@ -2,10 +2,10 @@
namespace App\Http\Controllers\Webprofile\Backend;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Repositories\Webprofile\CategoryRepository;
use App\Repositories\Webprofile\En\CategoryRepository as EnCategoryRepository;
use Illuminate\Http\Request;
use Statickidz\GoogleTranslate;
class CategoryController extends Controller
......@@ -53,8 +53,6 @@ class CategoryController extends Controller
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
......@@ -113,7 +111,6 @@ class CategoryController extends Controller
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
*
* @return \Illuminate\Http\Response
......@@ -149,12 +146,15 @@ class CategoryController extends Controller
*/
public function destroy($id)
{
$data = $this->repo->findId($id, ['rEn']);
$data = $this->repo->findId($id, ['rEn', 'berita']);
if (!$data->berita) {
$this->repo->destroy($data);
if ($data->rEn) {
$this->repoEn->destroy($data->rEn);
}
}
return response()->json(['done']);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment