1 year ago by Master Jupiter

Relates to the lesson Build a classified ads site

Hi I am doing classified ad series. While creating database seeder for Area ->slug, Alex uses php creating method. Is that a function? I know only about create method.

In AppServiceProvider.php

public function boot()
            $prefix = $area->parent ? $area->parent->name . ' ' : '';
            $area->slug = str_slug($prefix . $area->name);

1 year ago by Master Jupiter

I got my answers, It was covered in the following lesson:


1 year ago by Dmitriy Belyakov

Best answer

Alex registers event handler using "creating" method on Area model class. It is inherited from Illuminate\Database\Eloquent\Model which uses it through Illuminate\Database\Eloquent\Concerns\HasEvents trait. You can read more about events here and here Though I haven't found the way Alex registered an event handler in Laravel documentation. I think it is much simpler and faster to implement.

Sign in or create an account to reply to this topic.