/**
  * Builds a menu for displaying associated items to a model entry (i.e. /club/21/team).
  *
  * The menu will include:
  *  - An Add LinkMenuItem;
  *  - A SpacerMenuItem with the name of the associated model;
  *  - A ResourceMenuItem to hold entries of the associated model.
  *
  * @param String      $modelName       The name of the model (i.e. Club).
  * @param int         $modelId         The id of the model entry.
  * @param String      $associationName The name of the associated model (i.e. Team).
  * @param ModelConfig $config          (optional) The `ModelConfig` to use.
  *
  * @return Menu the Menu, which can be configured further.
  */
 public function create($modelName, $modelId, $associationName, ModelConfig $config = null)
 {
     $menu = new Menu();
     $addMenuItem = new LinkMenuItem();
     $addMenuItem->setText(Lang::trans('Add') . ' ' . Lang::trans($associationName));
     $addMenuItem->setIcon(Icons::ion_plus);
     $addMenuItem->setTarget(Url::route($this->aujaRouter->getCreateAssociationName($modelName, $associationName), $modelId));
     $menu->addMenuItem($addMenuItem);
     $headerMenuItem = new SpacerMenuItem();
     $headerMenuItem->setText(Lang::trans(str_plural($associationName)));
     $menu->addMenuItem($headerMenuItem);
     $resourceMenuItem = new ResourceMenuItem();
     $resourceMenuItem->setTarget(Url::route($this->aujaRouter->getAssociationName($modelName, $associationName), $modelId));
     $menu->addMenuItem($resourceMenuItem);
     return $menu;
 }
 /**
  * Builds a menu for a single model entry, where the model has exactly one relationship with another model.
  *
  * The menu will include:
  *  - An Edit LinkMenuItem to edit the model entry.
  *  - A SpacerMenuItem with the name of the associated model;
  *  - An Add LinkMenuItem to add an entry of the associated model;
  *  - A ResourceMenuItem to hold entries of the associated model.
  *
  * @param String      $modelName The name of the model.
  * @param int         $modelId   The id of the model entry.
  * @param Relation    $relation  The Relation this model has with the associated model.
  * @param ModelConfig $config    (optional) The `ModelConfig` to use.
  *
  * @return Menu The Menu, which can be configured further.
  */
 public function create($modelName, $modelId, Relation $relation, ModelConfig $config = null)
 {
     $otherModelName = $relation->getRight()->getName();
     $menu = new Menu();
     $editMenuItem = new LinkMenuItem();
     $editMenuItem->setText(Lang::trans('Edit'));
     $editMenuItem->setTarget(URL::route($this->aujaRouter->getEditName($modelName), $modelId));
     $menu->addMenuItem($editMenuItem);
     $headerMenuItem = new SpacerMenuItem();
     $headerMenuItem->setText(Lang::trans(str_plural($otherModelName)));
     $menu->addMenuItem($headerMenuItem);
     $addMenuItem = new LinkMenuItem();
     $addMenuItem->setText(sprintf('%s %s', Lang::trans('Add'), Lang::trans($otherModelName)));
     $addMenuItem->setIcon(Icons::ion_plus);
     $addMenuItem->setTarget(URL::route($this->aujaRouter->getCreateAssociationName($modelName, $otherModelName), $modelId));
     $menu->addMenuItem($addMenuItem);
     $resourceMenuItem = new ResourceMenuItem();
     $resourceMenuItem->setTarget(URL::route($this->aujaRouter->getAssociationName($modelName, $otherModelName), $modelId));
     $menu->addMenuItem($resourceMenuItem);
     return $menu;
 }