-
-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from adamcopley/soft-deletes-fix
ensure slugs are still unique if we use soft deletes
- Loading branch information
Showing
5 changed files
with
88 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace Spatie\Sluggable\Test\Integration; | ||
|
||
use Spatie\Sluggable\HasSlug; | ||
use Spatie\Sluggable\SlugOptions; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\SoftDeletes; | ||
|
||
class TestModelSoftDeletes extends Model | ||
{ | ||
use SoftDeletes, | ||
HasSlug; | ||
|
||
protected $table = 'test_model_soft_deletes'; | ||
|
||
protected $guarded = []; | ||
|
||
public $timestamps = false; | ||
|
||
/** | ||
* Get the options for generating the slug. | ||
*/ | ||
public function getSlugOptions() : SlugOptions | ||
{ | ||
return $this->slugOptions ?? $this->getDefaultSlugOptions(); | ||
} | ||
|
||
/** | ||
* Set the options for generating the slug. | ||
*/ | ||
public function setSlugOptions(SlugOptions $slugOptions) : self | ||
{ | ||
$this->slugOptions = $slugOptions; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Get the default slug options used in the tests. | ||
*/ | ||
public function getDefaultSlugOptions() : SlugOptions | ||
{ | ||
return SlugOptions::create() | ||
->generateSlugsFrom('name') | ||
->saveSlugsTo('url'); | ||
} | ||
} |