Есть страница в админке Код (Text): <!-- Content Header (Page header) --> <section class="content-header"> <h1> Список товаров </h1> <ol class="breadcrumb"> <li><a href="<?=ADMIN;?>"><i class="fa fa-dashboard"></i> Главная</a></li> <li class="active">Список товаров</li> </ol> </section> <!-- Main content --> <section class="content"> <div class="row"> <div class="col-md-12"> <div class="box"> <div class="box-body"> <div class="text-center"> <?php if($pagination->countPages > 1): ?> <?=$pagination;?> <?php endif; ?> <p>(<?=count($products);?> məhsul <?=$count;?>)</p> </div> <div class="table-responsive"> <table class="table table-bordered table-hover"> <thead> <tr> <th><a href="<?=ADMIN;?>/product/id">ID</a><a href="<?=ADMIN;?>/product/idb"> <i class="fa fa-fw fa-unsorted"></i></a></th> <th><a href="<?=ADMIN;?>/product/cat">Категория</a></th> <th><a href="<?=ADMIN;?>/product/index" class="active">Наименование</a></th> <th><a href="<?=ADMIN;?>/product/market">Маркет</a></th> <th><a href="<?=ADMIN;?>/product/aksiya">Срок Акции</a></th> <th>Фото</th> <th>Цена</th> <th><a href="<?=ADMIN;?>/product/status">Статус</a></th> <th>Действия</th> </tr> </thead> <tbody> <?php foreach($products as $product): ?> <tr> <td><?=$product['id'];?></td> <td><?=$product['cat'];?></td> <td><?=$product['title'];?></td> <td><?=$product['description'];?></td> <td><?=$product['keywords'];?></td> <td><img class="img-responsive zoom-img" width="60px" src="/images/<?=$product['img'];?>"</td> <td><?=$product['price'];?></td> <td><?=$product['status'] ? 'On' : 'Off';?> <input type="checkbox" name="status"<?=$product['status'] ? ' checked' : null;?>></td> <td><a href="<?=ADMIN;?>/product/edit?id=<?=$product['id'];?>" target="_blank"><i class="fa fa-fw fa-eye"></i></a> <a class="delete" href="<?=ADMIN;?>/product/delete?id=<?=$product['id'];?>"><i class="fa fa-fw fa-close text-danger"></i></a></td> </tr> <?php endforeach; ?> </tbody> </table> </div> <div class="text-right"> <form action="<?=ADMIN;?>/product/check?id=<?=$product['id'];?>" method="post"> <button type="submit" class="btn btn-success">Сохранить</button> </div> <div class="text-center"> <p>(<?=count($products);?> məhsul <?=$count;?>)</p> <?php if($pagination->countPages > 1): ?> <?=$pagination;?> <?php endif; ?> </div> </div> </div> </div> </div> </section> <!-- /.content --> выглядит так я добавил чекбоксы и кнопку сохранить А вот что написать в контроллере я не знаю Код контроллера Код (Text): <?php namespace app\controllers\admin; use app\models\admin\Product; use app\models\AppModel; use ishop\App; use ishop\libs\Pagination; class ProductController extends AppController { public function indexAction(){ $page = isset($_GET['page']) ? (int)$_GET['page'] : 1; $perpage = 1000; $count = \R::count('product'); $pagination = new Pagination($page, $perpage, $count); $start = $pagination->getStart(); $products = \R::getAll("SELECT product.*, category.title AS cat FROM product JOIN category ON category.id = product.category_id ORDER BY product.title LIMIT $start, $perpage"); $this->setMeta('Список товаров'); $this->set(compact('products', 'pagination', 'count')); } public function addImageAction(){ if(isset($_GET['upload'])){ if($_POST['name'] == 'single'){ $wmax = App::$app->getProperty('img_width'); $hmax = App::$app->getProperty('img_height'); }else{ $wmax = App::$app->getProperty('gallery_width'); $hmax = App::$app->getProperty('gallery_height'); } $name = $_POST['name']; $product = new Product(); $product->uploadImg($name, $wmax, $hmax); } } public function editAction(){ if(!empty($_POST)){ $id = $this->getRequestID(false); $product = new Product(); $data = $_POST; $product->load($data); $product->attributes['status'] = $product->attributes['status'] ? '1' : '0'; $product->attributes['hit'] = $product->attributes['hit'] ? '1' : '0'; $product->getImg(); if(!$product->validate($data)){ $product->getErrors(); redirect(); } if($product->update('product', $id)){ $product->editFilter($id, $data); $product->editRelatedProduct($id, $data); $product->saveGallery($id); $alias = AppModel::createAlias('product', 'alias', $data['title'], $id); $product = \R::load('product', $id); $product->alias = $alias; \R::store($product); $_SESSION['success'] = 'Изменения сохранены'; redirect(); } } $id = $this->getRequestID(); $product = \R::load('product', $id); App::$app->setProperty('parent_id', $product->category_id); $filter = \R::getCol('SELECT attr_id FROM attribute_product WHERE product_id = ?', [$id]); $related_product = \R::getAll("SELECT related_product.related_id, product.title FROM related_product JOIN product ON product.id = related_product.related_id WHERE related_product.product_id = ?", [$id]); $gallery = \R::getCol('SELECT img FROM gallery WHERE product_id = ?', [$id]); $this->setMeta("Редактирование товара {$product->title}"); $this->set(compact('product', 'filter', 'related_product', 'gallery')); } public function addAction(){ if(!empty($_POST)){ $product = new Product(); $data = $_POST; $product->load($data); $product->attributes['status'] = $product->attributes['status'] ? '1' : '0'; $product->attributes['hit'] = $product->attributes['hit'] ? '1' : '0'; $product->getImg(); if(!$product->validate($data)){ $product->getErrors(); $_SESSION['form_data'] = $data; redirect(); } if($id = $product->save('product')){ $product->saveGallery($id); $alias = AppModel::createAlias('product', 'alias', $data['title'], $id); $p = \R::load('product', $id); $p->alias = $alias; \R::store($p); $product->editFilter($id, $data); $product->editRelatedProduct($id, $data); $_SESSION['success'] = 'Товар добавлен'; } redirect(); } $this->setMeta('Новый товар'); } public function deleteAction(){ $id = $this->getRequestID(); $product = \R::load('product', $id); \R::trash($product); $_SESSION['success'] = 'Товар удален'; redirect(); } public function relatedProductAction(){ /*$data = [ 'items' => [ [ 'id' => 1, 'text' => 'Товар 1', ], [ 'id' => 2, 'text' => 'Товар 2', ], ] ];*/ $q = isset($_GET['q']) ? $_GET['q'] : ''; $data['items'] = []; $products = \R::getAssoc('SELECT id, title FROM product WHERE title LIKE ? LIMIT 10', ["%{$q}%"]); if($products){ $i = 0; foreach($products as $id => $title){ $data['items'][$i]['id'] = $id; $data['items'][$i]['text'] = $title; $i++; } } echo json_encode($data); die; } public function deleteGalleryAction(){ $id = isset($_POST['id']) ? $_POST['id'] : null; $src = isset($_POST['src']) ? $_POST['src'] : null; if(!$id || !$src){ return; } if(\R::exec("DELETE FROM gallery WHERE product_id = ? AND img = ?", [$id, $src])){ @unlink(WWW . "/images/$src"); exit('1'); } return; } }