Add documents to A_N_Y_T_H_I_N_G

This commit is contained in:
David Bomba 2020-06-22 21:36:39 +10:00
parent 7af826fa7f
commit 849e6040bd
3 changed files with 18 additions and 0 deletions

View File

@ -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;
}

View File

@ -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) {

View File

@ -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;
}
}