/**
  * @param \Illuminate\Database\Eloquent\Model $model
  * @param string $event
  * @return boolean|null
  */
 protected function generateSlug(Model $model, $event)
 {
     // If the "slugging" event returns a value, abort
     if ($this->fireSluggingEvent($model, $event) !== null) {
         return;
     }
     $wasSlugged = $this->slugService->slug($model);
     $this->fireSluggedEvent($model, $wasSlugged);
 }
예제 #2
0
 /**
  * Test that we generate unique slugs in a static context.
  *
  * @test
  */
 public function testStaticSlugGeneratorWhenEntriesExist()
 {
     $post = Post::create(['title' => 'My Test Post']);
     $this->assertEquals('my-test-post', $post->slug);
     $slug = SlugService::createSlug(Post::class, 'slug', 'My Test Post');
     $this->assertEquals('my-test-post-1', $slug);
 }