diff --git a/app/Console/Commands/CreateSingleAccount.php b/app/Console/Commands/CreateSingleAccount.php index ecdcc40ea558..ba83e7ecba92 100644 --- a/app/Console/Commands/CreateSingleAccount.php +++ b/app/Console/Commands/CreateSingleAccount.php @@ -516,8 +516,8 @@ class CreateSingleAccount extends Command $cg->user_id = $user->id; $cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23'; $cg->require_cvv = true; - $cg->show_billing_address = true; - $cg->show_shipping_address = true; + $cg->require_billing_address = true; + $cg->require_shipping_address = true; $cg->update_details = true; $cg->config = encrypt(config('ninja.testvars.stripe')); $cg->save(); @@ -527,8 +527,8 @@ class CreateSingleAccount extends Command // $cg->user_id = $user->id; // $cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23'; // $cg->require_cvv = true; - // $cg->show_billing_address = true; - // $cg->show_shipping_address = true; + // $cg->require_billing_address = true; + // $cg->require_shipping_address = true; // $cg->update_details = true; // $cg->config = encrypt(config('ninja.testvars.stripe')); // $cg->save(); @@ -540,8 +540,8 @@ class CreateSingleAccount extends Command $cg->user_id = $user->id; $cg->gateway_key = '38f2c48af60c7dd69e04248cbb24c36e'; $cg->require_cvv = true; - $cg->show_billing_address = true; - $cg->show_shipping_address = true; + $cg->require_billing_address = true; + $cg->require_shipping_address = true; $cg->update_details = true; $cg->config = encrypt(config('ninja.testvars.paypal')); $cg->save(); @@ -553,8 +553,8 @@ class CreateSingleAccount extends Command $cg->user_id = $user->id; $cg->gateway_key = '3758e7f7c6f4cecf0f4f348b9a00f456'; $cg->require_cvv = true; - $cg->show_billing_address = true; - $cg->show_shipping_address = true; + $cg->require_billing_address = true; + $cg->require_shipping_address = true; $cg->update_details = true; $cg->config = encrypt(config('ninja.testvars.checkout')); $cg->save(); @@ -566,8 +566,8 @@ class CreateSingleAccount extends Command $cg->user_id = $user->id; $cg->gateway_key = '3b6621f970ab18887c4f6dca78d3f8bb'; $cg->require_cvv = true; - $cg->show_billing_address = true; - $cg->show_shipping_address = true; + $cg->require_billing_address = true; + $cg->require_shipping_address = true; $cg->update_details = true; $cg->config = encrypt(config('ninja.testvars.authorize')); $cg->save(); diff --git a/app/Http/Controllers/CompanyController.php b/app/Http/Controllers/CompanyController.php index c703fe983b8f..f6668b6048f9 100644 --- a/app/Http/Controllers/CompanyController.php +++ b/app/Http/Controllers/CompanyController.php @@ -408,6 +408,10 @@ class CompanyController extends BaseController */ public function update(UpdateCompanyRequest $request, Company $company) { + + if($request->hasFile('company_logo') || !array_key_exists('company_logo', $request->input('settings'))) + $this->removeLogo($company); + $company = $this->company_repo->save($request->all(), $company); $company->saveSettings($request->input('settings'), $company); diff --git a/app/Http/Controllers/OpenAPI/CompanyGatewaySchema.php b/app/Http/Controllers/OpenAPI/CompanyGatewaySchema.php index a5009d01b461..ed483fd0585b 100644 --- a/app/Http/Controllers/OpenAPI/CompanyGatewaySchema.php +++ b/app/Http/Controllers/OpenAPI/CompanyGatewaySchema.php @@ -7,8 +7,8 @@ * @OA\Property(property="company_id", type="string", example="2", description="______"), * @OA\Property(property="gateway_key", type="string", example="2", description="______"), * @OA\Property(property="accepted_credit_cards", type="integer", example="32", description="Bitmask representation of cards"), - * @OA\Property(property="show_billing_address", type="boolean", example=true, description="______"), - * @OA\Property(property="show_shipping_address", type="boolean", example=true, description="______"), + * @OA\Property(property="require_billing_address", type="boolean", example=true, description="______"), + * @OA\Property(property="require_shipping_address", type="boolean", example=true, description="______"), * @OA\Property(property="config", type="string", example="dfadsfdsafsafd", description="The configuration map for the gateway"), * @OA\Property(property="update_details", type="boolean", example=true, description="______"), * @OA\Property( diff --git a/app/Jobs/Product/UpdateOrCreateProduct.php b/app/Jobs/Product/UpdateOrCreateProduct.php index 7f45f30c532d..210046f6fced 100644 --- a/app/Jobs/Product/UpdateOrCreateProduct.php +++ b/app/Jobs/Product/UpdateOrCreateProduct.php @@ -18,7 +18,6 @@ use App\Models\Product; use App\Repositories\InvoiceRepository; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Database\Capsule\Eloquent; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; @@ -27,11 +26,11 @@ class UpdateOrCreateProduct implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; - private $products; + public $products; - private $invoice; + public $invoice; - private $company; + public $company; /** * Create a new job instance. @@ -58,8 +57,15 @@ class UpdateOrCreateProduct implements ShouldQueue public function handle() { MultiDB::setDB($this->company->db); + + //only update / create products - not tasks or gateway fees + $updateable_products = collect($this->products)->filter(function ($item) { - foreach ($this->products as $item) { + return $item->type_id == 1; + + }); + + foreach ($updateable_products as $item) { if (empty($item->product_key)) { continue; } diff --git a/app/Models/CompanyGateway.php b/app/Models/CompanyGateway.php index 0de3bd5f226e..eae78caf1769 100644 --- a/app/Models/CompanyGateway.php +++ b/app/Models/CompanyGateway.php @@ -38,8 +38,12 @@ class CompanyGateway extends BaseModel 'gateway_key', 'accepted_credit_cards', 'require_cvv', - 'show_billing_address', - 'show_shipping_address', + 'require_billing_address', + 'require_shipping_address', + 'require_client_name', + 'require_zip', + 'require_client_phone', + 'require_contact_name', 'update_details', 'config', 'fees_and_limits', diff --git a/app/Models/Credit.php b/app/Models/Credit.php index 63050b2a7b65..cd11e9ea578c 100644 --- a/app/Models/Credit.php +++ b/app/Models/Credit.php @@ -26,6 +26,7 @@ use App\Utils\Traits\MakesInvoiceValues; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Support\Carbon; +use Illuminate\Support\Facades\Storage; use Laracasts\Presenter\PresentableTrait; class Credit extends BaseModel diff --git a/app/Repositories/BaseRepository.php b/app/Repositories/BaseRepository.php index 553b869e51a1..54ec44405f52 100644 --- a/app/Repositories/BaseRepository.php +++ b/app/Repositories/BaseRepository.php @@ -34,24 +34,6 @@ class BaseRepository use MakesHash; use SavesDocuments; - /** - * @return null - */ - public function getClassName() - { - return null; - } - - /** - * @return mixed - */ - private function getInstance() - { - $className = $this->getClassName(); - - return new $className(); - } - /** * @param $entity * @param $type @@ -153,25 +135,6 @@ class BaseRepository return count($entities); } - /** - * @param $ids - * - * @return mixed - */ - public function findByPublicIds($ids) - { - return $this->getInstance()->scope($ids)->get(); - } - - /** - * @param $ids - * - * @return mixed - */ - public function findByPublicIdsWithTrashed($ids) - { - return $this->getInstance()->scope($ids)->withTrashed()->get(); - } public function getInvitation($invitation, $resource) { diff --git a/app/Repositories/ClientRepository.php b/app/Repositories/ClientRepository.php index 806fa4ba553e..e4924f387f7e 100644 --- a/app/Repositories/ClientRepository.php +++ b/app/Repositories/ClientRepository.php @@ -39,17 +39,7 @@ class ClientRepository extends BaseRepository { $this->contact_repo = $contact_repo; } - - /** - * Gets the class name. - * - * @return string The class name. - */ - public function getClassName() - { - return Client::class; - } - + /** * Saves the client and its contacts. * diff --git a/app/Repositories/CompanyRepository.php b/app/Repositories/CompanyRepository.php index 296e3fba29a7..70941a8a0ae0 100644 --- a/app/Repositories/CompanyRepository.php +++ b/app/Repositories/CompanyRepository.php @@ -23,22 +23,12 @@ class CompanyRepository extends BaseRepository { } - /** - * Gets the class name. - * - * @return string The class name. - */ - public function getClassName() - { - return Company::class; - } - /** * Saves the client and its contacts. * * @param array $data The data * @param Company $company - * @return Client|Company|null Company Object + * @return Company|null Company Object */ public function save(array $data, Company $company) : ?Company { diff --git a/app/Repositories/CreditRepository.php b/app/Repositories/CreditRepository.php index dd2963a316a1..5092fc8881ab 100644 --- a/app/Repositories/CreditRepository.php +++ b/app/Repositories/CreditRepository.php @@ -30,15 +30,6 @@ class CreditRepository extends BaseRepository { } - /** - * Gets the class name. - * - * @return string The class name. - */ - public function getClassName() - { - return Credit::class; - } /** * Saves the client and its contacts. diff --git a/app/Repositories/DesignRepository.php b/app/Repositories/DesignRepository.php index 353774e999d0..97a53dd8734e 100644 --- a/app/Repositories/DesignRepository.php +++ b/app/Repositories/DesignRepository.php @@ -11,30 +11,10 @@ namespace App\Repositories; -use App\Libraries\MultiDB; -use App\Models\Activity; -use App\Models\Backup; -use App\Models\Client; -use App\Models\Design; -use App\Models\Invoice; -use App\Models\User; -use App\Utils\Traits\MakesInvoiceHtml; -use Illuminate\Support\Facades\Log; - /** - * Class for activity repository. + * Class for DesignRepository . */ class DesignRepository extends BaseRepository { - use MakesInvoiceHtml; - /** - * Gets the class name. - * - * @return string The class name. - */ - public function getClassName() - { - return Design::class; - } } diff --git a/app/Repositories/DocumentRepository.php b/app/Repositories/DocumentRepository.php index 595fcc732dab..b9521dc954cd 100644 --- a/app/Repositories/DocumentRepository.php +++ b/app/Repositories/DocumentRepository.php @@ -19,15 +19,6 @@ use App\Utils\Ninja; */ class DocumentRepository extends BaseRepository { - /** - * Gets the class name. - * - * @return string The class name. - */ - public function getClassName() - { - return Document::class; - } public function delete($document) { @@ -43,8 +34,8 @@ class DocumentRepository extends BaseRepository $document->restore(); - if (class_exists($className)) { - event(new $className($document, $document->company, Ninja::eventVars())); - } + // if (class_exists($className)) { + // event(new $className($document, $document->company, Ninja::eventVars())); + // } } } diff --git a/app/Repositories/ExpenseRepository.php b/app/Repositories/ExpenseRepository.php index 0044514ffbdd..da7f7f80c916 100644 --- a/app/Repositories/ExpenseRepository.php +++ b/app/Repositories/ExpenseRepository.php @@ -24,27 +24,14 @@ class ExpenseRepository extends BaseRepository { use GeneratesCounter; - public function __construct() - { - } - - /** - * Gets the class name. - * - * @return string The class name. - */ - public function getClassName() - { - return Expense::class; - } /** * Saves the expense and its contacts. * - * @param array $data The data - * @param \App\Models\expense $expense The expense + * @param array $data The data + * @param \App\Models\Expense $expense The expense * - * @return expense|null expense Object + * @return \App\Models\Expense|Null expense Object */ public function save(array $data, Expense $expense) : ?Expense { @@ -63,7 +50,7 @@ class ExpenseRepository extends BaseRepository * Store expenses in bulk. * * @param array $expense - * @return expense|null + * @return \App\Models\Expense|null */ public function create($expense): ?Expense { diff --git a/app/Repositories/GroupSettingRepository.php b/app/Repositories/GroupSettingRepository.php index fd0ebb4d9ce9..d1aac1dda4d9 100644 --- a/app/Repositories/GroupSettingRepository.php +++ b/app/Repositories/GroupSettingRepository.php @@ -12,21 +12,9 @@ namespace App\Repositories; use App\Models\GroupSetting; -use App\Utils\Traits\MakesHash; class GroupSettingRepository extends BaseRepository { - use MakesHash; - - /** - * Gets the class name. - * - * @return string The class name. - */ - public function getClassName() - { - return GroupSetting::class; - } public function save($data, GroupSetting $group_setting) :?GroupSetting { diff --git a/app/Repositories/InvoiceRepository.php b/app/Repositories/InvoiceRepository.php index a6d00636803e..12a22121e484 100644 --- a/app/Repositories/InvoiceRepository.php +++ b/app/Repositories/InvoiceRepository.php @@ -27,23 +27,14 @@ class InvoiceRepository extends BaseRepository { use MakesHash; - /** - * Gets the class name. - * - * @return string The class name. - */ - public function getClassName() - { - return Invoice::class; - } /** * Saves the invoices. * - * @param array. $data The invoice data - * @param InvoiceSum|Invoice $invoice The invoice + * @param array $data The invoice data + * @param Invoice $invoice The invoice * - * @return Invoice|InvoiceSum|null Returns the invoice object + * @return Invoice|null Returns the invoice object */ public function save($data, Invoice $invoice):?Invoice { @@ -75,19 +66,17 @@ class InvoiceRepository extends BaseRepository * ie. invoice can be deleted from a business logic perspective. * * @param Invoice $invoice - * @return void $invoice + * @return Invoice $invoice */ - public function delete($invoice) + public function delete($invoice) :Invoice { if ($invoice->is_deleted) { - return; + return $invoice; } $invoice->service()->markDeleted()->handleCancellation()->save(); - - - $invoice = parent::delete($invoice); + parent::delete($invoice); return $invoice; } diff --git a/app/Repositories/Migration/InvoiceMigrationRepository.php b/app/Repositories/Migration/InvoiceMigrationRepository.php index 9230c9a80bfd..1b28ec5c52f5 100644 --- a/app/Repositories/Migration/InvoiceMigrationRepository.php +++ b/app/Repositories/Migration/InvoiceMigrationRepository.php @@ -100,7 +100,7 @@ class InvoiceMigrationRepository extends BaseRepository $invitations = collect($data['invitations']); /* Get array of Keys which have been removed from the invitations array and soft delete each invitation */ - $model->invitations->pluck('key')->diff($invitations->pluck('key'))->each(function ($invitation) { + $model->invitations->pluck('key')->diff($invitations->pluck('key'))->each(function ($invitation) use($resource){ $this->getInvitation($invitation, $resource)->delete(); }); diff --git a/app/Repositories/Migration/PaymentMigrationRepository.php b/app/Repositories/Migration/PaymentMigrationRepository.php index 632c5ef47932..197e4eaac9ce 100644 --- a/app/Repositories/Migration/PaymentMigrationRepository.php +++ b/app/Repositories/Migration/PaymentMigrationRepository.php @@ -48,11 +48,6 @@ class PaymentMigrationRepository extends BaseRepository $this->activity_repo = new ActivityRepository(); } - public function getClassName() - { - return Payment::class; - } - /** * Saves and updates a payment. //todo refactor to handle refunds and payments. * diff --git a/app/Repositories/PaymentRepository.php b/app/Repositories/PaymentRepository.php index b83851a1ea39..de63f2472b25 100644 --- a/app/Repositories/PaymentRepository.php +++ b/app/Repositories/PaymentRepository.php @@ -41,15 +41,6 @@ class PaymentRepository extends BaseRepository $this->credit_repo = $credit_repo; } - /** - * @return string - */ - - public function getClassName() - { - return Payment::class; - } - /** * Saves and updates a payment. //todo refactor to handle refunds and payments. * diff --git a/app/Repositories/ProductRepository.php b/app/Repositories/ProductRepository.php index 350c7ebc39da..c5c8a1e7c0af 100644 --- a/app/Repositories/ProductRepository.php +++ b/app/Repositories/ProductRepository.php @@ -19,11 +19,6 @@ class ProductRepository extends BaseRepository { use SavesDocuments; - public function getClassName() - { - return Product::class; - } - /** * @param array $data * @param Product $product diff --git a/app/Repositories/ProjectRepository.php b/app/Repositories/ProjectRepository.php index b1010bf71d65..136ecadf9e55 100644 --- a/app/Repositories/ProjectRepository.php +++ b/app/Repositories/ProjectRepository.php @@ -19,13 +19,4 @@ use App\Models\Project; class ProjectRepository extends BaseRepository { - /** - * Gets the class name. - * - * @return string The class name. - */ - public function getClassName() - { - return Project::class; - } } diff --git a/app/Repositories/QuoteRepository.php b/app/Repositories/QuoteRepository.php index e0e70424fd6a..33aa4e34e554 100644 --- a/app/Repositories/QuoteRepository.php +++ b/app/Repositories/QuoteRepository.php @@ -27,12 +27,7 @@ use Illuminate\Http\Request; */ class QuoteRepository extends BaseRepository { - use MakesHash; - public function getClassName() - { - return Quote::class; - } public function save($data, Quote $quote) : ?Quote { diff --git a/app/Repositories/RecurringInvoiceRepository.php b/app/Repositories/RecurringInvoiceRepository.php index 7ef4d778ab36..9658caaaa533 100644 --- a/app/Repositories/RecurringInvoiceRepository.php +++ b/app/Repositories/RecurringInvoiceRepository.php @@ -20,10 +20,6 @@ use Illuminate\Http\Request; */ class RecurringInvoiceRepository extends BaseRepository { - public function getClassName() - { - return RecurringInvoice::class; - } public function save($data, RecurringInvoice $invoice) : ?RecurringInvoice { diff --git a/app/Repositories/RecurringQuoteRepository.php b/app/Repositories/RecurringQuoteRepository.php index 65e218e28dbe..a0894e8f3a9d 100644 --- a/app/Repositories/RecurringQuoteRepository.php +++ b/app/Repositories/RecurringQuoteRepository.php @@ -20,10 +20,7 @@ use Illuminate\Http\Request; */ class RecurringQuoteRepository extends BaseRepository { - public function getClassName() - { - return RecurringQuote::class; - } + public function save(Request $request, RecurringQuote $quote) : ?RecurringQuote { @@ -31,13 +28,10 @@ class RecurringQuoteRepository extends BaseRepository $quote->save(); - $quote_calc = new InvoiceSum($quote, $quote->settings); + $quote_calc = new InvoiceSum($quote); $quote = $quote_calc->build()->getQuote(); - //fire events here that cascading from the saving of an Quote - //ie. client balance update... - return $quote; } } diff --git a/app/Repositories/TaskRepository.php b/app/Repositories/TaskRepository.php index 639567c25686..75f0e7817570 100644 --- a/app/Repositories/TaskRepository.php +++ b/app/Repositories/TaskRepository.php @@ -23,19 +23,6 @@ class TaskRepository extends BaseRepository { use GeneratesCounter; - public function __construct() - { - } - - /** - * Gets the class name. - * - * @return string The class name. - */ - public function getClassName() - { - return Task::class; - } /** * Saves the task and its contacts. diff --git a/app/Repositories/TokenRepository.php b/app/Repositories/TokenRepository.php index 39a559f376b1..aef6e1e20f44 100644 --- a/app/Repositories/TokenRepository.php +++ b/app/Repositories/TokenRepository.php @@ -15,15 +15,7 @@ use App\Models\CompanyToken; class TokenRepository extends BaseRepository { - /** - * Gets the class name. - * - * @return string The class name. - */ - public function getClassName() - { - return CompanyToken::class; - } + /** * Saves the companytoken. diff --git a/app/Repositories/UserRepository.php b/app/Repositories/UserRepository.php index dfa0c531a117..6a55bd1aa5a6 100644 --- a/app/Repositories/UserRepository.php +++ b/app/Repositories/UserRepository.php @@ -27,24 +27,15 @@ class UserRepository extends BaseRepository { use MakesHash; - /** - * Gets the class name. - * - * @return string The class name. - */ - public function getClassName() - { - return User::class; - } /** * Saves the user and its contacts. * * @param array $data The data - * @param \App\Models\user $user The user + * @param \App\Models\User $user The user * * @param bool $unset_company_user - * @return user|\App\Models\user|null user Object + * @return \App\Models\User user Object */ public function save(array $data, User $user, $unset_company_user = false) { diff --git a/app/Repositories/VendorRepository.php b/app/Repositories/VendorRepository.php index 165478c7e5ff..9b15eb5a3f5f 100644 --- a/app/Repositories/VendorRepository.php +++ b/app/Repositories/VendorRepository.php @@ -13,7 +13,7 @@ namespace App\Repositories; use App\Factory\VendorFactory; use App\Models\Vendor; -use App\Repositories\VSendorContactRepository; +use App\Repositories\VendorContactRepository; use App\Utils\Traits\GeneratesCounter; use Illuminate\Http\Request; @@ -23,37 +23,24 @@ use Illuminate\Http\Request; class VendorRepository extends BaseRepository { use GeneratesCounter; - /** - * @var vendorContactRepository - */ + protected $contact_repo; /** - * vendorController constructor. - * @param vendorContactRepository $contact_repo + * VendorContactRepository constructor. */ public function __construct(VendorContactRepository $contact_repo) { $this->contact_repo = $contact_repo; } - /** - * Gets the class name. - * - * @return string The class name. - */ - public function getClassName() - { - return Vendor::class; - } - /** * Saves the vendor and its contacts. * * @param array $data The data - * @param \App\Models\vendor $vendor The vendor + * @param \App\Models\Vendor $vendor The vendor * - * @return vendor|\App\Models\vendor|null vendor Object + * @return vendor|\App\Models\Vendor|null Vendor Object * @throws \Laracasts\Presenter\Exceptions\PresenterException */ public function save(array $data, Vendor $vendor) : ?Vendor @@ -70,7 +57,7 @@ class VendorRepository extends BaseRepository $vendor->save(); if (isset($data['contacts'])) { - $contacts = $this->contact_repo->save($data, $vendor); + $this->contact_repo->save($data, $vendor); } if (empty($data['name'])) { diff --git a/app/Services/Credit/CreateInvitations.php b/app/Services/Credit/CreateInvitations.php index 4a742effd293..45c7b1bff7a2 100644 --- a/app/Services/Credit/CreateInvitations.php +++ b/app/Services/Credit/CreateInvitations.php @@ -40,7 +40,7 @@ class CreateInvitations extends AbstractService $ii->credit_id = $this->credit->id; $ii->client_contact_id = $contact->id; $ii->save(); - } elseif ($invitation && ! $contact->send_email) { + } elseif (! $contact->send_email) { $invitation->delete(); } }); diff --git a/app/Transformers/CompanyGatewayTransformer.php b/app/Transformers/CompanyGatewayTransformer.php index 160391b735cc..6cc59b8b98f1 100644 --- a/app/Transformers/CompanyGatewayTransformer.php +++ b/app/Transformers/CompanyGatewayTransformer.php @@ -49,8 +49,15 @@ class CompanyGatewayTransformer extends EntityTransformer 'gateway_key' => (string) $company_gateway->gateway_key ?: '', 'accepted_credit_cards' => (int) $company_gateway->accepted_credit_cards, 'require_cvv' => (bool) $company_gateway->require_cvv, - 'show_billing_address' => (bool) $company_gateway->show_billing_address, - 'show_shipping_address' => (bool) $company_gateway->show_shipping_address, + 'require_billing_address' => (bool) $company_gateway->require_billing_address, + 'require_shipping_address' => (bool) $company_gateway->require_shipping_address, + 'require_client_name' => (bool) $company_gateway->require_client_name, + 'require_zip' => (bool) $company_gateway->require_zip, + 'require_client_phone' => (bool) $company_gateway->require_client_phone, + 'require_contact_name' => (bool) $company_gateway->require_contact_name, + 'require_contact_email' => (bool) $company_gateway->require_contact_email, + 'show_billing_address' => (bool) $company_gateway->show_billing_address, //@deprecated + 'show_shipping_address' => (bool) $company_gateway->show_shipping_address, //@deprecated 'update_details' => (bool) $company_gateway->update_details, 'config' => (string) $company_gateway->getConfigTransformed(), 'fees_and_limits' => $company_gateway->fees_and_limits ?: new stdClass, diff --git a/app/Utils/Traits/Uploadable.php b/app/Utils/Traits/Uploadable.php index b802bb5e10d6..d11f53f5396c 100644 --- a/app/Utils/Traits/Uploadable.php +++ b/app/Utils/Traits/Uploadable.php @@ -11,13 +11,33 @@ namespace App\Utils\Traits; +use App\Jobs\Util\UnlinkFile; use App\Jobs\Util\UploadAvatar; +use Illuminate\Support\Facades\Storage; /** * Class Uploadable. */ trait Uploadable { + + public function removeLogo($company) + { + $company_logo = $company->settings->company_logo; + +info("company logo to be deleted = {$company_logo}"); + + $file_name = basename($company_logo); + + $storage_path = $company->company_key . '/' . $file_name; + + if (Storage::exists($storage_path)) { + UnlinkFile::dispatchNow(config('filesystems.default'), $storage_path); + } + + + } + public function uploadLogo($file, $company, $entity) { if ($file) { diff --git a/database/migrations/2020_11_03_200345_company_gateway_fields_refactor.php b/database/migrations/2020_11_03_200345_company_gateway_fields_refactor.php new file mode 100644 index 000000000000..18ac62d41d48 --- /dev/null +++ b/database/migrations/2020_11_03_200345_company_gateway_fields_refactor.php @@ -0,0 +1,36 @@ +renameColumn('show_billing_address', 'require_billing_address'); + $table->renameColumn('show_shipping_address', 'require_shipping_address'); + $table->boolean('require_client_name')->default(false); + $table->boolean('require_zip')->default(false); + $table->boolean('require_client_phone')->default(false); + $table->boolean('require_contact_name')->default(false); + $table->boolean('require_contact_email')->default(false); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +} diff --git a/database/seeders/RandomDataSeeder.php b/database/seeders/RandomDataSeeder.php index d2b75f333c52..d2e549129a2d 100644 --- a/database/seeders/RandomDataSeeder.php +++ b/database/seeders/RandomDataSeeder.php @@ -315,8 +315,8 @@ class RandomDataSeeder extends Seeder $cg->user_id = $user->id; $cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23'; $cg->require_cvv = true; - $cg->show_billing_address = true; - $cg->show_shipping_address = true; + $cg->require_billing_address = true; + $cg->require_shipping_address = true; $cg->update_details = true; $cg->config = encrypt(config('ninja.testvars.stripe')); $cg->save(); @@ -326,8 +326,8 @@ class RandomDataSeeder extends Seeder $cg->user_id = $user->id; $cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23'; $cg->require_cvv = true; - $cg->show_billing_address = true; - $cg->show_shipping_address = true; + $cg->require_billing_address = true; + $cg->require_shipping_address = true; $cg->update_details = true; $cg->config = encrypt(config('ninja.testvars.stripe')); $cg->save(); @@ -339,8 +339,8 @@ class RandomDataSeeder extends Seeder $cg->user_id = $user->id; $cg->gateway_key = '38f2c48af60c7dd69e04248cbb24c36e'; $cg->require_cvv = true; - $cg->show_billing_address = true; - $cg->show_shipping_address = true; + $cg->require_billing_address = true; + $cg->require_shipping_address = true; $cg->update_details = true; $cg->config = encrypt(config('ninja.testvars.paypal')); $cg->save(); @@ -352,8 +352,8 @@ class RandomDataSeeder extends Seeder $cg->user_id = $user->id; $cg->gateway_key = '3758e7f7c6f4cecf0f4f348b9a00f456'; $cg->require_cvv = true; - $cg->show_billing_address = true; - $cg->show_shipping_address = true; + $cg->require_billing_address = true; + $cg->require_shipping_address = true; $cg->update_details = true; $cg->config = encrypt(config('ninja.testvars.checkout')); $cg->save(); @@ -365,8 +365,8 @@ class RandomDataSeeder extends Seeder $cg->user_id = $user->id; $cg->gateway_key = '3b6621f970ab18887c4f6dca78d3f8bb'; $cg->require_cvv = true; - $cg->show_billing_address = true; - $cg->show_shipping_address = true; + $cg->require_billing_address = true; + $cg->require_shipping_address = true; $cg->update_details = true; $cg->config = encrypt(config('ninja.testvars.authorize')); $cg->save(); diff --git a/psalm.xml b/psalm.xml index 73bb3b38d930..2c1858a64e00 100644 --- a/psalm.xml +++ b/psalm.xml @@ -61,6 +61,16 @@ + + + + + + + + + + diff --git a/tests/Feature/CompanyGatewayResolutionTest.php b/tests/Feature/CompanyGatewayResolutionTest.php index 8de3d96a7f9c..b06d7eebc638 100644 --- a/tests/Feature/CompanyGatewayResolutionTest.php +++ b/tests/Feature/CompanyGatewayResolutionTest.php @@ -101,8 +101,8 @@ class CompanyGatewayResolutionTest extends TestCase $this->cg->user_id = $this->user->id; $this->cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23'; $this->cg->require_cvv = true; - $this->cg->show_billing_address = true; - $this->cg->show_shipping_address = true; + $this->cg->require_billing_address = true; + $this->cg->require_shipping_address = true; $this->cg->update_details = true; $this->cg->config = encrypt(json_encode($json_config)); $this->cg->fees_and_limits = $data; diff --git a/tests/Feature/CompanyGatewayTest.php b/tests/Feature/CompanyGatewayTest.php index 8dc1499fc17a..9d2159985c25 100644 --- a/tests/Feature/CompanyGatewayTest.php +++ b/tests/Feature/CompanyGatewayTest.php @@ -63,8 +63,8 @@ class CompanyGatewayTest extends TestCase $cg->user_id = $this->user->id; $cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23'; $cg->require_cvv = true; - $cg->show_billing_address = true; - $cg->show_shipping_address = true; + $cg->require_billing_address = true; + $cg->require_shipping_address = true; $cg->update_details = true; $cg->config = encrypt(config('ninja.testvars.stripe')); $cg->fees_and_limits = $data; @@ -133,8 +133,8 @@ class CompanyGatewayTest extends TestCase $cg->user_id = $this->user->id; $cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23'; $cg->require_cvv = true; - $cg->show_billing_address = true; - $cg->show_shipping_address = true; + $cg->require_billing_address = true; + $cg->require_shipping_address = true; $cg->update_details = true; $cg->config = encrypt(config('ninja.testvars.stripe')); $cg->fees_and_limits = $data; @@ -170,8 +170,8 @@ class CompanyGatewayTest extends TestCase $cg->user_id = $this->user->id; $cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23'; $cg->require_cvv = true; - $cg->show_billing_address = true; - $cg->show_shipping_address = true; + $cg->require_billing_address = true; + $cg->require_shipping_address = true; $cg->update_details = true; $cg->config = encrypt(config('ninja.testvars.stripe')); $cg->fees_and_limits = $data; diff --git a/tests/MockAccountData.php b/tests/MockAccountData.php index 6d6461e1e7d3..5dfeae55c8cb 100644 --- a/tests/MockAccountData.php +++ b/tests/MockAccountData.php @@ -539,8 +539,8 @@ trait MockAccountData $cg->user_id = $this->user->id; $cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23'; $cg->require_cvv = true; - $cg->show_billing_address = true; - $cg->show_shipping_address = true; + $cg->require_billing_address = true; + $cg->require_shipping_address = true; $cg->update_details = true; $cg->config = encrypt(config('ninja.testvars.stripe')); $cg->fees_and_limits = $data; @@ -551,8 +551,8 @@ trait MockAccountData $cg->user_id = $this->user->id; $cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23'; $cg->require_cvv = true; - $cg->show_billing_address = true; - $cg->show_shipping_address = true; + $cg->require_billing_address = true; + $cg->require_shipping_address = true; $cg->update_details = true; $cg->fees_and_limits = $data; $cg->config = encrypt(config('ninja.testvars.stripe')); diff --git a/tests/Unit/Migration/migration.json b/tests/Unit/Migration/migration.json index 1307746a43b5..d73df558201f 100644 --- a/tests/Unit/Migration/migration.json +++ b/tests/Unit/Migration/migration.json @@ -65637,7 +65637,7 @@ "gateway_key": "16dc1d3c8a865425421f64463faaf768", "accepted_credit_cards": 0, "require_cvv": 1, - "show_billing_address": null, + "require_billing_address": null, "show_shipping_address": 0, "update_details": null, "config": "{\"apiKey\":\"345345345\",\"publishableKey\":\"5435345\",\"plaidClientId\":\"\",\"plaidSecret\":\"\",\"plaidPublicKey\":\"\",\"enableAlipay\":false,\"enableSofort\":false,\"enableSepa\":false,\"enableBitcoin\":false,\"enableApplePay\":false,\"enableAch\":false}", @@ -65666,7 +65666,7 @@ "gateway_key": "16dc1d3c8a865425421f64463faaf768", "accepted_credit_cards": 0, "require_cvv": 1, - "show_billing_address": null, + "require_billing_address": null, "show_shipping_address": 0, "update_details": null, "config": "{\"apiKey\":\"345345345\",\"publishableKey\":\"5435345\",\"plaidClientId\":\"\",\"plaidSecret\":\"\",\"plaidPublicKey\":\"\",\"enableAlipay\":false,\"enableSofort\":false,\"enableSepa\":false,\"enableBitcoin\":false,\"enableApplePay\":false,\"enableAch\":false}",