1. Go to this page and download the library: Download condoedge/communications library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
condoedge / communications example snippets
class OpenedReinscriptions implements CommunicableEvent
{
use Dispatchable, InteractsWithSockets, SerializesModels;
protected $event;
protected $teamsIds;
public function __construct($event)
{
$this->event = $event;
}
function getParams(): array
{
return [
'event' => $this->event,
];
}
function getCommunicables(): array|Collection
{
$persons = Person::whereHas('personTeams', fn($q) => $q->whereIn('team_id', $this->event->team->teams()->pluck('id'))->whereHas(
'teamRole', fn($q) => $q->where('role', InscriptionTypeEnum::PARENT)
))->whereDoesntHave('personEvents', fn($q) => $q->whereHas('person.registeredBy', fn($q) => $q->whereColumn('id', 'persons.id')));
return $persons->get();
}
static function getName(): string
{
return 'opened reinscriptions';
}
}
Variables::setVariables([
'events' => [
// ID, name, classes, automatic handling (access to the object and attribute)
['event.name_ev', 'Event name', 'bg-level1', true]
],
'teams' => [
['team_name', 'Team name', 'bg-level1', false]
]
]);
// We could also use the automatic handling of the variables ({model.attribute}) for simple cases
ContentReplacer::setHandlers([
'team_name' => function ($team) {
return $team->name;
}
]);
// We could also implement the method `enhanceContext` in the model to do this (I think it's better)
ContextEnhancer::setEnhancers([
'event' => function ($event) {
return [
'team' => $event->team,
'teams_ids' => [$event->team_id],
];
}
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.