$imagine = new Imagine\Gd\Imagine(); $size = new Imagine\Image\Box(500, 500); $mode = Imagine\Image\ImageInterface::THUMBNAIL_INSET; $imagine->open($file_path)->thumbnail($size, $mode)->save($thumb_path); $data['preview_url'] = $thumb_path; } } } try { Lot::patch($id, $data); $app->flash('success', 'Данные лота обновлены!'); } catch (Exception $e) { // что-то пошло не так $app->flash('error', $e->getMessage()); } $app->redirect($app->urlFor('lots')); }); // удаление лота $app->get('/delete_lot/:id', function ($id) use($app) { $victim = Lot::delete($id); $app->flash('success', 'Лот "' . $victim->title . '" удален!'); $app->redirect($app->urlFor('lots')); })->name('delete_lot'); // порядок лотов $app->post('/lot_order', function () use($app) { $post_data = $app->request->post(); $lot_ids = $post_data['lots']; foreach ($lot_ids as $number => $id) { Lot::patch($id, array('order' => $number)); } })->name('lot_order');