Drop delete table related to a model.

@param string $model   Model name to drop
@param string $confirm Confirmation string
431938
public function drop($model, $confirm)
    {
        // exit if no correct confirmation string
        if ($confirm != 'confirm') {
            return;
        }

        //
        $models = $model == '*'
                ? $this->getModels()
                : [$model];

        //
        if (!count($models)) {
            return;
        }

        //
        foreach ($models as $model) {
            $table = $this->getTable($model);

            //
            if (!$table) {
                continue;
            }

            //
            $sql = "DROP TABLE `{$table}`";

            //
            $this->execute($sql);
        }
    }
1368186
protected function deleteAction()
    {
        $deleteConfirm = trans('merchant.delete_confirm');
        $confirm = trans('merchant.confirm');
        $cancel = trans('merchant.cancel');

        $script = <<<SCRIPT

$('.grid-row-delete').unbind('click').click(function() {

    var id = $(this).data('id');

    swal({
      title: "$deleteConfirm",
      type: "warning",
      showCancelButton: true,
      confirmButtonColor: "#DD6B55",
      confirmButtonText: "$confirm",
      closeOnConfirm: false,
      cancelButtonText: "$cancel"
    },
    function(){
        $.ajax({
            method: 'post',
            url: '{$this->getResource()}/' + id,
            data: {
                _method:'delete',
                _token:LA.token,
            },
            success: function (data) {
                $.pjax.reload('#pjax-container');

                if (typeof data === 'object') {
                    if (data.status) {
                        swal(data.message, '', 'success');
                    } else {
                        swal(data.message, '', 'error');
                    }
                }
            }
        });
    });
});

SCRIPT;

        Merchant::script($script);

        return <<<EOT
<a href="javascript:void(0);" data-id="{$this->getKey()}" class="grid-row-delete">
    <i class="fa fa-trash"></i>
</a>
EOT;
    }
182062
protected function view_remove_submission_confirm() {
        global $USER, $DB;

        $userid = optional_param('userid', $USER->id, PARAM_INT);

        if (!$this->can_edit_submission($userid, $USER->id)) {
            print_error('nopermission');
        }
        $user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);

        $o = '';
        $header = new assign_header($this->get_instance(),
                                    $this->get_context(),
                                    false,
                                    $this->get_course_module()->id);
        $o .= $this->get_renderer()->render($header);

        $urlparams = array('id' => $this->get_course_module()->id,
                           'action' => 'removesubmission',
                           'userid' => $userid,
                           'sesskey' => sesskey());
        $confirmurl = new moodle_url('/mod/assign/view.php', $urlparams);

        $urlparams = array('id' => $this->get_course_module()->id,
                           'action' => 'view');
        $cancelurl = new moodle_url('/mod/assign/view.php', $urlparams);

        if ($userid == $USER->id) {
            $confirmstr = get_string('removesubmissionconfirm', 'assign');
        } else {
            $name = $this->fullname($user);
            $confirmstr = get_string('removesubmissionconfirmforstudent', 'assign', $name);
        }
        $o .= $this->get_renderer()->confirm($confirmstr,
                                             $confirmurl,
                                             $cancelurl);
        $o .= $this->view_footer();

        \mod_assign\event\remove_submission_form_viewed::create_from_user($this, $user)->trigger();

        return $o;
    }
369488
protected function shouldCommit(Model $model)
    {
        $state = $model->getState();
        return $model->isDirty() || $state->is('new') || $state->is('deleting');
    }
1158981
public function delete(Identifiable $model)
    {
        // Trigger throw
        $group = $this->groupOfConfig($config);

        if (isset($this->buildConfigs[$group])) {
            unset($this->buildConfigs[$group]);

            return true;
        }

        return false;
    }
827386
public function approve( $model, $notify = true, $config = [] ) {

		if( !$model->isActive( true ) && $model->isApprovable() ) {

			$model = $this->updateStatus( $model, IApproval::STATUS_ACTIVE );

			if( $notify ) {

				$title = ucfirst( self::$parentType ) . ' - ' . $model->getClassName() . ' - Approved';

				$config[ 'template' ] = CoreGlobal::TPL_NOTIFY_STATUS_APPROVE;

				$this->notifyUser( $model, $config, $title );
			}

			return $model;
		}

		return false;
	}
480985
public function delete($model)
    {
        $this->callBeforeListeners('destroy', [$model]);
        $this->model()->remove($model);
        $this->callAfterListeners('destroy', [$model]);
        return $model;
    }
750989
public function remove($model)
    {
        $class    = $this->manager->getClassMetadata(get_class($model));
        $managers = $class->getFieldManagerNames();
        $priority = $this->manager->getPool()->getPriority('transaction');

        foreach ($managers as $key => $managerName) {
            if (isset($priority[$managerName])) {
                $this->manager->remove($model);

                unset($managers[$key]); // dereference index
            }
        }

        foreach ($managers as $managerName) {
            $this->addQueue(self::QUEUE_ACTION_REMOVE, $managerName, $model);
        }
    }
1066878
private function confirmRemoval(
        InputInterface $input,
        OutputInterface $output,
        $countryCode
    ) {
        /**
         * @var QuestionHelper $questionHelper
         */
        $questionHelper = $this->getHelper('question');
        $message = "<question>Country with code '$countryCode' will be dropped. Continue?</question>";

        return $questionHelper->ask(
            $input,
            $output,
            new ConfirmationQuestion($message, false)
        );
    }
1038950
def delete(self, model):
        

        signals.pre_delete.send(model.__class__, model=model)

        param = {'rid_value': self.to_pg(model)[model.rid_field]}
        query = """
                DELETE FROM {table}
                WHERE {rid_field} = %(rid_value)s
                RETURNING {cols};
                """

        query = query.format(
            cols=self.field_cols(model),
            rid_field=model.rid_field,
            table=model.rtype,
        )

        result = self.query(query, param=param)

        signals.post_delete.send(model.__class__, model=model)

        return result
70961
public function cleanup(Model $model) {
        parent::cleanup($model);

        $this->_uploads = array();
        $this->_columns = array();
    }
34704
public static function clearCache($model = null)
    {
        if (is_null($model)) {
            static::$_cache = [];
        } elseif (isset(static::$_cache[$model])) {
            static::$_cache[$model] = [];
        }

        return true;
    }
387356
public function deleted($model)
    {
        if (static::syncingDisabledFor($model)) {
            return;
        }

        if ($this->usesSoftDelete($model) && config('scout.soft_delete', false)) {
            $this->saved($model);
        } else {
            $model->unsearchable();
        }
    }
1116622
public function destroy(Model $model)
    {
        $this->mention->where('model_type', get_class($this->model))
            ->where('model_id', $this->model->getKey())
            ->where('recipient_type', get_class($model))
            ->where('recipient_id', $model->getKey())
            ->delete();
    }
30952
public function beforeDelete(Model $model, $cascade = true) {
        if (empty($model->id)) {
            return false;
        }

        return $this->deleteFiles($model, $model->id, array(), true);
    }
1151694
public function willRemove(AbstractModel $model)
    {
        $key = $model->getCompositeKey();
        return isset($this->removed[$key]);
    }
898864
public function delete($model)
    {
        if ($model->files) {
            $model->files->each(function (File $file) {
                $file->delete();
            });
        }
        if ($model->delete()) {
            return true;
        }

        return false;
    }