Browse Source

update payload search

pull/1/head
wahyun 9 months ago
parent
commit
d58194a117
  1. 35
      app/Http/Controllers/Controller.php

35
app/Http/Controllers/Controller.php

@ -46,10 +46,14 @@ class Controller extends BaseController
protected function setCustomeDirectoryUpload($company_name) protected function setCustomeDirectoryUpload($company_name)
{ {
$pathImage = 'assets/' . $company_name . '/image/'; $current_date = date('Y-m-d');
$pathDocument = 'assets/' . $company_name . '/file/project/'; [$year, $month] = explode('-', $current_date);
$pathTmpImport = 'assets/' . $company_name . '/file/tmpimport/'; $yearMonth = $year.'-'.$month;
$pathActivityDocument = 'assets/' . $company_name . '/file/activity/';
$pathImage = 'assets/' . $company_name .'/'. $yearMonth . '/image/';
$pathDocument = 'assets/' . $company_name .'/'. $yearMonth . '/file/project/';
$pathTmpImport = 'assets/' . $company_name .'/'. $yearMonth . '/file/tmpimport/';
$pathActivityDocument = 'assets/' . $company_name .'/'. $yearMonth . '/file/activity/';
return [ return [
'pathImage' => $pathImage, 'pathImage' => $pathImage,
@ -118,8 +122,10 @@ class Controller extends BaseController
} }
} }
protected function setLimitsStorage($company, $dokumen, $name, $initPath, $destinatePath) protected function setLimitsStorage($company, $dokumen, $initPath, $destinatePath)
{ {
$countCreate = false;
DB::transaction(function() use($company, $dokumen, $initPath, $destinatePath, &$countCreate) {
$totalSize = 0; $totalSize = 0;
$sizeFile = $dokumen->getSize(); $sizeFile = $dokumen->getSize();
// Path // Path
@ -169,24 +175,23 @@ class Controller extends BaseController
$transaction = ProductTransaction::query() $transaction = ProductTransaction::query()
->where('company_id', $company['id']); ->where('company_id', $company['id']);
$cloneQueryTransaction = clone $transaction; $cloneQueryTransaction = clone $transaction;
$countCreate = false;
if ($transaction->where([['type_paket', 'Basic'], ['amount', '!=', null]])->exists()) { if ($transaction->where([['type_paket', 'Basic'], ['amount', '!=', null]])->exists()) {
$maximumSize = 500 * 1024 * 1024; $maximumSize = 500 * 1024 * 1024;
$countCreate = true; $countCreate = true;
} elseif ($cloneQueryTransaction->where([['type_paket', 'Free'], ['amount', 0]])->exists()) { } elseif ($cloneQueryTransaction->where([['type_paket', 'Free'], ['amount', 0]])->exists()) {
$maximumSize = 50 * 1024 * 1024; $maximumSize = 50 * 1024 * 1024;
$countCreate = true; $countCreate = true;
} else {
$countCreate = true;
} }
if ($countCreate) { if ($countCreate) {
if ($totalSize > $maximumSize) { if (floatval($totalSize) > floatval($maximumSize)) {
return response()->json(['status' => 'failed', 'message' => 'Limited storage maximum!', 'code' => 500], 500); $countCreate = false;
} }
} }
$resultMove = $dokumen->move($initPath, $name); });
return $countCreate;
return [
'resultMove' => $resultMove
];
} }
protected function setUpPayload($condition, $tableSelf) protected function setUpPayload($condition, $tableSelf)
@ -334,6 +339,10 @@ class Controller extends BaseController
$query = $query->whereIn($tableColumn . "." . $column, $value); $query = $query->whereIn($tableColumn . "." . $column, $value);
} else if ($operator == "notin") { } else if ($operator == "notin") {
$query = $query->whereNotIn($tableColumn . "." . $column, $value); $query = $query->whereNotIn($tableColumn . "." . $column, $value);
} else if ($operator == "isnull") {
$query = $query->WhereNull($tableColumn . "." . $column);
} else if ($operator == "notnull") {
$query = $query->WhereNotNull($tableColumn . "." . $column);
} else { } else {
$query = $query->where($tableColumn . "." . $column, $operator, $value); $query = $query->where($tableColumn . "." . $column, $operator, $value);
} }

Loading…
Cancel
Save