generated from Flycro/laravel-nuxt
feat: Realtime for Votes + Deadlines
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user