belongsTo(HelpTopic::class,'ticket_category_id'); } public function comments(){ return $this->hasMany(HelpTicketComment::class); } /* |-------------------------------------------------------------------------- | SCOPES |-------------------------------------------------------------------------- */ /* |-------------------------------------------------------------------------- | ACCESORS |-------------------------------------------------------------------------- */ /* |-------------------------------------------------------------------------- | MUTATORS |-------------------------------------------------------------------------- */ /** * Boot all of the bootable traits on the model. */ public static function boot() { parent::boot(); static::creating(function ($ticket) { $ticket->code = strtoupper(str_random(5)) . date('jn'); }); } }