function updateProcess($id)
{
    $update = Request::get('update');
    $valid = Validator::make(array('update.title' => 'required|min:1|slashes', 'update.parentid' => 'slashes'));
    if (!$valid) {
        throw new Exception("Error Processing Request: " . Validator::getMessage());
    }
    if (Request::hasFile('image')) {
        if (Request::isImage('image')) {
            $update['image'] = File::upload('image');
            $loadData = Categories::get(array('where' => "where catid='{$id}'"));
            if (isset($loadData[0]['catid'])) {
                File::remove($loadData[0]['image']);
            }
        }
    }
    Categories::update($id, $update);
}
示例#2
0
$_method = $_SERVER['REQUEST_METHOD'];
// var_dump("expression");
// var_dump($_POST);
// $_POST=json_decode($_POST);
// var_dump($_POST);
if ($_method == 'POST') {
    if (isset($_POST['_method'])) {
        if ($_POST['_method'] == 'put') {
            $cat = new Categories($_GET['id']);
            // var_dump($_GET['id']);
            $cat->id = $_GET['id'];
            $cat->number = $_POST['number'];
            $cat->name = $_POST['name'];
            $cat->des = $_POST['des'];
            $cat->parent = $_POST['parent'];
            $cat->update();
        } else {
            if ($_POST['_method'] == 'delete') {
                $cat = new Categories($_GET['id']);
                $cat->delete();
                $rest = new categories_server();
                $rest->handle_response('Deleted', 400);
                // $response['data'] = 'Deleted';
                // $response['status'] = 'Bad Request';
                // $json_response = json_encode($response);
                // echo $json_response;
            }
        }
    } else {
        //insert action
        var_dump($_POST);
function categories_edit_form_submit($data)
{
    $data['church_id'] = $_SESSION['log_church_id'];
    $error = categories_validate($data);
    if (!empty($error)) {
        return FALSE;
    } else {
        $categories = new Categories();
        $update = $categories->update($data);
        if ($update['code'] == 200) {
            return categories_list($data['id']);
        }
    }
}