mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 08:14:44 -04:00
add repository for quickbooks data
This commit is contained in:
parent
ee334fd974
commit
4c3829b8c1
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repositories\Import\Quickbooks\Contracts;
|
||||||
|
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
interface RepositoryInterface {
|
||||||
|
|
||||||
|
function get(int $max = 100): Collection;
|
||||||
|
function all(): Collection;
|
||||||
|
function count(): int;
|
||||||
|
}
|
11
app/Repositories/Import/Quickbooks/CustomerRepository.php
Normal file
11
app/Repositories/Import/Quickbooks/CustomerRepository.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repositories\Import\QuickBooks;
|
||||||
|
|
||||||
|
use App\Repositories\Import\Quickbooks\Repository;
|
||||||
|
use App\Repositories\Import\Quickbooks\Contracts\RepositoryInterface;
|
||||||
|
|
||||||
|
class CustomerRepository extends Repository implements RepositoryInterface
|
||||||
|
{
|
||||||
|
protected string $entity = "Customer";
|
||||||
|
}
|
38
app/Repositories/Import/Quickbooks/Repository.php
Normal file
38
app/Repositories/Import/Quickbooks/Repository.php
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repositories\Import\QuickBooks;
|
||||||
|
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use App\Repositories\Import\Quickbooks\Contracts\RepositoryInterface;
|
||||||
|
use App\Services\Import\Quickbooks\Contracts\SdkInterface as QuickbooksInterface;
|
||||||
|
use App\Repositories\Import\Quickbooks\Transformers\Transformer as QuickbooksTransformer;
|
||||||
|
|
||||||
|
abstract class Repository implements RepositoryInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
protected string $entity;
|
||||||
|
protected QuickbooksInterface $db;
|
||||||
|
protected QuickbooksTransformer $transfomer;
|
||||||
|
|
||||||
|
public function __construct(QuickbooksInterface $db, QuickbooksTransformer $transfomer)
|
||||||
|
{
|
||||||
|
$this->db= $db;
|
||||||
|
$this->transformer = $transfomer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function count() : int {
|
||||||
|
return $this->db->totalRecords($this->entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function all() : Collection
|
||||||
|
{
|
||||||
|
return $this->get($this->count());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get(int $max = 100): Collection
|
||||||
|
{
|
||||||
|
return $this->transformer->transform($this->db->fetchRecords($this->entity, $max), $this->entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user