Browse Source

update tmp import

pull/3/head
ibnu 2 years ago
parent
commit
627dd6b9c1
  1. 30
      app/Http/Controllers/ActivityController.php
  2. 1
      app/Http/Controllers/Controller.php
  3. 17
      app/Models/TmpImport.php
  4. 1
      routes/web.php

30
app/Http/Controllers/ActivityController.php

@ -6,6 +6,7 @@ use App\Models\CommentActivity;
use App\Models\Link; use App\Models\Link;
use App\Models\Project; use App\Models\Project;
use App\Models\TemplateGantt; use App\Models\TemplateGantt;
use App\Models\TmpImport;
use App\Models\VersionGantt; use App\Models\VersionGantt;
use App\Models\UserToActivity; use App\Models\UserToActivity;
use Illuminate\Http\Request; use Illuminate\Http\Request;
@ -386,4 +387,33 @@ class ActivityController extends Controller
return response()->json(['stack' => $activityStack, 'status' => 'success', 'message' => 'Data imported!', 'projectId' => $projectId, 'code' => 200], 200); return response()->json(['stack' => $activityStack, 'status' => 'success', 'message' => 'Data imported!', 'projectId' => $projectId, 'code' => 200], 200);
} }
public function uploadTmpImport(Request $request)
{
if($request->hasFile('dokumen')){
$document = $request->file('dokumen');
$gantt_id = $request->gantt_id;
$name = $document->getClientOriginalName();
$result = $document->move($this->pathDocument, $name);
if($result){
$data = [
'ref_id' => (int)$gantt_id,
'file' => $name,
'type_dokumen' => $request->type_dokumen
];
$result = TmpImport::create($data);
if(!$result){
unlink($this->pathDocument.$name);
return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500);
}
return response()->json(['status'=>'success','message'=>'Upload successful!','code'=>200], 200);
}
return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500);
}
return response()->json(['status'=>'failed','message'=>'File is required!','code'=>400], 400);
}
} }

1
app/Http/Controllers/Controller.php

@ -11,6 +11,7 @@ class Controller extends BaseController
{ {
protected $pathImage = "assets/image/"; protected $pathImage = "assets/image/";
protected $pathDocument = "assets/file/project/"; protected $pathDocument = "assets/file/project/";
protected $pathTmpImport = "assets/file/tmpimport/";
protected $pathActivityDocument = "assets/file/activity/"; protected $pathActivityDocument = "assets/file/activity/";
protected $listJoinAll = ['first', 'second', 'third', 'fourth', 'fifth', protected $listJoinAll = ['first', 'second', 'third', 'fourth', 'fifth',
'sixth', 'seventh', 'eighth', 'ninth', 'tenth']; 'sixth', 'seventh', 'eighth', 'ninth', 'tenth'];

17
app/Models/TmpImport.php

@ -0,0 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class TmpImport extends Model
{
protected $table = 'tmp_import';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'created_by';
protected $fillable = [
'file', 'type_dokumen', 'gantt_id', 'created_at', 'created_by'
];
}

1
routes/web.php

@ -207,6 +207,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout
$router->put('/task/update-regular/{id}', 'ActivityController@updateRegular'); $router->put('/task/update-regular/{id}', 'ActivityController@updateRegular');
$router->delete('/task/{id}', 'ActivityController@delete'); $router->delete('/task/{id}', 'ActivityController@delete');
$router->get('/task/get-update/{id}', 'ActivityController@getUpdate'); $router->get('/task/get-update/{id}', 'ActivityController@getUpdate');
$router->post('/tmp-import/upload', 'ActivityController@uploadTmpImport');
$router->post('/link', 'LinkController@add'); $router->post('/link', 'LinkController@add');
$router->put('/link/{id}', 'LinkController@update'); $router->put('/link/{id}', 'LinkController@update');

Loading…
Cancel
Save