diff --git a/README.md b/README.md index 1333ed7..2a93240 100644 --- a/README.md +++ b/README.md @@ -1 +1,78 @@ -TODO +# Laravel Fakturoid + +Simple wrapper for official php package https://github.com/fakturoid/fakturoid-php + +### Docs + +- [Installation](#installation) +- [Configuration](#configuration) +- [Examples](#examples) + +## Installation + +### Step 1: Install package + +Add the package in your composer.json by executing the command. + +```bash +composer require dominik-wbz/laravel-fakturoid +``` + +This will both update composer.json and install the package into the vendor/ directory. + +Next, add the service provider and facade to `config/app.php` + +Add the service provider to providers: + +``` +'providers' => [ + ... + WEBIZ\LaravelFakturoid\FakturoidServiceProvider::class, + ... +] +``` + +And add the facade to aliases: + +``` +'aliases' => [ + ... + 'Fakturoid' => WEBIZ\LaravelFakturoid\Facade::class, + ... +] +``` + +### Step 2: Configuration + +First initialise the config file by running this command: + +```bash +php artisan vendor:publish +``` + +With this command, initialize the configuration and modify the created file, located under `config/fakturoid.php`. + +## Configuration + +```php +return [ + 'account_name' => 'XXX', + 'account_email' => 'XXX', + 'account_api_key' => 'XXX', + 'app_contact' => 'PHPlib ', +]; +``` + +## Examples + +### Create Subject + +```php + +\Fakturoid::createSubject(array('name' => 'Firma s.r.o.', 'email' => 'aloha@pokus.cz')); + +``` + +## License + +Copyright (c) 2019 webiz eu s.r.o MIT Licensed. diff --git a/src/LaravelFakturoid.php b/src/LaravelFakturoid.php index 4b751a0..e501a22 100644 --- a/src/LaravelFakturoid.php +++ b/src/LaravelFakturoid.php @@ -8,9 +8,9 @@ class LaravelFakturoid { public function __construct() { $this->config = [ - 'app_name' => config('fakturoid.app_name'), - 'app_email' => config('fakturoid.app_email'), - 'app_api_key' => config('fakturoid.app_api_key'), + 'account_name' => config('fakturoid.app_name'), + 'account_email' => config('fakturoid.app_email'), + 'account_api_key' => config('fakturoid.app_api_key'), 'app_contact' => config('fakturoid.app_contact'), ]; $this->initFakturoid(); @@ -22,8 +22,15 @@ protected function initFakturoid() { return $this->fakturoid; } - public function gooo() { - dd($this); + public function __call($name, $arguments) { + if (method_exists($this, $name)) { + return $this->{$name}(...$arguments); + } else if (method_exists($this->fakturoid, $name)) { + $fakturoid = $this->fakturoid; + $methodResult = $fakturoid->{$name}(...$arguments); + return $methodResult; + } + return null; } } diff --git a/src/config.php b/src/config.php index 0edf358..fb07924 100644 --- a/src/config.php +++ b/src/config.php @@ -1,7 +1,7 @@ 'XXX', - 'app_email' => 'XXX', - 'app_api_key' => 'XXX', + 'account_name' => 'XXX', + 'account_email' => 'XXX', + 'account_api_key' => 'XXX', 'app_contact' => 'PHPlib ', ]; \ No newline at end of file