PHP code example of patrolserver / patrol-laravel

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

    

patrolserver / patrol-laravel example snippets


'providers' => [
  ...
  'PatrolServer\Patrol\PatrolServiceProvider',
],

'aliases' => [
  ...
  'Patrol' => 'PatrolServer\Patrol\Facades\Patrol',
],

$user = Patrol::user();

$servers = Patrol::servers();

foreach ($servers as $server) 
{
    Log::info($server);
}

Route::post('patrolserver/webhook', 'PatrolServerController@webhook');

 App\Http\Controllers;

use Illuminate\Routing\Controller;
use Patrol;
use Log;

class PatrolServerController extends Controller 
{
	public function webhook() 
	{
		Patrol::webhook('new_server_issues', function ($event) 
		{
    		$server_id = array_get($event, 'server_id');

			if (!$server_id)
				Log::info('Server could not be found');

			$server = Patrol::get('servers/' . $server_id);
			Log::info($server);
		});

		Patrol::webhook('test', function ($event) 
		{
			Log::info($event);
		});
	}
}

protected function schedule(Schedule $schedule)
{
    // This command will scan your modules on a daily basis, at midnight.
	$schedule->command('patrol:run')->dailyAt('00:00');
}

php artisan vendor:publish --provider="PatrolServer\Patrol\PatrolServiceProvider"