1. Go to this page and download the library: Download germania-kg/salesmen 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/ */
germania-kg / salesmen example snippets
public function getSalesmanId()
extends SalesmanIdProviderInterface
public function setSalesmanId( $id )
public $salesman_id;
public function getSalesmanId()
use SalesmanIdProviderTrait;
public function setSalesmanId( $salesman )
use Germania\Salesmen\SalesmanIdProviderInterface;
use Germania\Salesmen\SalesmanIdProviderTrait;
class Salesman implements SalesmanIdProviderInterface
{
use SalesmanIdProviderTrait;
public function __construct( $salesman_id )
{
$this->salesman_id = $salesman_id;
}
}
$salesman = new Salesman( 99 );
echo $salesman->getSalesmanId(); // 99
use Germania\Salesmen\ SalesmanIdAwareInterface;
use Germania\Salesmen\SalesmanIdAwareTrait;
class MyOrder implements SalesmanIdAwareInterface
{
use SalesmanIdAwareTrait;
}
$order = new MyOrder;
$order->setSalesmanId( 34 );
echo $order->getSalesmanId(); // 34
use Germania\Salesmen\SalesmanFilterIterator;
// Prepare some SalesmanIdProviderInterface instances:
$order1 = new MyOrder;
$order1->setSalesmanId( 1 );
$order2 = new MyOrder;
$order2->setSalesmanId( 20 );
$order3 = new MyOrder;
$order4->setSalesmanId( 999 );
$orders = [
$order1,
$order2,
$order3
];
// ---------------------------------------
// Filter by ID or ID array:
// ---------------------------------------
// should be '1'
$filter = new SalesmanFilterIterator( new \ArrayIterator( $orders ) , 20);
echo iterator_count($filter);
// should be '2'
$filter = new SalesmanFilterIterator( new \ArrayIterator( $orders ), array(20, 999));
echo iterator_count($filter);
// ---------------------------------------
// Filter by SalesmanIdProviderInterface:
// ---------------------------------------
$salesman = new Salesman( 1 );
$filter = new SalesmanFilterIterator( new \ArrayIterator( $orders ), $salesman);
// should be '1'
echo iterator_count($filter);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.