protected function isModelDeletable(Model $model)
    {
        $this->lastUnmetDeleteConditionMessage = null;

        // access rights
        if ( ! $this->isAuthorizedToDelete()) {
            $this->lastUnmetDeleteConditionMessage = $this->getUnmetConditionMessageForAuthorizationFailure();
            return false;
        }

        // delete condition & model configuration
        $info = $this->getModelInformation();

        if ( ! $info->allowDelete()) {
            $this->lastUnmetDeleteConditionMessage = $this->getUnmetConditionMessageForDisallowedFailure();
            return false;
        }

        $condition = $info->deleteCondition();

        if ( ! $condition) {
            return true;
        }

        // Resolve condition and check.
        $strategies = $this->interpretDeleteCondition($condition);

        foreach ($strategies as $strategy => $parameters) {

            /** @var DeleteConditionStrategyFactoryInterface $factory */
            $factory = app(DeleteConditionStrategyFactoryInterface::class);
            $strategy = $factory->make($strategy);

            if ( ! $strategy->check($model, $parameters)) {
                $this->lastUnmetDeleteConditionMessage = $strategy->message();
                return false;
            }
        }

        return true;
    }
protected function isModelDeletable(Model $model)
    {
        $this->lastUnmetDeleteConditionMessage = null;

        // access rights
        if ( ! $this->isAuthorizedToDelete()) {
            $this->lastUnmetDeleteConditionMessage = $this->getUnmetConditionMessageForAuthorizationFailure();
            return false;
        }

        // delete condition & model configuration
        $info = $this->getModelInformation();

        if ( ! $info->allowDelete()) {
            $this->lastUnmetDeleteConditionMessage = $this->getUnmetConditionMessageForDisallowedFailure();
            return false;
        }

        $condition = $info->deleteCondition();

        if ( ! $condition) {
            return true;
        }

        // Resolve condition and check.
        $strategies = $this->interpretDeleteCondition($condition);

        foreach ($strategies as $strategy => $parameters) {

            /** @var DeleteConditionStrategyFactoryInterface $factory */
            $factory = app(DeleteConditionStrategyFactoryInterface::class);
            $strategy = $factory->make($strategy);

            if ( ! $strategy->check($model, $parameters)) {
                $this->lastUnmetDeleteConditionMessage = $strategy->message();
                return false;
            }
        }

        return true;
    }
protected function isModelDeletable ( Model $ model ) { $ this -> lastUnmetDeleteConditionMessage = null ; // access rights if ( ! $ this -> isAuthorizedToDelete ( ) ) { $ this -> lastUnmetDeleteConditionMessage = $ this -> getUnmetConditionMessageForAuthorizationFailure ( ) ; return false ; } // delete condition & model configuration $ info = $ this -> getModelInformation ( ) ; if ( ! $ info -> allowDelete ( ) ) { $ this -> lastUnmetDeleteConditionMessage = $ this -> getUnmetConditionMessageForDisallowedFailure ( ) ; return false ; } $ condition = $ info -> deleteCondition ( ) ; if ( ! $ condition ) { return true ; } // Resolve condition and check. $ strategies = $ this -> interpretDeleteCondition ( $ condition ) ; foreach ( $ strategies as $ strategy => $ parameters ) { /** @var DeleteConditionStrategyFactoryInterface $factory */ $ factory = app ( DeleteConditionStrategyFactoryInterface :: class ) ; $ strategy = $ factory -> make ( $ strategy ) ; if ( ! $ strategy -> check ( $ model , $ parameters ) ) { $ this -> lastUnmetDeleteConditionMessage = $ strategy -> message ( ) ; return false ; } } return true ; }
Returns whether a given model may be deleted.

@param Model $model
@return bool
Returns whether a given model may be deleted .