app/Models/Message.php
/**
     * Boot the soft taggable trait for a model.
     *
     * @return void
     */
Boot the soft taggable trait for a model.
@return void
Boot the soft taggable trait for a model . @return void
protected static function boot()
    {
        parent::boot();
        static::created(function ($model) {
            $me   = auth()->user();
            $chat = $model->chat;
            if ($me->id === $chat->user_one_id) {
                $chat->update(['seen_two' => 0]);
            } else {
                $chat->update(['seen_one' => 0]);
            }
        });
    }
protected static function boot ( ) { parent :: boot ( ) ; static :: created ( function ( $ model ) { $ me = auth ( ) -> user ( ) ; $ chat = $ model -> chat ; if ( $ me -> id === $ chat -> user_one_id ) { $ chat -> update ( [ 'seen_two' => 0 ] ) ; } else { $ chat -> update ( [ 'seen_one' => 0 ] ) ; } } ) ; }
Boot the soft taggable trait for a model.
Boot the soft taggable trait for a model .
// Unsee chat for another user on new message created