1414use Bkwld \Upchuck \SupportsUploads ;
1515use Bkwld \Library \Utils \Collection ;
1616use Bkwld \Decoy \Exceptions \Exception ;
17- use Cviebrock \EloquentSluggable \SluggableTrait ;
17+ use Cviebrock \EloquentSluggable \Sluggable ;
18+ use Cviebrock \EloquentSluggable \SluggableScopeHelpers ;
1819use Bkwld \Decoy \Collections \Base as BaseCollection ;
19- use Cviebrock \EloquentSluggable \SluggableInterface ;
2020use Illuminate \Database \Eloquent \Model as Eloquent ;
2121use Illuminate \Database \Eloquent \ModelNotFoundException ;
2222use Symfony \Component \HttpKernel \Exception \AccessDeniedHttpException ;
2323
24- abstract class Base extends Eloquent implements SluggableInterface
24+ abstract class Base extends Eloquent
2525{
2626
2727 /**
2828 * Adding common traits. The memory usage of adding additional methods is
2929 * negligible.
3030 */
3131 use Cloneable,
32- SluggableTrait,
32+ Sluggable,
33+ SluggableScopeHelpers,
3334 SupportsUploads,
34- Traits \CanSerializeTransform {
35- needsSlugging as traitNeedsSlugging;
36- }
35+ Traits \CanSerializeTransform
36+ ;
3737
3838 /**
3939 * Use the Decoy Base Collection
@@ -195,12 +195,18 @@ public function changes()
195195 * Tell sluggable where to get the source for the slug and apply other
196196 * customizations.
197197 *
198- * @var array
198+ * @return array
199199 */
200- protected $ sluggable = [
201- 'build_from ' => 'admin_title ' ,
202- 'max_length ' => 100 ,
203- ];
200+ public function sluggable ()
201+ {
202+ if (!$ this ->needsSlugging ()) return [];
203+ return [
204+ 'slug ' => [
205+ 'source ' => 'admin_title ' ,
206+ 'maxLength ' => 100 ,
207+ ]
208+ ];
209+ }
204210
205211 /**
206212 * Check for a validation rule for a slug column
@@ -209,11 +215,7 @@ public function changes()
209215 */
210216 protected function needsSlugging ()
211217 {
212- if (!array_key_exists ('slug ' , static ::$ rules )) {
213- return false ;
214- }
215-
216- return $ this ->traitNeedsSlugging ();
218+ return array_key_exists ('slug ' , static ::$ rules );
217219 }
218220
219221 //---------------------------------------------------------------------------
@@ -636,12 +638,13 @@ public function scopeOtherLocalizations($query)
636638 * Find by the slug and fail if missing. Invokes methods from the
637639 * Sluggable trait.
638640 *
639- * @param string $string
641+ * @param string $string
642+ * @param array $columns
640643 * @return Illuminate\Database\Eloquent\Model
641644 *
642645 * @throws Illuminate\Database\Eloquent\ModelNotFoundException
643646 */
644- public static function findBySlugOrFail ($ slug )
647+ public static function findBySlugOrFail ($ slug, array $ columns = [ ' * ' ] )
645648 {
646649 // Model not found, throw exception
647650 if (!$ item = static ::findBySlug ($ slug )) {
0 commit comments