src/Validation.php
public function validate($operation, $model)
    {
        $model = is_array($model) ? $model : $model->getAttributes();

        $rules = $this->model->rules($operation == 'update' ? array_keys($model) : null, $operation);

        $rules = $this->interpolateValidationRules($rules, $model);

        $validator = Validator::make($model, $rules);

        $messages = [];

        if ($validator->fails()) {
            $messages = $validator->messages()->all();
        }

        // Perform other validations
        foreach ($this->validations as $validationMethod) {
            if ($message = $this->{$validationMethod}($model)) {
                $messages[] = $message;
            }
        }

        if (count($messages)) {
            throw App::make('sedp-mis.base-repository.validationException', $messages);
        }
    }
public function validate($operation, $model)
    {
        $model = is_array($model) ? $model : $model->getAttributes();

        $rules = $this->model->rules($operation == 'update' ? array_keys($model) : null, $operation);

        $rules = $this->interpolateValidationRules($rules, $model);

        $validator = Validator::make($model, $rules);

        $messages = [];

        if ($validator->fails()) {
            $messages = $validator->messages()->all();
        }

        // Perform other validations
        foreach ($this->validations as $validationMethod) {
            if ($message = $this->{$validationMethod}($model)) {
                $messages[] = $message;
            }
        }

        if (count($messages)) {
            throw App::make('sedp-mis.base-repository.validationException', $messages);
        }
    }
public function validate ( $ operation , $ model ) { $ model = is_array ( $ model ) ? $ model : $ model -> getAttributes ( ) ; $ rules = $ this -> model -> rules ( $ operation == 'update' ? array_keys ( $ model ) : null , $ operation ) ; $ rules = $ this -> interpolateValidationRules ( $ rules , $ model ) ; $ validator = Validator :: make ( $ model , $ rules ) ; $ messages = [ ] ; if ( $ validator -> fails ( ) ) { $ messages = $ validator -> messages ( ) -> all ( ) ; } // Perform other validations foreach ( $ this -> validations as $ validationMethod ) { if ( $ message = $ this -> { $ validationMethod } ( $ model ) ) { $ messages [ ] = $ message ; } } if ( count ( $ messages ) ) { throw App :: make ( 'sedp-mis.base-repository.validationException' , $ messages ) ; } }
Validate model attributes before saving.
Throw an exception when validation fails.

@param  string  $operation
@param  array|\Illuminate\Database\Eloquent\Model $model
@throws \Exception
@return void
Validate model attributes before saving . Throw an exception when validation fails .