$attributes = ['name' => $name, 'category_id' => $category, 'price' => $price, 'slug' => $slug]; $album = new albums(); $album->atualizar($id, $attributes); $app->flash('sucesso', 'Categoria alterada com sucesso !'); $app->redirect('/admin/albums'); } }); $app->post('/admin/albums/delete/:id', function ($id) use($app) { $albums = new albums(); $images = new images(); $imageCadastrada = images::where('album_id', $id); if (count($imageCadastrada) > 0) { $app->flash('erro', 'Este álbum possui fotos cadastradas'); $app->redirect('/admin/albums'); } else { $albums->deletar($id); $app->flash('sucesso', 'Álbum deletado com sucesso !'); $app->redirect('/admin/albums'); } }); $app->post('/admin/albums/cover/:id', function () use($app) { $id = $app->request()->post('album-id'); $foto = $_FILES['foto']['name']; $temp_foto = $_FILES['foto']['tmp_name']; $extensoes_permitidas = array('jpg', 'jpeg', 'png'); if (empty($foto)) { $app->flash('mensagem', '<div class="alert alert-danger">Escolha uma foto.</div>'); $app->redirect('/admin/albums'); } else { $isImage = cover::isImage($foto); if ($isImage) {