/** * @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); }
/** * 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); }