コード例 #1
0
ファイル: HomeController.php プロジェクト: bitqiu/DataTables
 /**
  * ajax 删除数据
  *
  * @param $id
  */
 function postDel(Request $request)
 {
     Data::find($request->input('id'))->delete();
 }
コード例 #2
0
ファイル: DataController.php プロジェクト: ThapaMahesh/locker
 public function postUpdate(Request $request)
 {
     try {
         $id = $request->input('id');
         $accountInfo = Data::find($id);
         if ($accountInfo) {
             if ($request->input('username') != "") {
                 $accountInfo->username = $request->input('username');
             }
             if ($request->input('password') != "") {
                 $accountInfo->password = $request->input('password');
             }
             $accountInfo->save();
             return ['message' => 'Success!!', 'data' => $accountInfo, 'code' => '200'];
         }
         return ['message' => 'Invalid Request!!', 'data' => '', 'code' => '401'];
     } catch (\Exception $e) {
         return ['message' => 'Invalid Request!!', 'data' => $e->getMessage(), 'code' => '401'];
     }
 }