Пример #1
0
 public function setupDel(Request $request)
 {
     $validator = Validator::make($request->all(), ['table' => 'required', 'id' => 'required']);
     if ($validator->fails()) {
         return 'false';
     } else {
         switch (strtolower($request->get('table'))) {
             case 'cate':
                 SetupCate::find($request->get('id'))->delete();
                 SetupKind::where('idCate', $request->get('id'))->delete();
                 SetupValue::where('idCate', $request->get('id'))->delete();
                 break;
             case 'kind':
                 SetupKind::find($request->get('id'))->delete();
                 SetupValue::where('idKind', $request->get('id'))->delete();
                 break;
             case 'value':
                 SetupValue::find($request->get('id'))->delete();
                 break;
         }
         return $request->get('id');
     }
 }
Пример #2
0
 public function setupDel(Request $request)
 {
     $validator = Validator::make($request->all(), ['table' => 'required', 'id' => 'required']);
     if ($validator->fails()) {
         return 'false';
     } else {
         switch (strtolower($request->get('table'))) {
             case 'cate':
                 SetupCate::find($request->get('id'))->delete();
                 SetupKind::where('idCate', $request->get('id'))->delete();
                 SetupValue::where('idCate', $request->get('id'))->delete();
                 break;
             case 'kind':
                 SetupKind::find($request->get('id'))->delete();
                 SetupValue::where('idKind', $request->get('id'))->delete();
                 break;
             case 'value':
                 SetupValue::find($request->get('id'))->delete();
                 break;
         }
         $log = new Log();
         $log->memberId = Auth::user()->id;
         $log->detail = 'Delete Setup table = ' . strtolower($request->get('table')) . ', id =' . trim($request->get('id'));
         $log->save();
         return $request->get('id');
     }
 }