Browse Source

storage Information

pull/1/head
farhantock 10 months ago
parent
commit
e735c33734
  1. 42
      app/Http/Controllers/Controller.php
  2. 46
      routes/web.php

42
app/Http/Controllers/Controller.php

@ -13,6 +13,8 @@ use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
use Laravel\Lumen\Routing\Controller as BaseController;
use RecursiveIteratorIterator;
use RecursiveDirectoryIterator;
class Controller extends BaseController
{
@ -41,10 +43,10 @@ class Controller extends BaseController
protected function setCustomeDirectoryUpload($company_name)
{
$pathImage = 'assets/'.$company_name.'/image/';
$pathDocument = 'assets/'.$company_name.'/file/project/';
$pathTmpImport = 'assets/'.$company_name.'/file/tmpimport/';
$pathActivityDocument = 'assets/'.$company_name.'/file/activity/';
$pathImage = 'assets/' . $company_name . '/image/';
$pathDocument = 'assets/' . $company_name . '/file/project/';
$pathTmpImport = 'assets/' . $company_name . '/file/tmpimport/';
$pathActivityDocument = 'assets/' . $company_name . '/file/activity/';
return [
'pathImage' => $pathImage,
@ -54,7 +56,19 @@ class Controller extends BaseController
];
}
protected function setLimitsStorage($company, $dokumen, $name, $initPath, $destinatePath) {
public function storage($company_name)
{
$directory = 'assets/' . urldecode($company_name);
$size = 0;
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file) {
$size += $file->getSize();
}
return round($size / 1048576, 2);
}
protected function setLimitsStorage($company, $dokumen, $name, $initPath, $destinatePath)
{
$totalSize = 0;
$sizeFile = $dokumen->getSize();
// Path
@ -63,11 +77,11 @@ class Controller extends BaseController
$folderPathTmpImport = $destinatePath['pathTmpImport'];
$folderPathActivityDocument = $destinatePath['pathActivityDocument'];
// Create Directory
if(!file_exists($initPath)) {
if (!file_exists($initPath)) {
mkdir($initPath, 0777, true);
}
// Scanning & Existing Folder
if(file_exists($folderPathImage)) {
if (file_exists($folderPathImage)) {
$files = scandir($folderPathImage);
foreach ($files as $file) {
if (is_file($folderPathImage . '/' . $file)) {
@ -75,7 +89,7 @@ class Controller extends BaseController
}
}
}
if(file_exists($folderPath)) {
if (file_exists($folderPath)) {
$filesImage = scandir($folderPath);
foreach ($filesImage as $file) {
if (is_file($folderPath . '/' . $file)) {
@ -83,7 +97,7 @@ class Controller extends BaseController
}
}
}
if(file_exists($folderPathTmpImport)) {
if (file_exists($folderPathTmpImport)) {
$filesTmpImport = scandir($folderPathTmpImport);
foreach ($filesTmpImport as $file) {
if (is_file($folderPathTmpImport . '/' . $file)) {
@ -91,7 +105,7 @@ class Controller extends BaseController
}
}
}
if(file_exists($folderPathActivityDocument)) {
if (file_exists($folderPathActivityDocument)) {
$filesActivityDocument = scandir($folderPathActivityDocument);
foreach ($filesActivityDocument as $file) {
if (is_file($folderPathActivityDocument . '/' . $file)) {
@ -105,16 +119,16 @@ class Controller extends BaseController
->where('company_id', $company['id']);
$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;
$countCreate = true;
} elseif ($cloneQueryTransaction->where([['type_paket','Free'], ['amount', 0]])->exists()) {
} elseif ($cloneQueryTransaction->where([['type_paket', 'Free'], ['amount', 0]])->exists()) {
$maximumSize = 50 * 1024 * 1024;
$countCreate = true;
}
if($countCreate) {
if ($countCreate) {
if ($totalSize > $maximumSize) {
return response()->json(['status'=>'failed','message'=>'Limited storage maximum!','code'=> 500], 500);
return response()->json(['status' => 'failed', 'message' => 'Limited storage maximum!', 'code' => 500], 500);
}
}
$resultMove = $dokumen->move($folderPath, $name);

46
routes/web.php

@ -6,18 +6,18 @@ $router->get('/', function () use ($router) {
$router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($router) {
$router->post('/login', 'AuthController@login');
// Landing Route
// Landing Route
$router->post('/send-email', 'AuthController@sendEmail');
$router->post('/company-management-user/add', 'CompanyController@add');
$router->post('/product-transaction/add','ProductTransactionController@add');
$router->post('/company-management-user/search', 'CompanyController@search');
$router->post('/human-resource-user/add', 'HumanResourceController@add_user');
$router->get('/company-management-user/edit/{id}', 'CompanyController@edit');
$router->post('/demo-management-user/add', 'DemoController@add');
$router->post('/role-user/add', 'RoleController@add');
$router->post('/menu-company-user/add-multiple', 'MenuCompanyController@addMultiple');
$router->post('/role-menu-user/add-multiple', 'RoleMenuController@addMultiple');
$router->post('/refferal-code/search', 'RefferalCodeController@search');
$router->post('/company-management-user/add', 'CompanyController@add');
$router->post('/product-transaction/add', 'ProductTransactionController@add');
$router->post('/company-management-user/search', 'CompanyController@search');
$router->post('/human-resource-user/add', 'HumanResourceController@add_user');
$router->get('/company-management-user/edit/{id}', 'CompanyController@edit');
$router->post('/demo-management-user/add', 'DemoController@add');
$router->post('/role-user/add', 'RoleController@add');
$router->post('/menu-company-user/add-multiple', 'MenuCompanyController@addMultiple');
$router->post('/role-menu-user/add-multiple', 'RoleMenuController@addMultiple');
$router->post('/refferal-code/search', 'RefferalCodeController@search');
$router->post('/menu/add', 'MenuController@add');
$router->get('/menu/edit/{id}', 'MenuController@edit');
@ -78,7 +78,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->delete('/project/delete/{id}/{company_id}', 'ProjectController@delete');
$router->get('/project/list', 'ProjectController@list');
$router->get('/project/set-baseline/{gantt_id}', 'ProjectController@setBaseline');
$router->get('/project/set-baseline-activity/{activity_id}/{gantt_id}', 'ProjectController@setBaselineActivity');
$router->get('/project/set-baseline-activity/{activity_id}/{gantt_id}', 'ProjectController@setBaselineActivity');
$router->get('/project/synchronize-report/{gantt_id}', 'ProjectController@synchronizeReport');
$router->get('/project/manpower/{proyek_id}', 'ProjectController@getManpower');
$router->get('/project/manpower/assigned/{gantt_id}', 'ProjectController@getAssignedHR');
@ -369,17 +369,17 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->get('/project-issues/list', 'ProjectIssuesController@list');
$router->get('/project-issues/{where}/{val}', 'ProjectIssuesController@customWhere');
$router->get('/kanban-board/list', 'KanbanBoardController@list');
$router->post('/kanban-board/add', 'KanbanBoardController@add');
$router->put('/kanban-board/update/{id}', 'KanbanBoardController@update');
$router->delete('/kanban-board/delete/{id}', 'KanbanBoardController@delete');
$router->post('/kanban-board/search', 'KanbanBoardController@search');
$router->get('/kanban-board/list', 'KanbanBoardController@list');
$router->post('/kanban-board/add', 'KanbanBoardController@add');
$router->put('/kanban-board/update/{id}', 'KanbanBoardController@update');
$router->delete('/kanban-board/delete/{id}', 'KanbanBoardController@delete');
$router->post('/kanban-board/search', 'KanbanBoardController@search');
$router->get('/kanban-card/get-data/{project_id}/{gantt_id}/{board_id}', 'KanbanCardController@getData');
$router->post('/kanban-card/add', 'KanbanCardController@add');
$router->put('/kanban-card/update/{id}', 'KanbanCardController@update');
$router->delete('/kanban-card/delete/{id}', 'KanbanCardController@delete');
$router->post('/kanban-card/search', 'KanbanCardController@search');
$router->get('/kanban-card/get-data/{project_id}/{gantt_id}/{board_id}', 'KanbanCardController@getData');
$router->post('/kanban-card/add', 'KanbanCardController@add');
$router->put('/kanban-card/update/{id}', 'KanbanCardController@update');
$router->delete('/kanban-card/delete/{id}', 'KanbanCardController@delete');
$router->post('/kanban-card/search', 'KanbanCardController@search');
$router->post('/project-risks/add', 'ProjectRisksController@add');
$router->get('/project-risks/edit/{id}', 'ProjectRisksController@edit');
@ -587,5 +587,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->post('/demo-management/search', 'DemoController@search');
$router->delete('/demo-management/delete/{id}', 'DemoController@delete');
$router->get('/demo-management/list', 'DemoController@list');
$router->get('information-storage/{company_name}', 'Controller@storage');
});
});

Loading…
Cancel
Save