fix files

This commit is contained in:
hafifierahman
2022-04-12 11:00:52 +08:00
parent c401f17f7d
commit 62d1252f4e
4 changed files with 62 additions and 4 deletions
+24 -1
View File
@@ -26,6 +26,7 @@ use App\Pengesahan;
use App\Permohonan;
use App\Status;
use App\LookupStatus;
use App\KPFiles;
use DB;
use Carbon\Carbon;
@@ -2093,6 +2094,7 @@ class AdminPageController extends Controller
{
$timeloni = Carbon::now();
$status = new Status;
$kp_files = new KPFiles;
try{
@@ -2103,10 +2105,16 @@ class AdminPageController extends Controller
$status->tarikhmasa = $timeloni->toDateTimeString();
$status->save();
$kp_files->data = $request->dataimage;
$kp_files->type = $request->imagetype;
$kp_files->filename = $request->imagename;
$kp_files->tarikhmasa = $timeloni->toDateTimeString();
$kp_files->save();
$pengesahan = Pengesahan::where([['mohonid',$request->mohonid],['tagpb',0]])
->update(array(
'tagpb' => 1,
'kelulusanpbimage' => $request->kelulusanpbimage
'kp_id' => $kp_files->id
));
$permohonan = Permohonan::where('mohonid',$request->mohonid)
@@ -2230,4 +2238,19 @@ class AdminPageController extends Controller
return response($e);
}
}
public function viewFile(Request $request) {
// $data = \DB::connection($conn)
// ->table($tbl)
// ->where('filename', $filename)
// ->first();
$kp = KPFiles::where('kp_id',$request->kp_id)
->first();
return response(base64_decode(stream_get_contents($kp->data)), 200, [
'Content-type' => 'application/' . $kp->type,
'Content-Disposition' => 'inline; filename='.$kp->filename
]);
}
}
+32
View File
@@ -0,0 +1,32 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class KPFiles extends Model
{
protected $table = 'kelulusanpb_files';
public $timestamps = false;
protected $connection = 'mysql7';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'kp_id',
'data',
'filename',
'type',
'tarikhmasa'
];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
// protected $hidden = [];
}
+3 -1
View File
@@ -38,7 +38,9 @@ class Pengesahan extends Model
'bank_cit',
'komen_batal',
'kelulusanpbimage',
'resit_cit'
'resit_cit',
'nama_cit',
'jeniscit'
];
/**
+3 -2
View File
@@ -692,11 +692,12 @@ $router->group(['prefix'=>'admin'], function () use ($router){
$router->put('permohonan/updateoperasi',['uses'=>'AdminPageController@KelulusanPermohonanByOperasi']);
$router->put('permohonan/updateakaun',['uses'=>'AdminPageController@KelulusanPermohonanByAkaun']);
$router->put('permohonan/updatecetak',['uses'=>'AdminPageController@PengesahanCetakan']);
$router->put('permohonan/updatepb',['uses'=>'AdminPageController@KelulusanPermohonanByPB']);
$router->post('permohonan/updatepb',['uses'=>'AdminPageController@KelulusanPermohonanByPB']);
$router->put('permohonan/updatebank',['uses'=>'AdminPageController@DepositBank']);
$router->put('permohonan/tagterima',['uses'=>'AdminPageController@TagTerima']);
$router->put('permohonan/tagcit',['uses'=>'AdminPageController@TagCit']);
$router->get('permohonan/viewfiles',['uses'=>'AdminPageController@viewFile']);
});