src/Label305/AujaLaravel/Factory/SingleAssociationIndexMenuFactory.php
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;
    }
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;
    }
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.