diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index f9977878988c..ec86da941082 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -966,16 +966,17 @@ class InvoiceController extends BaseController */ public function upload(UploadInvoiceRequest $request, Invoice $invoice) { + if (! $this->checkFeature(Account::FEATURE_DOCUMENTS)) { return $this->featureFailure(); } if ($request->has('documents')) { - $this->saveDocuments($request->file('documents'), $invoice); + $this->saveDocuments($request->file('documents'), $invoice, $request->input('is_public', true)); } if ($request->has('file')) { - $this->saveDocuments($request->file('documents'), $invoice); + $this->saveDocuments($request->file('documents'), $invoice, $request->input('is_public', true)); } return $this->itemResponse($invoice->fresh()); diff --git a/app/Http/Requests/Invoice/UploadInvoiceRequest.php b/app/Http/Requests/Invoice/UploadInvoiceRequest.php index 17af8468e9b3..8339f64aa393 100644 --- a/app/Http/Requests/Invoice/UploadInvoiceRequest.php +++ b/app/Http/Requests/Invoice/UploadInvoiceRequest.php @@ -44,6 +44,8 @@ class UploadInvoiceRequest extends Request $rules['file'] = $this->file_validation; } + $rules['is_public'] = 'sometimes|boolean'; + return $rules; } diff --git a/app/Jobs/Util/UploadFile.php b/app/Jobs/Util/UploadFile.php index 43417f3529a1..33aeef21c0b3 100644 --- a/app/Jobs/Util/UploadFile.php +++ b/app/Jobs/Util/UploadFile.php @@ -53,7 +53,7 @@ class UploadFile implements ShouldQueue public $disk; - public function __construct($file, $type, $user, $company, $entity, $disk = null, $is_public = false) + public function __construct($file, $type, $user, $company, $entity, $disk = null, $is_public = true) { $this->file = $file; $this->type = $type; diff --git a/app/Models/PaymentHash.php b/app/Models/PaymentHash.php index 233cb2d36731..daf6b6197d9f 100644 --- a/app/Models/PaymentHash.php +++ b/app/Models/PaymentHash.php @@ -20,7 +20,7 @@ use Illuminate\Database\Eloquent\Model; * @property string $hash * @property float $fee_total * @property int|null $fee_invoice_id - * @property mixed $data + * @property \stdClass $data * @property int|null $payment_id * @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $updated_at @@ -38,6 +38,13 @@ class PaymentHash extends Model 'data' => 'object', ]; + /** + * @class \App\Models\PaymentHash $this + * @property \App\Models\PaymentHash $data + * @class \stdClass $data + * @property string $raw_value + */ + /** * @return mixed @@ -75,9 +82,8 @@ class PaymentHash extends Model public function withData(string $property, $value): self { - $this->data = array_merge((array) $this->data, [$property => $value]); - $this->save(); - - return $this; + $this->data = array_merge((array) $this->data, [$property => $value]); // @phpstan-ignore-line + $this->save();// @phpstan-ignore-line + return $this; // @phpstan-ignore-line } } diff --git a/app/PaymentDrivers/CheckoutCom/CheckoutWebhook.php b/app/PaymentDrivers/CheckoutCom/CheckoutWebhook.php index 5b9b51599982..c7c1069c63ff 100644 --- a/app/PaymentDrivers/CheckoutCom/CheckoutWebhook.php +++ b/app/PaymentDrivers/CheckoutCom/CheckoutWebhook.php @@ -88,14 +88,15 @@ class CheckoutWebhook implements ShouldQueue $driver = $this->company_gateway->driver($payment_hash->fee_invoice->client)->init()->setPaymentMethod(); - $payment_hash->data = array_merge((array) $payment_hash->data, $this->webhook_array); - $payment_hash->save(); - $driver->setPaymentHash($payment_hash); + $payment_hash->data = array_merge((array) $payment_hash->data, $this->webhook_array); // @phpstan-ignore-line + $payment_hash->save(); + $driver->setPaymentHash($payment_hash); + // @phpstan-ignore-line $data = [ 'payment_method' => isset($this->webhook_array['source']['id']) ? $this->webhook_array['source']['id'] : '', 'payment_type' => PaymentType::CREDIT_CARD_OTHER, - 'amount' => $payment_hash->data->raw_value, + 'amount' => $payment_hash->data->raw_value, // @phpstan-ignore-line 'transaction_reference' => $payment_object['id'], 'gateway_type_id' => GatewayType::CREDIT_CARD, ]; diff --git a/app/PaymentDrivers/CheckoutCom/Webhook.php b/app/PaymentDrivers/CheckoutCom/Webhook.php index 187d2dad2220..8fc5744762b7 100644 --- a/app/PaymentDrivers/CheckoutCom/Webhook.php +++ b/app/PaymentDrivers/CheckoutCom/Webhook.php @@ -66,8 +66,6 @@ class Webhook /** * Lists the workflows in Checkout - * - * @return void */ public function getWorkFlows() {