Exemplo n.º 1
0
 /**
  * Returns a node by name
  *
  * @param string $name
  * @param bool $track
  * @param bool $published
  * @return Node
  */
 public function getNode($name, $track = true, $published = true)
 {
     if ($this->withPublishedOnly($published)) {
         $node = PublishedNode::withName($name);
     } else {
         $node = Node::withName($name);
     }
     $node = $node->firstOrFail();
     $this->track($track, $node);
     return $node;
 }
Exemplo n.º 2
0
 /** @test */
 function it_scopes_nodes_with_name()
 {
     $this->assertNull(Node::withName('english-title')->first());
     $node = $this->getNode();
     $node->fill(['en' => ['title' => 'English Title', 'description' => 'English Description', 'area' => 100000], 'tr' => ['title' => 'Türkçe Başlık', 'description' => 'Türkçe Açıklama', 'area' => 30000]]);
     $node->save();
     $this->assertInstanceOf('Nuclear\\Hierarchy\\Node', Node::withName('english-title')->first());
     $this->assertInstanceOf('Nuclear\\Hierarchy\\Node', Node::withName('english-title', 'en')->first());
     $this->assertNull(Node::withName('english-title', 'tr')->first());
     $this->assertInstanceOf('Nuclear\\Hierarchy\\Node', Node::withName('tuerkce-baslik')->first());
     $this->assertInstanceOf('Nuclear\\Hierarchy\\Node', Node::withName('tuerkce-baslik', 'tr')->first());
 }