diff --git a/app/Repositories/ClientRepository.php b/app/Repositories/ClientRepository.php index be461b6f1141..72cdf83b0605 100644 --- a/app/Repositories/ClientRepository.php +++ b/app/Repositories/ClientRepository.php @@ -15,6 +15,7 @@ use App\Factory\ClientFactory; use App\Models\Client; use App\Repositories\ClientContactRepository; use App\Utils\Traits\GeneratesCounter; +use App\Utils\Traits\SavesDocuments; use Illuminate\Http\Request; /** @@ -23,6 +24,8 @@ use Illuminate\Http\Request; class ClientRepository extends BaseRepository { use GeneratesCounter; + use SavesDocuments; + /** * @var ClientContactRepository */ @@ -75,6 +78,9 @@ class ClientRepository extends BaseRepository $data['name'] = $client->present()->name(); } + if (array_key_exists('documents', $data)) { + $this->saveDocuments($data['documents'], $client); + } return $client; } diff --git a/app/Repositories/PaymentRepository.php b/app/Repositories/PaymentRepository.php index 2237f992fb86..245c02795a96 100644 --- a/app/Repositories/PaymentRepository.php +++ b/app/Repositories/PaymentRepository.php @@ -21,6 +21,7 @@ use App\Models\Invoice; use App\Models\Payment; use App\Repositories\CreditRepository; use App\Utils\Traits\MakesHash; +use App\Utils\Traits\SavesDocuments; use Illuminate\Http\Request; use Illuminate\Support\Carbon; @@ -30,6 +31,7 @@ use Illuminate\Support\Carbon; class PaymentRepository extends BaseRepository { use MakesHash; + use SavesDocuments; protected $credit_repo; @@ -89,6 +91,9 @@ class PaymentRepository extends BaseRepository $payment->status_id = Payment::STATUS_COMPLETED; $payment->save(); + if (array_key_exists('documents', $data)) { + $this->saveDocuments($data['documents'], $payment); + } /*Ensure payment number generated*/ if (!$payment->number || strlen($payment->number) == 0) { diff --git a/app/Repositories/ProductRepository.php b/app/Repositories/ProductRepository.php index 8ed886fc6f7f..744694330baa 100644 --- a/app/Repositories/ProductRepository.php +++ b/app/Repositories/ProductRepository.php @@ -12,6 +12,7 @@ namespace App\Repositories; use App\Models\Product; +use App\Utils\Traits\SavesDocuments; use Illuminate\Http\Request; /** @@ -19,6 +20,8 @@ use Illuminate\Http\Request; */ class ProductRepository extends BaseRepository { + use SavesDocuments; + public function getClassName() { return Product::class; @@ -34,6 +37,10 @@ class ProductRepository extends BaseRepository $product->fill($data); $product->save(); + if (array_key_exists('documents', $data)) { + $this->saveDocuments($data['documents'], $product); + } + return $product; } }