1. Go to this page and download the library: Download aybarsm/laravel-pandle 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/ */
aybarsm / laravel-pandle example snippets
use Aybarsm\Laravel\Pandle\Contracts\ClientContract as PandleClient;
class YourController extends Controller
{
public function __construct(protected PandleClient $pandle) {}
public function index()
{
// Get authenticated user info
$me = $this->pandle->me();
// Get company instance
$company = $this->pandle->company(123456);
// Get bank accounts
$bankAccounts = $company->getBankAccounts();
// Get customers
$customers = $company->getCustomers();
}
}
use Aybarsm\Laravel\Pandle\Contracts\ClientContract;
use Aybarsm\Laravel\Pandle\Contracts\HandlerContract;
use Aybarsm\Laravel\Pandle\Contracts\CompanyContract;
use Aybarsm\Laravel\Pandle\Contracts\AccessTokenContract;
// Example of clean DI in action
class Company implements CompanyContract
{
public function __construct(
protected ClientContract $client
) {}
}
declare(strict_types=1);
namespace Aybarsm\Laravel\Pandle;
use Aybarsm\Laravel\Pandle\Contracts\AccessTokenContract;
use Aybarsm\Laravel\Pandle\Contracts\ClientContract;
use Aybarsm\Laravel\Pandle\Contracts\CompanyContract;
use Aybarsm\Laravel\Pandle\Contracts\HandlerContract;
use Illuminate\Support\ServiceProvider;
final class PandleServiceProvider extends ServiceProvider
{
public function register(): void
{
$this->mergeConfigFrom(
__DIR__.'/../config/pandle.php',
'pandle'
);
$this->app->bindIf(AccessTokenContract::class, AccessToken::class);
$this->app->singletonIf(HandlerContract::class, Handler::class);
$this->app->bindIf(CompanyContract::class, Company::class);
$this->app->singletonIf(ClientContract::class, Client::class);
}
public function boot(): void
{
if ($this->app->runningInConsole()) {
$this->publishes([
__DIR__.'/../config/pandle.php' => config_path('pandle.php'),
]);
}
}
}
namespace App\Providers;
use Aybarsm\Laravel\Pandle\Contracts\HandlerContract;
use Your\Custom\PandleHandler;
class AppServiceProvider extends ServiceProvider
{
public function register(): void
{
$this->app->singleton(HandlerContract::class, function ($app){
return new PandleHandler();
});
}
}