BossPogs
6 months ago
300
0
Laravel

Laravel Pusher not working again

Posted 6 months ago by BossPogs

Hello. My pusher is not working again but when I check in the Pusher dashboard it is working. I try the php artisan config:clear but it is not working again.

call.blade.php

<div class="col-md-12">
                <form id="form-data" class="form-horizontal" method="POST" action="updatecall">
                    {{ csrf_field() }}
                    <div class="table-responsive">
                        <table class="table table-bordered" id="example" width="100%" cellspacing="0">
                            <tr>
                                @if($callid === null)
                                
                                @else
                                <input type="hidden" class="form-control" id="google/cloud-text-to-speech" name="call_id" value="{{ $callid->id }}" readonly>
                                <td><label>Probably Next Call</td>
                                <td><span id="letter">{{ $callid->letter }}</span>-<span id="number">{{ $callid->number }}</span></td>
                                <td>
                                    <button type="submit" class="btn btn-success btn-fill pull-right" id="update" float:right>
                                        CALL NEXT
                                    </button>
                                </td>
                            </tr>
                        </table>
                    </div>
                </form>
            @endif
        </div>  

<script>
$(document).ready(function() {
    // Enable pusher logging - don't include this in production
    Pusher.logToConsole = true;

    var pusher = new Pusher('586c6fb979ff3d2ad3b1', {
      cluster: 'ap1',
      forceTLS: true
    });

    var channel = pusher.subscribe('my-channel');
    channel.bind('my-event', function(data) {
        //alert(JSON.stringify(data));

        $("#call_id").val(data.id);
        $("#letter").html(data.letter);
        $("#number").html(data.number);
        
    }); //code that's not working


});
</script>

Controller

public function store(Request $request)
    {
        //query sa pag get counter gamita ang assignments
        $counter_id = Assignment::where('user_id', Auth::user()->id)
                    ->first();

        $called = Call::find($request->input('call_id'));
        $called->user_id = Auth::user()->id;
        $called->counter_id = $counter_id->counter_id; 
        $called->called = 'YES';
        $called->save();

        /*$office_id = Office::join('users', 'offices.id', '=', 'users.office_id')
                    ->select('offices.id')
                    ->where('users.id', Auth::user()->id)
                    ->first();*/
        $office_id = User::where('id', Auth::user()->id)->first();
        
        $callid = Call::join('transactions', 'calls.trans_id', '=', 'transactions.id')
                ->join('offices', 'transactions.office_id', '=', 'offices.id')
                ->select('calls.*')
                ->where('calls.called', 'NO')
                ->where('offices.id', $office_id->office_id)
                ->oldest('calls.created_at')
                ->first();

        if($callid != null)
        {
            // pusher
            $options = array(
                'cluster' => 'ap1',
                'useTLS' => true
            );

            $pusher = new Pusher(
                env('PUSHER_APP_KEY'),
                env('PUSHER_APP_SECRET'),
                env('PUSHER_APP_ID'),
                $options
            );

            $data = ['letter' => $callid->letter, 'number' => $callid->number, 'id' => $callid->id]; // sending calls: letter, number, id aron magupdate siya
            $pusher->trigger('my-channel', 'my-event', $data);
        }
        
        return redirect()->route('call.index')->with('success' , 'CALLED');
    }

On the other the pusher is working but today I was shocked it was not working in my laravel project but when I check in the pusher dashboard, the pusher is working

Please sign in or create an account to participate in this conversation.