PHP code example of mmb / panelkit
1. Go to this page and download the library: Download mmb/panelkit 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/ */
mmb / panelkit example snippets
$menu->schema([
[
$menu->key("Forward", fn () => EveryForwardForm::make()->request()),
$menu->key("Message", fn () => EveryMessageForm::make()->request()),
]
])
Every::toAll()
->send(['text' => 'Hello Everyone!'])
->log($this->update->getChat()->id)
->notify();
Every::to(fn () => BotUser::where('ban', false)->orderBy('created_at'))
->send()
->message(fn (BotUser $user) => ['text' => "Hello {$user->name}!"])
->log($this->update->getChat()->id)
->notify();
new PvEveryLogger(CHAT_ID)
class CustomLogger implements EveryLogger
{
public function created(EveryJob $job) : void
{
// ...
}
public function log(EveryJob $job) : void
{
// ...
}
public function error(EveryJob $job, \Throwable $exception) : void
{
// ...
}
public function completed(EveryJob $job) : void
{
// ...
}
}
Every::toAll()
->send(['text' => 'Foo'])
->logger(new CustomLogger())
->notify();
$handler->callback(LockMiddleAction::class),
LockRequest::for($this->context, 'main'), // For each groups
$menu->schema([
[$menu->keyFor("🔒 Locks", LockResourceSection::class)],
]);
$lock = Lock::add(...); // To add a new lock
$lock->delete(); // To delete the lock
LockRequest::for($this->context, 'main')->
'lock' => [
'fixed' => [
[
'chat_id' => -123455678,
'title' => 'Join',
'url' => 'https://t.me/Link',
'group' => 'main',
],
],
],
class UserIsOddCondition implements LockCondition
{
public function show() : bool
{
return BotUser::current()->id % 2 == 1;
}
}
'lock' => [
'condition' => UserIsOddCondition::class,
],
LockRequest::for($this->context, 'main')->withCondition(UserIsOddCondition::class)
class PostLockRequest extends LockRequest
{
#[Find]
public Post $post;
public function withPost(Post $post)
{
$this->post = $post;
return $this;
}
#[FixedDialog('lock:{group:slug}:{post:slug}')]
public function mainDialog(Dialog $dialog)
{
parent::mainDialog($dialog);
$dialog
->on('submit', function () use ($dialog)
{
if ($this->locks)
{
$this->tell(__('panelkit::lock.submit_invalid'), alert: true);
$dialog->reload();
}
else
{
$this->update->getMessage()?->delete(ignore: true);
PostSection::invokes('main', $this->post);
}
}
);
}
}
PostLockRequest::for($this->context, 'main')->withPost($myPost)->
new TgAllAim()
new TgCustomAim(new SerializableClosure(function () {...}))
class TgNotBannedAim implements TgAim
{
public function getQuery() : Builder
{
return BotUser::whereIsNull('ban_until')->orderBy('created_at');
}
}
Every::make()
->aim(new TgNotBannedAim())
->send(['text' => 'Hi'])
->notify();
new TgFixedLetter(['text' => 'Hello Mmb!'])
new TgEmptyLetter()
new TgCustomLetter(new SerializableClosure(function () {...}))
class TgWelcomeLetter implements TgLetter
{
public function getLetter(Model $record) : array
{
return [
'text' => "Welcome {$record->name}!",
];
}
}
Every::toAll()
->send()
->letter(new TgWelcomeLetter())
->notify();
new TgMessageNotifier()
new TgForwardNotifier()
new TgCustomNotifier(new SerializableClosure(function () {...}))
class TgHomeSectionNotifier implements TgNotifier
{
public function notify(Model $record, array $message) : bool
{
return (bool) pov()
->user($record)
->catch()
->run(
fn () => HomeSection::invokes('main')
);
}
}
Every::toAll()
->notifier(new TgHomeSectionNotifier())
->notify();
shell
php artisan vendor:publish --tag="panelkit:config"
php artisan vendor:publish --tag="panelkit:lang"