|
|
|
@ -9,33 +9,15 @@ use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
|
|
|
|
class MenuCompanyController extends Controller |
|
|
|
|
{ |
|
|
|
|
// public function add(Request $request) |
|
|
|
|
// { |
|
|
|
|
// $this->validate($request, [ |
|
|
|
|
// 'icon' => 'required', |
|
|
|
|
// 'name' => 'string|required', |
|
|
|
|
// 'url' => 'required|unique:m_company_menu,url', |
|
|
|
|
// 'sequence' => 'required|integer', |
|
|
|
|
// ]); |
|
|
|
|
|
|
|
|
|
// $data = $request->all(); |
|
|
|
|
|
|
|
|
|
// $data['created_by'] = $this->currentName; |
|
|
|
|
|
|
|
|
|
// $result = MenuCompany::create($data); |
|
|
|
|
|
|
|
|
|
// if ($result) { |
|
|
|
|
// return response()->json(['status' => 'success', 'message' => 'add data menu successfully!', 'code' => 200], 200); |
|
|
|
|
// } else { |
|
|
|
|
// return response()->json(['status' => 'failed', 'message' => 'add data menu failed!', 'code' => 400], 400); |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
public function addMultiple(Request $request) |
|
|
|
|
{ |
|
|
|
|
$menus = $request->all(); |
|
|
|
|
|
|
|
|
|
if (is_array($menus) && count($menus) > 0) { |
|
|
|
|
$data = MenuCompany::where('company_id',$menus[0]['company_id']); |
|
|
|
|
if($data){ |
|
|
|
|
$data->delete(); |
|
|
|
|
} |
|
|
|
|
if (is_array($menus) && count($menus) > 0 && isset($menus[0]['menu_id'])) { |
|
|
|
|
$countRes = 0; |
|
|
|
|
foreach ($menus as $menu) { |
|
|
|
|
|
|
|
|
@ -60,12 +42,17 @@ class MenuCompanyController extends Controller
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($countRes > 0) { |
|
|
|
|
return response()->json(['status' => 'success', 'message' => 'add data menu successfully!', 'code' => 200]); |
|
|
|
|
return response()->json(['status' => 'success', 'message' => 'Add data menu successfully!', 'code' => 200]); |
|
|
|
|
} else { |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'add data menu failed created!', 'code' => 400]); |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Add data menu failed created!', 'code' => 500]); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'add data menu failed created!', 'code' => 400]); |
|
|
|
|
if(isset($data)) |
|
|
|
|
{ |
|
|
|
|
return response()->json(['status' => 'success', 'message' => 'Add data menu successfully!', 'code' => 200]); |
|
|
|
|
}else{ |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Add data menu failed created!', 'code' => 500]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -120,15 +107,15 @@ class MenuCompanyController extends Controller
|
|
|
|
|
if ($data) { |
|
|
|
|
$delete = $data->delete(); |
|
|
|
|
} else { |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'data menu not found!', 'code' => 400], 400); |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Data menu not found!', 'code' => 400], 400); |
|
|
|
|
die(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($delete) { |
|
|
|
|
return response()->json(['status' => 'success', 'message' => 'data menu successfully deleted!', 'code' => 200], 200); |
|
|
|
|
return response()->json(['status' => 'success', 'message' => 'Data menu successfully deleted!', 'code' => 200], 200); |
|
|
|
|
} else { |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'data menu failed deleted!', 'code' => 400], 400); |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Data menu failed deleted!', 'code' => 400], 400); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|