protected function validateRelation($model, $relation)
    {
        $class = get_class($model);
        if (!method_exists($model, $relation)) {
            DB::rollBack(); //Rollback the transaction before throw exception
            throw new \LogicException(sprintf('%s does not have method \'%s\'.', $class, $relation));
        }

        if (!$model->$relation() instanceof \Illuminate\Database\Eloquent\Relations\Relation) {
            DB::rollBack(); //Rollback the transaction before throw exception
            throw new \LogicException(sprintf('%s \'%s\' is not an instance of Illuminate\Database\Eloquent\Relations\Relation.', $class, $relation));
        }
    }
protected function validateRelation($model, $relation)
    {
        $class = get_class($model);
        if (!method_exists($model, $relation)) {
            DB::rollBack(); //Rollback the transaction before throw exception
            throw new \LogicException(sprintf('%s does not have method \'%s\'.', $class, $relation));
        }

        if (!$model->$relation() instanceof \Illuminate\Database\Eloquent\Relations\Relation) {
            DB::rollBack(); //Rollback the transaction before throw exception
            throw new \LogicException(sprintf('%s \'%s\' is not an instance of Illuminate\Database\Eloquent\Relations\Relation.', $class, $relation));
        }
    }
protected function validateRelation ( $ model , $ relation ) { $ class = get_class ( $ model ) ; if ( ! method_exists ( $ model , $ relation ) ) { DB :: rollBack ( ) ; //Rollback the transaction before throw exception throw new \ LogicException ( sprintf ( '%s does not have method \'%s\'.' , $ class , $ relation ) ) ; } if ( ! $ model -> $ relation ( ) instanceof \ Illuminate \ Database \ Eloquent \ Relations \ Relation ) { DB :: rollBack ( ) ; //Rollback the transaction before throw exception throw new \ LogicException ( sprintf ( '%s \'%s\' is not an instance of Illuminate\Database\Eloquent\Relations\Relation.' , $ class , $ relation ) ) ; } }
Validate the relation method exists and is a type of Eloquent Relation.

@param Illuminate\Database\Eloquent\Model $model
@param string                             $relation

@return void
Validate the relation method exists and is a type of Eloquent Relation .