Sunday, April 2, 2017

Laravel disable slug transltions

I'm trying to save my group model with a slug, but it keeps saving my slug with the untranslated version of the name.

is there a way to force it so it uses the input value?

This is the model:

class Group extends Model
{
    use CrudTrait;
    use Sluggable, SluggableScopeHelpers;
    use HasTranslations;

    protected $table = 'groups';
    protected $primaryKey = 'id';
    protected $fillable = ['name', 'slug'];
    protected $hidden = ['pivot'];
    protected $translatable = ['name'];
    public $timestamps = true;


    */
    public function users()
    {
        return $this->belongsToMany(User::class);
    }

    /**
     * Return the sluggable configuration array for this model.
     *
     * @return array
     */
    public function sluggable()
    {
        return [
            'slug' => [
                'source' => 'name'

            ],
        ];
    }
}

And now when I put in a name e.g. test this will save my slug value as {"en":"{\"en\":\"test\"}"}

instead of just normal test anyone know what I might be doing wrong?

I'm also using the Laravel Backpack items



via Kiwi

Advertisement