-
-
Notifications
You must be signed in to change notification settings - Fork 186
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 #213 from marvin-wtt/implicit-model-binding
Adds support for implicit route model binding with translated slugs
- Loading branch information
Showing
9 changed files
with
230 additions
and
15 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
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,37 @@ | ||
<?php | ||
|
||
namespace Spatie\Sluggable\Tests; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\SoftDeletes; | ||
use Spatie\Sluggable\HasTranslatableSlug; | ||
use Spatie\Sluggable\SlugOptions; | ||
use Spatie\Translatable\HasTranslations; | ||
|
||
class TranslatableModelSoftDeletes extends Model | ||
{ | ||
use HasTranslations; | ||
use HasTranslatableSlug; | ||
use SoftDeletes; | ||
|
||
protected $table = 'translatable_model_soft_deletes'; | ||
|
||
protected $guarded = []; | ||
public $timestamps = false; | ||
|
||
protected $translatable = ['name', 'other_field', 'slug']; | ||
|
||
protected $customSlugOptions; | ||
|
||
public function useSlugOptions($slugOptions) | ||
{ | ||
$this->customSlugOptions = $slugOptions; | ||
} | ||
|
||
public function getSlugOptions(): SlugOptions | ||
{ | ||
return $this->customSlugOptions ?: SlugOptions::create() | ||
->generateSlugsFrom('name') | ||
->saveSlugsTo('slug'); | ||
} | ||
} |