classes/Controllers/Base.php
public function parent($parent)
    {
        // Save out the passed reference
        $this->parent = $parent;

        // Save out sub properties that I hope to deprecate
        $this->parent_model = get_class($this->parent);
        $this->parent_controller = Decoy::controllerForModel($this->parent_model);

        // Figure out what the relationship function to the child (this controller's
        // model) on the parent model .  It will be the plural version of this
        // model's name.
        $this->parent_to_self = Decoy::hasManyName($this->model);

        // If the parent is the same as this controller, assume that it's a
        // many-to-many-to-self relationship.  Thus, expect a relationship method to
        // be defined on the model called "RELATIONSHIPAsChild".  I.e. "postsAsChild"
        if ($this->parent_controller == $this->controller && method_exists($this->model, $this->parent_to_self.'AsChild')) {
            $this->self_to_parent = $this->parent_to_self.'AsChild';

        // If the parent relationship is a polymorphic one-many, then the
        // relationship function on the child model will be the model name plus
        // "able".  For instance, the Link model would have it's relationship to
        // parent called "linkable".
        } elseif (is_a($this->parentRelation(), 'Illuminate\Database\Eloquent\Relations\MorphMany')) {
            $this->self_to_parent = Decoy::belongsToName($this->model).'able';

        // Save out to self to parent relationship.  It will be singular if the
        // relationship is a many to many.
        } else {
            $this->self_to_parent = $this->isChildInManyToMany()?
                Decoy::hasManyName($this->parent_model):
                Decoy::belongsToName($this->parent_model);
        }

        // Make chainable
        return $this;
    }
public function parent($parent)
    {
        // Save out the passed reference
        $this->parent = $parent;

        // Save out sub properties that I hope to deprecate
        $this->parent_model = get_class($this->parent);
        $this->parent_controller = Decoy::controllerForModel($this->parent_model);

        // Figure out what the relationship function to the child (this controller's
        // model) on the parent model .  It will be the plural version of this
        // model's name.
        $this->parent_to_self = Decoy::hasManyName($this->model);

        // If the parent is the same as this controller, assume that it's a
        // many-to-many-to-self relationship.  Thus, expect a relationship method to
        // be defined on the model called "RELATIONSHIPAsChild".  I.e. "postsAsChild"
        if ($this->parent_controller == $this->controller && method_exists($this->model, $this->parent_to_self.'AsChild')) {
            $this->self_to_parent = $this->parent_to_self.'AsChild';

        // If the parent relationship is a polymorphic one-many, then the
        // relationship function on the child model will be the model name plus
        // "able".  For instance, the Link model would have it's relationship to
        // parent called "linkable".
        } elseif (is_a($this->parentRelation(), 'Illuminate\Database\Eloquent\Relations\MorphMany')) {
            $this->self_to_parent = Decoy::belongsToName($this->model).'able';

        // Save out to self to parent relationship.  It will be singular if the
        // relationship is a many to many.
        } else {
            $this->self_to_parent = $this->isChildInManyToMany()?
                Decoy::hasManyName($this->parent_model):
                Decoy::belongsToName($this->parent_model);
        }

        // Make chainable
        return $this;
    }
public function parent ( $ parent ) { // Save out the passed reference $ this -> parent = $ parent ; // Save out sub properties that I hope to deprecate $ this -> parent_model = get_class ( $ this -> parent ) ; $ this -> parent_controller = Decoy :: controllerForModel ( $ this -> parent_model ) ; // Figure out what the relationship function to the child (this controller's // model) on the parent model .  It will be the plural version of this // model's name. $ this -> parent_to_self = Decoy :: hasManyName ( $ this -> model ) ; // If the parent is the same as this controller, assume that it's a // many-to-many-to-self relationship.  Thus, expect a relationship method to // be defined on the model called "RELATIONSHIPAsChild".  I.e. "postsAsChild" if ( $ this -> parent_controller == $ this -> controller && method_exists ( $ this -> model , $ this -> parent_to_self . 'AsChild' ) ) { $ this -> self_to_parent = $ this -> parent_to_self . 'AsChild' ; // If the parent relationship is a polymorphic one-many, then the // relationship function on the child model will be the model name plus // "able".  For instance, the Link model would have it's relationship to // parent called "linkable". } elseif ( is_a ( $ this -> parentRelation ( ) , 'Illuminate\Database\Eloquent\Relations\MorphMany' ) ) { $ this -> self_to_parent = Decoy :: belongsToName ( $ this -> model ) . 'able' ; // Save out to self to parent relationship.  It will be singular if the // relationship is a many to many. } else { $ this -> self_to_parent = $ this -> isChildInManyToMany ( ) ? Decoy :: hasManyName ( $ this -> parent_model ) : Decoy :: belongsToName ( $ this -> parent_model ) ; } // Make chainable return $ this ; }
Give this controller a parent model instance.  For instance, this makes the
index view a listing of just the children of the parent.

@param  Illuminate\Database\Eloquent\Model $parent
@return $this
Give this controller a parent model instance . For instance this makes the index view a listing of just the children of the parent .