1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00
invoiceninja/app/Repositories/DesignRepository.php

58 lines
1.5 KiB
PHP
Raw Normal View History

2020-06-22 00:34:02 +02:00
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
2020-06-22 00:34:02 +02:00
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
2023-01-28 23:21:40 +01:00
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
2020-06-22 00:34:02 +02:00
*
2021-06-16 08:58:16 +02:00
* @license https://www.elastic.co/licensing/elastic-license
2020-06-22 00:34:02 +02:00
*/
namespace App\Repositories;
use App\Models\Design;
use Illuminate\Support\Str;
2020-06-22 00:34:02 +02:00
/**
2020-11-03 14:27:41 +01:00
* Class for DesignRepository .
2020-06-22 00:34:02 +02:00
*/
class DesignRepository extends BaseRepository
{
2024-01-14 05:05:00 +01:00
public function delete($design): Design
{
$design->name = $design->name.'_deleted_'.Str::random(5);
/** Make sure this design was not a default design - if it is, set the Clean template as the default */
/** @var \App\Models\User $user */
$user = auth()->user();
$company = $user->company();
$settings = $company->settings;
if ($settings->invoice_design_id == $design->hashed_id) {
$settings->invoice_design_id = 'Wpmbk5ezJn';
}
if ($settings->quote_design_id == $design->hashed_id) {
$settings->quote_design_id = 'Wpmbk5ezJn';
}
if ($settings->credit_design_id == $design->hashed_id) {
$settings->credit_design_id = 'Wpmbk5ezJn';
}
if ($settings->purchase_order_design_id == $design->hashed_id) {
$settings->purchase_order_design_id = 'Wpmbk5ezJn';
}
2024-01-14 05:05:00 +01:00
$company->settings = $settings;
$company->save();
parent::delete($design);
return $design;
}
2020-06-22 00:34:02 +02:00
}