add message template

This commit is contained in:
xiaomlove
2025-06-19 13:13:26 +07:00
parent 75c1eb0664
commit a0ff441f03
85 changed files with 479 additions and 7 deletions
+5 -2
View File
@@ -2,6 +2,7 @@
namespace App\Models;
use App\Enums\ModelEventEnum;
use Nexus\Database\NexusDB;
class Message extends NexusModel
@@ -26,10 +27,12 @@ class Message extends NexusModel
return $this->belongsTo(User::class, 'receiver');
}
public static function add(array $data): bool
public static function add(array $data): self
{
clear_inbox_count_cache($data["receiver"]);
return self::query()->insert($data);
$message = self::query()->create($data);
fire_event(ModelEventEnum::MESSAGE_CREATED, $message);
return $message;
}
}