PHPackages                             noxxie/ptv-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. noxxie/ptv-laravel

ActiveLibrary[Database &amp; ORM](/categories/database)

noxxie/ptv-laravel
==================

Interface between your application and the PTV transfer database

2.0.0(7y ago)012MITPHP

Since Mar 6Pushed 7y ago1 watchersCompare

[ Source](https://github.com/NoxxieNl/ptv-laravel)[ Packagist](https://packagist.org/packages/noxxie/ptv-laravel)[ RSS](/packages/noxxie-ptv-laravel/feed)WikiDiscussions master Synced yesterday

READMEChangelog (4)Dependencies (2)Versions (7)Used By (0)

PTV-Laravel
===========

[](#ptv-laravel)

[![StyleCi](https://camo.githubusercontent.com/6c73610c680ade42e881715a604aa8b2c12c8436f116b297c5744adf0abaede7/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3137343133303236372f736869656c64)](https://camo.githubusercontent.com/6c73610c680ade42e881715a604aa8b2c12c8436f116b297c5744adf0abaede7/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3137343133303236372f736869656c64)[![license](https://camo.githubusercontent.com/ee1539acb390391843d3ac2e330721a63c405cfb67195f5afabd2e6ecb326161/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6e6f787869652f7074762d6c61726176656c2e737667)](https://camo.githubusercontent.com/ee1539acb390391843d3ac2e330721a63c405cfb67195f5afabd2e6ecb326161/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6e6f787869652f7074762d6c61726176656c2e737667)[![version](https://camo.githubusercontent.com/f53d2968eaee85795b1e65014e3196fb0593006c72dfb728cc80257d691cbecf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e6f787869652f7074762d6c61726176656c2e737667)](https://camo.githubusercontent.com/f53d2968eaee85795b1e65014e3196fb0593006c72dfb728cc80257d691cbecf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e6f787869652f7074762d6c61726176656c2e737667)[![activity](https://camo.githubusercontent.com/86e979fb2f72fe8a8dc575effbc5bdb5e090d165e1abce0e96d1b9ce2c469bc7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f6e6f787869656e6c2f7074762d6c61726176656c2e737667)](https://camo.githubusercontent.com/86e979fb2f72fe8a8dc575effbc5bdb5e090d165e1abce0e96d1b9ce2c469bc7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f6e6f787869656e6c2f7074762d6c61726176656c2e737667)

This package allows you to manage the import and export from data from and to the `transfer database` of an PTV application. This package uses the transferDB option within PTV to transfer data to and from PTV.

Installation
------------

[](#installation)

This package can be used in Laravel 5.4 or higher. Older versions are currently not supported. You can install the package via composer:

`composer require noxxie/ptv-laravel`

The service provider will automatically get registered. Or you may manually add the service provider in your `config/app.php` file:

```
'providers' => [
     ...
     Noxxie\Ptv\PtvServiceProvider::class,
];
```

You can publish the config file with: `php artisan vendor:publish --provider="Noxxie\Ptv\PtvServiceProvider" --tag="config"`

With the publication of the config file you change allot of default values as well add additional values to fit your needs. Reed the **config** for more information regarding configuration this package.

Configuration
-------------

[](#configuration)

When the configuration file is published you can configure allot of settings using the configuration file.

`connection`, With this option you can specify what connection name this package needs to use in order to connect to your PTV transfer database. And so its *important* that you specify a extra databsae connection in your `config/database.php` file. By default this package will search for a connection with the name `ptv`.

Example of a database connection:

```
...
'ptv'  =>  [
    'driver'            =>  'sqlsrv',
    'host'              =>  '',
    'port'              =>  '1433',
    'database'          =>  '',
    'username'          =>  '',
    'password'          =>  '',
    'charset'           =>  'utf8',
    'prefix'            =>  '',
    'prefix_indexes'    =>  true,
],
...
```

**Heads up**: defining your SQL database settings directly in `config/database.php` will result in that your username and password data will be uploaded into any git you may use. Be advised that using the `environment` file is much safer. (See the laravel documentation regarding environment variables).

`friendly_naming`, This option allows you to use easier naming when writing imports for an order. I personally am always confused with what column name was used for which action and in what table it was stored. With the friendly naming option you can "translate" the column names to a easier to remember name.

By default this package comes with pre configured easy naming options. For example when importing an order I wanted a easier naming for the address data so it made more sense for me:

```
'IORA_ORDER_ACTIONPOINT'  =>  [
    'postcode'      =>  'IORA_POSTCODE',
    'city'          =>  'IORA_CITY',
    'country'       =>  'IORA_COUNTRY',
    'street'        =>  'IORA_STREET',
    'houseno'       =>  'IORA_HOUSENO',
    'timewindow'    =>  'IORA_HANDLINGTIME_CLASS',
    'from'          =>  'IORA_EARLIEST_DATETIME',
    'till'          =>  'IORA_LATEST_DATETIME',
],
```

Now with the above set in `friendly_naming` the package will automatically convert all the attributes to there correct column name.

`Defaults`, With this option you can set default values that are always required when you import an order but actually they never change when you want to create a new order. Instead of defining them with each import you can define them once inside the configuration class and they will be automatically injected in to your new order when you create one.

Please note that the default options are the first once to be set when you create a new order, and so you can overwrite every default option when you create a new order.

Also with the default option you can use `placeholders` that are replaced with data when you create an order. The following are available:

- `%UNIQUE_ID%`, will be replaced by a unique ID that is not used within the transfer database
- `%CURRENT_DATE%`, will be replaced by the current date (format Ymd)
- `%UNIQUE_IORA_ID%`, will be replaced by a unique ID that is used for creating new order locations within PTV

If you are **NOT** sure how to deal with this options with regard to the transfer database from PTV do **NOT** change the placeholders that are already in place by default within this package.

Usage
-----

[](#usage)

This package can be used in different ways how to access the `order` or `route` instance.

### Dependency injection

[](#dependency-injection)

You can access one by dependency injection provided by Laravel:

```
