Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

246
Visualizações
Multiple Laravel bootable traits not working

Using multiple boot traits with the same event will fire just the first one and ignore the rest bootable traits.

class Tag extends Model
{
    use HasKey; // this will work (but if i put it bellow it will not work)
    use HasSlug; // this's not (but if i put it above it will work)
}
trait HasKey
{
    public static function bootHasKey()
    {
        static::creating(
            fn (Model $model) => $model->key = 'value'
        );
    }
trait HasSlug
{
    public static function bootHasSlug()
    {
        static::creating(
            fn (Model $model) => $model->slug = 'value'
        );
    }
}
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I found that it's not supported at the moment, maybe in the future releases of Laravel!

https://github.com/laravel/framework/issues/40645#issuecomment-1022969116

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda