public function delete($id = null)
    {
        $this->request->allowMethod(['post', 'delete']);

        $position = $this->BannersPositions->get($id);

        //Before deleting, it checks if the position has some banners
        if (!$position->banner_count) {
            $this->BannersPositions->deleteOrFail($position);
            $this->Flash->success(I18N_OPERATION_OK);
        } else {
            $this->Flash->alert(I18N_BEFORE_DELETE);
        }

        return $this->redirect(['action' => 'index']);
    }
public function delete($id = null)
    {
        $this->request->allowMethod(['post', 'delete']);

        $position = $this->BannersPositions->get($id);

        //Before deleting, it checks if the position has some banners
        if (!$position->banner_count) {
            $this->BannersPositions->deleteOrFail($position);
            $this->Flash->success(I18N_OPERATION_OK);
        } else {
            $this->Flash->alert(I18N_BEFORE_DELETE);
        }

        return $this->redirect(['action' => 'index']);
    }
public function delete ( $ id = null ) { $ this -> request -> allowMethod ( [ 'post' , 'delete' ] ) ; $ position = $ this -> BannersPositions -> get ( $ id ) ; //Before deleting, it checks if the position has some banners if ( ! $ position -> banner_count ) { $ this -> BannersPositions -> deleteOrFail ( $ position ) ; $ this -> Flash -> success ( I18N_OPERATION_OK ) ; } else { $ this -> Flash -> alert ( I18N_BEFORE_DELETE ) ; } return $ this -> redirect ( [ 'action' => 'index' ] ) ; }
Deletes banners position
@param string $id Banners Position ID
@return \Cake\Network\Response|null
Deletes banners position