Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

DocumentStore.php 1.9KB

3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\File;
  3. use App\Entity\Address\Address;
  4. use Lc\CaracoleBundle\Model\File\DocumentInterface;
  5. use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
  6. use Lc\CaracoleBundle\Repository\SectionStoreTrait;
  7. use Lc\CaracoleBundle\Repository\AbstractStore;
  8. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  9. class DocumentStore extends AbstractStore
  10. {
  11. use MerchantStoreTrait;
  12. protected DocumentRepositoryQuery $query;
  13. public function __construct(DocumentRepositoryQuery $query)
  14. {
  15. $this->query = $query;
  16. }
  17. public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  18. {
  19. $query->orderBy('id');
  20. return $query;
  21. }
  22. public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  23. {
  24. $query->filterIsOnlineAndOffline();
  25. if(isset($this->merchant) && $this->merchant) {
  26. $query->filterByMerchant($this->merchant);
  27. }
  28. return $query;
  29. }
  30. public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  31. {
  32. return $query;
  33. }
  34. public function getOneLatestByType(string $documentType, $query = null): DocumentInterface
  35. {
  36. $query = $this->createDefaultQuery($query);
  37. $query
  38. ->filterByType($documentType)
  39. ->orderBy('createdAt', 'DESC');
  40. return $query->findOne();
  41. }
  42. // findLastInvoice
  43. public function getOneLastInvoice($query = null)
  44. {
  45. $query = $this->createDefaultQuery($query);
  46. $query
  47. ->orderBy('createdAt', 'DESC');
  48. return $query->findOne();
  49. }
  50. public function getByBuyerAddress(Address $buyerAddress, $query = null)
  51. {
  52. $query = $this->createDefaultQuery($query);
  53. $query->filterByBuyerAddress($buyerAddress);
  54. return $query->find();
  55. }
  56. }