Merge branch 'master' of https://github.com/brkcvn/akaunting into code-clean
This commit is contained in:
@ -44,6 +44,26 @@ abstract class SettingController extends Controller
|
||||
|
||||
$total_companies = Company::count();
|
||||
|
||||
// Clear setting media
|
||||
foreach ($this->file_keys as $file_key) {
|
||||
$keys = explode('.', $file_key);
|
||||
|
||||
if ($prefix != $keys[0]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! setting($file_key, false)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$file_old_key = 'uploaded_' . $keys[1];
|
||||
if (array_key_exists($file_old_key, $fields)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
setting()->forget($file_key);
|
||||
}
|
||||
|
||||
foreach ($fields as $key => $value) {
|
||||
$real_key = $prefix . '.' . $key;
|
||||
|
||||
|
@ -88,7 +88,7 @@ abstract class Index extends Component
|
||||
public $classBulkAction;
|
||||
|
||||
/** @var bool */
|
||||
public $showPicture;
|
||||
public $showLogo;
|
||||
|
||||
/** @var bool */
|
||||
public $hideName;
|
||||
@ -179,7 +179,7 @@ abstract class Index extends Component
|
||||
bool $hideEmptyPage = false, bool $hideSummary = false, $summaryItems = [], bool $hideSearchString = false, bool $hideBulkAction = false,
|
||||
string $searchStringModel = '', string $bulkActionClass = '', array $bulkActions = [], array $bulkActionRouteParameters = [], string $searchRoute = '',
|
||||
string $classBulkAction = '',
|
||||
bool $showPicture = false, bool $hideName = false, bool $hideTaxNumber = false, string $classNameAndTaxNumber = '', string $textName = '', string $textTaxNumber = '',
|
||||
bool $showLogo = false, bool $hideName = false, bool $hideTaxNumber = false, string $classNameAndTaxNumber = '', string $textName = '', string $textTaxNumber = '',
|
||||
bool $hideEmail = false, bool $hidePhone = false, string $classEmailAndPhone = '', string $textEmail = '', string $textPhone = '',
|
||||
bool $hideCountry = false, bool $hideCurrencyCode = false, string $classCountryAndCurrencyCode = '', string $textCountry = '', string $textCurrencyCode = '',
|
||||
bool $hideOpen = false, bool $hideOverdue = false, string $classOpenAndOverdue = '', string $textOpen = '', string $textOverdue = '',
|
||||
@ -229,7 +229,7 @@ abstract class Index extends Component
|
||||
|
||||
$this->classBulkAction = $this->getClassBulkAction($type, $classBulkAction);
|
||||
|
||||
$this->showPicture = $showPicture;
|
||||
$this->showLogo = $showLogo;
|
||||
$this->hideName = $hideName;
|
||||
$this->hideTaxNumber = $hideTaxNumber;
|
||||
$this->classNameAndTaxNumber = $this->getClassNameAndTaxNumber($type, $classNameAndTaxNumber);
|
||||
|
@ -54,6 +54,22 @@ class Companies extends Controller
|
||||
$file_keys = ['company.logo'];
|
||||
$uploaded_file_keys = ['company.uploaded_logo'];
|
||||
|
||||
// Clear setting media
|
||||
foreach ($file_keys as $file_key) {
|
||||
$keys = explode('.', $file_key);
|
||||
|
||||
if (! setting($file_key, false)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$file_old_key = 'uploaded_' . $keys[1];
|
||||
if (array_key_exists($file_old_key, $fields)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
setting()->forget($file_key);
|
||||
}
|
||||
|
||||
foreach ($fields as $key => $value) {
|
||||
// Don't process unwanted keys
|
||||
if (in_array($key, $skip_keys)) {
|
||||
|
@ -24,7 +24,7 @@ class UpdateTransaction extends Job implements ShouldUpdate
|
||||
|
||||
$this->model->attachMedia($media, 'attachment');
|
||||
}
|
||||
} elseif (!$this->request->file('attachment') && $this->model->attachment) {
|
||||
} elseif (! $this->request->file('attachment') && $this->model->attachment) {
|
||||
$this->deleteMediaModel($this->model, 'attachment', $this->request);
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,8 @@ class UpdateContact extends Job implements ShouldUpdate
|
||||
$media = $this->getMedia($this->request->file('logo'), Str::plural($this->model->type));
|
||||
|
||||
$this->model->attachMedia($media, 'logo');
|
||||
} elseif (! $this->request->file('logo') && $this->model->logo) {
|
||||
$this->deleteMediaModel($this->model, 'logo', $this->request);
|
||||
}
|
||||
|
||||
$this->model->update($this->request->all());
|
||||
|
@ -57,7 +57,7 @@ trait Uploads
|
||||
{
|
||||
$medias = $model->$parameter;
|
||||
|
||||
if (!$medias) {
|
||||
if (! $medias) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ trait Uploads
|
||||
}
|
||||
}
|
||||
|
||||
foreach ((array)$medias as $media) {
|
||||
foreach ((array) $medias as $media) {
|
||||
if (in_array($media->id, $already_uploaded)) {
|
||||
continue;
|
||||
}
|
||||
@ -86,7 +86,7 @@ trait Uploads
|
||||
|
||||
public function getMediaFolder($folder, $company_id = null)
|
||||
{
|
||||
if (!$company_id) {
|
||||
if (! $company_id) {
|
||||
$company_id = company_id();
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ trait Uploads
|
||||
|
||||
public function getMediaPathOnStorage($media)
|
||||
{
|
||||
if (!is_object($media)) {
|
||||
if (! is_object($media)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user