syntax error, unexpected ‘=>’ (T_DOUBLE_ARROW) [duplicate]

  laravel, laravel-8, php, php-7.4, php-8

Context
I just finished developing an internal business application using Laravel/Jetstream with Inertia which uses a Model Broadcaster with Ably integrated for desktop notifications. Everything was working perfectly locally so I pushed live this afternoon. I have everything migrated and what appears to be setup properly, with https working.

The server is a LEMP droplet on DO
Link to the image details: https://marketplace.digitalocean.com/apps/lemp?ipAddress=143.198.148.3#getting-started

Issue:
Everything I have read about the issue says it’s likely a php version issue being earlier than 7.4, but this isn’t the case here

The result of phpinfo():(I can’t include the image because I just signed up today)

PHP Version 7.4.3

Image located at:
https://i.ibb.co/C1qZyjZ/Screen-Shot-2021-07-21-at-3-56-20-PM.png

The result of var_dump(PHP_VERSION)

string(5) "7.4.3"

Inside of my Model Broadcaster is the origination of the error.

namespace AppModels;

use IlluminateBroadcastingPrivateChannel;
use IlluminateDatabaseEloquentBroadcastsEvents;
use IlluminateDatabaseEloquentFactoriesHasFactory;
use IlluminateDatabaseEloquentModel;
use IlluminateBroadcastingChannel;

class Ticket extends Model
{
    use BroadcastsEvents, HasFactory;

    /**
     * Get the channels that model events should broadcast on.
     *
     * @param  string  $event
     * @return IlluminateBroadcastingChannel|array
     */
    public function broadcastOn($event)
    {
        return match($event) {
            //
            //This is the line
            //
            'created' => [new Channel('ticket')],
            default => []
        };
    }
}

Laravel Documentation showing the same format:
https://laravel.com/docs/8.x/broadcasting#model-broadcasting

/**
 * Get the channels that model events should broadcast on.
 *
 * @param  string  $event
 * @return IlluminateBroadcastingChannel|array
 */
public function broadcastOn($event)
{
    return match($event) {
        'deleted' => [],
        default => [$this, $this->user],
    };
}


Source: Laravel

Leave a Reply