Esempio n. 1
0
 /**
  * Test slugifing some words
  *
  * @return void
  * @author Dan Cox
  */
 public function test_slug()
 {
     $slug1 = Str::slug('Foo bar');
     $slug2 = Str::slug('@&^!(@ Foo Bar');
     $slug3 = Str::slug('::":A:EOS Slugify Me');
     $this->assertEquals('foo-bar', $slug1);
     $this->assertEquals('foo-bar', $slug2);
     $this->assertEquals('a-eos-slugify-me', $slug3);
 }
Esempio n. 2
0
 /**
  * Hooks onto the pre update event to update slug if title has changed
  *
  * @ORM\PreUpdate
  * @return void
  * @author Dan Cox
  */
 public function preUpdateSlug()
 {
     if (!is_null($this->title) && Str::slug($this->title) !== $this->slug) {
         $this->slug = Str::slug($this->title);
     }
 }