C
C
Creed12342021-01-25 16:17:30
Laravel
Creed1234, 2021-01-25 16:17:30

How to force in crop to use a mutator?

Seyu DB through the factory.

I want a mutator to be used when creating the slug field,

public function setSlugAttribute($value)
    {
        $this->attributes['slug'] = Str::slug($value, '-');
    }

which, on normal save, takes the title and creates the slug field:
$productTitle = $request->title;
$product->slug = $productTitle;

How to use a mutator when seeding?
'title' => $this->faker->words(3, true),
'slug' => ???????

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question