PHP code example of deminua / laravel-tgbot

1. Go to this page and download the library: Download deminua/laravel-tgbot 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/ */

    

deminua / laravel-tgbot example snippets

 bootstrap/providers.php


/**
 * bootstrap/providers.php
 * add Deminua\LaravelTgbot\LaravelTgbot::class to array
 */
 
return [
    App\Providers\AppServiceProvider::class,
    Deminua\LaravelTgbot\LaravelTgbot::class,
];
 routes/web.php


/**
 * routes/web.php
 * LaravelTgbot::routes(['prefix' => 'telegram', 'middleware' => 'auth']);
 */


LaravelTgbot::routes();

 routes/web.php


/**
 * routes/web.php
 * For example, you can define your route:
*/
Route::get('send', function () {

    $data = [
        'title' => 'Test',
        'name' => 'Bob',
        'email' => '[email protected]',
        'phone' => '+380960000000',
        'url' => url()->previous()
    ];
    
    $response = response()->json(['message' => __('Thank you, has been successfully, we will contact you soon!')]);

    return LaravelTgbot::send($data, $response);
    
});


php artisan route:list

  GET|HEAD   send .......................................
  GET|HEAD   telegram ...................................
  POST       telegram ...................................
  GET|HEAD   telegram/edit/{bot} ........................
  POST       telegram/edit/{bot} ........................
  GET|HEAD   telegram/edit/{bot}/delete_client/{client} .
  POST       telegram/edit/{bot}/new_client .............
  GET|HEAD   telegram/edit/{bot}/test_client/{client} ...

php artisan migrate

php artisan vendor:publish --tag=laravel-tgbot-views