Update database Laravel Via Telegram
<?php
namespace Telegram\Bot\Commands;
use App\Models\Barang\Barang;
use App\Models\Barang\LogBarang;
use App\Models\Barang\Kategori;
use Illuminate\Support\Facades\DB;
class HelpCommand extends Command
{
public function handle($arguments)
{
$commands = $this->telegram->getCommands();
$text = '';
foreach ($commands as $name => $handler) {
$text .= sprintf('/%s - %s'.PHP_EOL, $name, $handler->getDescription());
$id = $this->update->getMessage()->getChat()->getId();
$message = $this->update->getMessage()->getText();
//custom in here
//update data etc with where $id (admin), goodluck
//custom in here
//update data etc with where $id (admin), goodluck
$this->replyWithMessage([
'text' => $text." ".$message." ".$id
]);
}
//pada config/telegram.php
'commands' => [
Telegram\Bot\Commands\HelpCommand::class
],
//pada Controller
use Telegram\Bot\Actions;
use Telegram\Bot\Api;
use Telegram\Bot\FileUpload\InputFile;
use Telegram\Bot\Laravel\Facades\Telegram;
---------------------------------
/** @var Api */
protected $telegram;
/**
* BotController constructor.
*
* @param Api $telegram
*/
public function __construct(Api $telegram)
{
$this->telegram = $telegram;
}
---------------------------------
$this->telegram->commandsHandler(true);
return "200";

0 Response to "Laravel Update Data Via Telegram Api Bot"
Post a Comment