In the error page click "Expand vendor frames" and click the top most stack, to see where the error is coming from. It might explain more. May be composer dependencies did not update successfully.
Jul 13, 2022
2
Level 6
Events: preg_match(): Argument #2 ($subject) must be of type string
Running into an odd error that started recently after updating some packages, but it's not clear what caused it.
In my code, I have an event (laravel) that is dispatched after an Event (my object) is created.
EventCreated::dispatch($event);
Now I'm getting an error such as:
preg_match(): Argument #2 ($subject) must be of type string
However, there is no second parameter for dispatching.
Below is the EventCreated code for reference.
<?php
namespace App\Events;
use App\Models\Event;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class EventCreated implements ShouldBroadcast
{
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
public Event $event;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct(Event $event)
{
$this->event = $event;
$this->dontBroadcastToCurrentUser();
}
/**
* Get the channels the event should broadcast on.
*
* @return Channel|array
*/
public function broadcastOn()
{
return new Channel('events');
}
}
Level 50
Please or to participate in this conversation.