public function store(RuleStoreListener $listener, array $input, $canBanSelf = false)
    {
        if (empty(array_get($input, 'expired_at'))) {
            $input['expired_at'] = null;
        }

        $rule = new Rule();
        $rule->fill($input);
        $form = $this->presenter->form($rule, $canBanSelf);

        $validationHelper = new ValidationHelper($form, $this->validation->on('create'), $input);

        if (!$validationHelper->isValid()) {
            return $listener->createRuleFailedValidation($validationHelper->getMessageBag());
        }
        try {
            $this->repository->store($rule);
            return $listener->storeRuleSuccess($rule);
        } catch (Exception $e) {
            Log::critical($e->getMessage());
            return $listener->storeRuleFailed(['error' => $e->getMessage()]);
        }
    }
public function store(RuleStoreListener $listener, array $input, $canBanSelf = false)
    {
        if (empty(array_get($input, 'expired_at'))) {
            $input['expired_at'] = null;
        }

        $rule = new Rule();
        $rule->fill($input);
        $form = $this->presenter->form($rule, $canBanSelf);

        $validationHelper = new ValidationHelper($form, $this->validation->on('create'), $input);

        if (!$validationHelper->isValid()) {
            return $listener->createRuleFailedValidation($validationHelper->getMessageBag());
        }
        try {
            $this->repository->store($rule);
            return $listener->storeRuleSuccess($rule);
        } catch (Exception $e) {
            Log::critical($e->getMessage());
            return $listener->storeRuleFailed(['error' => $e->getMessage()]);
        }
    }
public function store ( RuleStoreListener $ listener , array $ input , $ canBanSelf = false ) { if ( empty ( array_get ( $ input , 'expired_at' ) ) ) { $ input [ 'expired_at' ] = null ; } $ rule = new Rule ( ) ; $ rule -> fill ( $ input ) ; $ form = $ this -> presenter -> form ( $ rule , $ canBanSelf ) ; $ validationHelper = new ValidationHelper ( $ form , $ this -> validation -> on ( 'create' ) , $ input ) ; if ( ! $ validationHelper -> isValid ( ) ) { return $ listener -> createRuleFailedValidation ( $ validationHelper -> getMessageBag ( ) ) ; } try { $ this -> repository -> store ( $ rule ) ; return $ listener -> storeRuleSuccess ( $ rule ) ; } catch ( Exception $ e ) { Log :: critical ( $ e -> getMessage ( ) ) ; return $ listener -> storeRuleFailed ( [ 'error' => $ e -> getMessage ( ) ] ) ; } }
Stores the rule in the repository.

@param RuleStoreListener $listener
@param array $input
@param bool $canBanSelf
@return JsonResponse
Stores the rule in the repository .