Browse Source

update condition

pull/1/head
wahyun 9 months ago
parent
commit
ecc91e30a0
  1. 5
      app/Http/Controllers/ActivityDokumenController.php

5
app/Http/Controllers/ActivityDokumenController.php

@ -51,15 +51,16 @@ class ActivityDokumenController extends Controller
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']); $destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
$result = $document->move($destinationPath['pathActivityDocument'], $name); $result = $document->move($destinationPath['pathActivityDocument'], $name);
} }
if(!$result || !$company) if(!$result || !$company) {
return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500); return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500);
}
$data = [ $data = [
'activity_id' => (int)$activity_id, 'activity_id' => (int)$activity_id,
'file' => $name, 'file' => $name,
'description' => $request->description 'description' => $request->description
]; ];
$result = ActivityDokumen::create($data); $result = ActivityDokumen::create($data);
if(!$result || !$company){ if(!$result || !$company) {
unlink($destinationPath['pathActivityDocument'].$name); unlink($destinationPath['pathActivityDocument'].$name);
return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500); return response()->json(['status'=>'failed','message'=>'Upload failed!','code'=> 500], 500);
} }

Loading…
Cancel
Save