memogram / panelkit
Panel kit for memogram
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/memogram/panelkit
Requires
- laravel/framework: ^11.0|^12.0
- memogram/framework: dev-main
Requires (Dev)
- phpunit/phpunit: 11.0@dev
This package is auto-updated.
Last update: 2025-12-08 20:29:36 UTC
README
Installation
composer require memogram/panelkit
Publish
Optionally, you can publish the assets:
php artisan vendor:publish --tag="panelkit:config" php artisan vendor:publish --tag="panelkit:lang"
Broadcast
Broadcast is a service to notify the users by a message
Ready To Use
Add these lines to show global sending method actions:
return messageResponse() ->schema([ [ key("Forward", fn () => open([BroadcastForm::class, 'forwardForm'])), key("Message", fn () => open([BroadcastForm::class, 'messageForm'])), ] ]);
Fast Use
Send to all users a message:
Broadcast::toAll() ->message(['text' => 'Hello Everyone!']) ->log(update()->getChatId()) ->notify();
Logger
Logger logging the notifier status
Available builtin loggers:
new PvBroadcastLogger(CHAT_ID)
Creating customize classes:
class CustomLogger implements BroadcastLogger { public function created(BroadcastJob $job) : void { // ... } public function log(BroadcastJob $job) : void { // ... } public function error(BroadcastJob $job, \Throwable $exception) : void { // ... } public function completed(BroadcastJob $job) : void { // ... } }
Usage:
Broadcast::toAll() ->send(['text' => 'Foo']) ->logger(new CustomLogger()) ->notify();
Lock
Lock system used to protect contents by favorite lock methods like forcing channel joining
Ready To Use
Middleware:
withGlobalMiddleware(new LockMiddleware());
Use the section:
return messageResponse() ->schema([ [key("🔒 Locks", [LockResourceSection::class, 'main'])], // todo ]);
Fast Use
Works with locks:
$lock = Lock::push(...); // To add a new lock $lock->delete(); // To delete the lock
Using useLock hook:
public function lockedContent() { $lock = app(LockRequest::class)->useLock(); yield from $lock(); yield "Actual content"; }
Fixed Channels
Change the config:
'lock' => [ 'fixed' => [ [ 'chat_id' => -123455678, 'title' => 'Join', 'url' => 'https://t.me/Link', 'group' => 'main', ], ], ],
Lock Condition
class UserIsOddCondition implements LockCondition { public function show(): bool { return User::$current->id % 2 == 1; } }
Set globally condition in config:
'lock' => [ 'condition' => UserIsOddCondition::class, ],
Targets
Targets is a collection of tools to customize the actions
Aim
Aim set the target query and records
Available builtin aims:
new TgAllAim() new TgCustomAim(new SerializableClosure(function () {...}))
Creating customize classes:
class TgNotBannedAim implements TgAim { public function getQuery() : Builder { return BotUser::whereIsNull('ban_until')->orderBy('created_at'); } }
We trust on
orderBy('created_at')to sort the records by a stable order to prevent double sending or not sending to some users.
Usage:
Broadcast::make() ->aim(new TgNotBannedAim()) ->send(['text' => 'Hi']) ->notify();
Notifier
Notifier set the sending method
Available builtin notifiers:
new TgMessageNotifier() new TgForwardNotifier() new TgCustomNotifier(new SerializableClosure(function () {...}))
Creating customize classes:
class TgHomeSectionNotifier implements TgNotifier { public function notify(Model $record): bool { evnetHandler()-> // todo return (bool) pov() ->user($record) ->catch() ->run( fn () => HomeSection::invokes('main') ); } }
Usage:
Broadcast::toAll() ->notifier(new TgHomeSectionNotifier()) ->notify();