public function anyAjax($id, $action, $action_id = null, $cmd = null) { $this->layout = null; $order = Order::find($id); if (!$order) { return '{"status":"error"}'; } switch ($action) { case 'tag': if ($cmd) { if (!DB::table('order_tags_relations')->where('order_id', $id)->where('tag_id', $action_id)->count()) { DB::table('order_tags_relations')->insert(array('order_id' => $id, 'tag_id' => $action_id)); } } else { DB::table('order_tags_relations')->where('order_id', $id)->where('tag_id', $action_id)->delete(); } } return '{"status":"success"}'; }