function let(AujaRouter $aujaRouter, Relation $relation, Model $left, Model $right)
 {
     $this->beConstructedWith($aujaRouter);
     $this->relation = $relation;
     $relation->getLeft()->willReturn($left);
     $relation->getRight()->willReturn($right);
     $relation->getType()->willReturn('hasMany');
     $left->getName()->willReturn('Model');
     $right->getName()->willReturn('OtherModel');
     URL::shouldReceive('route');
     Lang::shouldReceive('trans')->with('Edit')->andReturn('Edit');
     Lang::shouldReceive('trans')->with('Properties')->andReturn('Properties');
     Lang::shouldReceive('trans')->with('OtherModel')->andReturn('OtherModel');
 }
 function let(AujaConfigurator $aujaConfigurator, AujaRouter $aujaRouter, Relation $relation, Model $left, Model $right)
 {
     $this->beConstructedWith($aujaConfigurator, $aujaRouter);
     $this->relations = [$relation];
     $relation->getLeft()->willReturn($left);
     $relation->getRight()->willReturn($right);
     $relation->getType()->willReturn('hasMany');
     $left->getName()->willReturn('Model');
     $right->getName()->willReturn('OtherModel');
     $aujaConfigurator->getModel('Model')->willReturn($left);
     $aujaConfigurator->getRelationsForModel($left)->willReturn([$relation]);
     $aujaConfigurator->getDisplayField($left)->willReturn('name');
     $aujaConfigurator->getIcon($left)->willReturn(null);
     URL::shouldReceive('route');
     Lang::shouldReceive('trans')->with('Add')->andReturn('Add');
     Lang::shouldReceive('trans')->with('Model')->andReturn('Model');
 }
 /**
  * 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;
 }