classes/Input/NestedModels.php
protected function makeRelation($model, $name, $data)
    {
        // The data must be an array and must contain arrays
        if (!is_array($data)
            || empty($data)
            || count(array_filter($data, function ($child) {
                return !is_array($child);
            }))) {
            return false;
        }

        // The input name should be a function defined on the model.
        if (!method_exists($model, $name)) {
            return false;
        }

        // Check if the running the function actually returns a relationship
        $relation = $model->$name();
        if (!is_a($relation, Relation::class)) {
            return false;
        }

        // Return the relationship object
        return $relation;
    }
protected function makeRelation($model, $name, $data)
    {
        // The data must be an array and must contain arrays
        if (!is_array($data)
            || empty($data)
            || count(array_filter($data, function ($child) {
                return !is_array($child);
            }))) {
            return false;
        }

        // The input name should be a function defined on the model.
        if (!method_exists($model, $name)) {
            return false;
        }

        // Check if the running the function actually returns a relationship
        $relation = $model->$name();
        if (!is_a($relation, Relation::class)) {
            return false;
        }

        // Return the relationship object
        return $relation;
    }
protected function makeRelation ( $ model , $ name , $ data ) { // The data must be an array and must contain arrays if ( ! is_array ( $ data ) || empty ( $ data ) || count ( array_filter ( $ data , function ( $ child ) { return ! is_array ( $ child ) ; } ) ) ) { return false ; } // The input name should be a function defined on the model. if ( ! method_exists ( $ model , $ name ) ) { return false ; } // Check if the running the function actually returns a relationship $ relation = $ model -> $ name ( ) ; if ( ! is_a ( $ relation , Relation :: class ) ) { return false ; } // Return the relationship object return $ relation ; }
Check if the input is a relation and, if it is, return the relationship
object

@param  Model          $model
@param  string         $name  The input name, like from <input name="$name">, which
is also the naem of the relationship function.
@param  mixed          $data
@return false|Relation
Check if the input is a relation and if it is return the relationship object