feat: Realtime for Votes + Deadlines

This commit is contained in:
2024-03-24 01:36:16 +01:00
parent b1cb25c823
commit 5c0dab3448
9 changed files with 133 additions and 1 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Models;
use App\Events\Vote\VoteCreated;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
@@ -14,6 +15,13 @@ class Vote extends Model
'book_recommendation_id',
];
protected static function booted() :void
{
static::created(static function ($vote) {
broadcast(new VoteCreated($vote))->toOthers();
});
}
public function user()
{
return $this->belongsTo(User::class);