Add payment cdm function
This commit is contained in:
@@ -58,7 +58,7 @@ class ApiController extends Controller
|
||||
if(config('app.env') != 'production'){
|
||||
$this->api_key = 'abecfd0c-98d8-4635-abc2-2fcba8c60c11';
|
||||
$this->XSignature_Key = 'S-GWr7z03XjAhqPsFfu_H5nQ';
|
||||
$this->collection_id = 'drxdyor4';
|
||||
$this->collection_id = 'bwdtejv0';
|
||||
}else{
|
||||
$this->api_key = 'f3e82fe1-a422-4660-97f0-65cc59ff6c47';
|
||||
$this->XSignature_Key = 'S-alZUbzmD2_TF3vmrRqgehQ';
|
||||
|
||||
@@ -20,8 +20,10 @@ use App\Models\FileResit;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\JenisEmas;
|
||||
use App\Services\MarhunPhotoService;
|
||||
use App\Services\ResitPhotoService;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class LelongMobileController extends Controller
|
||||
{
|
||||
@@ -1233,4 +1235,76 @@ class LelongMobileController extends Controller
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function listPhotoResit(Request $request)
|
||||
{
|
||||
$file_resit = FileResit::where('user_id', '=', $request->user_id)->where('lelong_id', '=', $request->lelong_id)->get();
|
||||
|
||||
if ($file_resit->isNotEmpty()) {
|
||||
|
||||
foreach($file_resit as $index => $resit)
|
||||
{
|
||||
$date_convert = strtotime($resit->created_at);
|
||||
$updatedDateTime = date("d-m-Y H:i", $date_convert);
|
||||
$file_resit[$index]['masa_upload'] = $updatedDateTime;
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'file_resit' => $file_resit,
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function addPhotoResit(Request $request)
|
||||
{
|
||||
$file_type = $request->gambarResit->getClientOriginalExtension();
|
||||
|
||||
$addfile = new FileResit();
|
||||
$addfile->user_id = $request->user_id;
|
||||
$addfile->lelong_id = $request->lelong_id;
|
||||
$addfile->file_type = $file_type;
|
||||
$addfile->save();
|
||||
|
||||
$directory = "/{$request->user_id}/{$request->lelong_id}/";
|
||||
$imageExtension = $file_type;
|
||||
|
||||
$resitImageFileName = $addfile->id;
|
||||
|
||||
Storage::disk('resit')->putFileAs($directory, $request->gambarResit, "${resitImageFileName}.${imageExtension}");
|
||||
|
||||
return response()->json(['success' => true]);
|
||||
}
|
||||
|
||||
public function showPhotoResit(Request $request)
|
||||
{
|
||||
$fileResit = FileResit::find($request->fileresit_id);
|
||||
$resitPhotoService = new ResitPhotoService();
|
||||
$resit_photo = $resitPhotoService->get($fileResit->user_id, $fileResit);
|
||||
return base64_encode($resit_photo);
|
||||
}
|
||||
|
||||
public function deletePhotoResit(Request $request)
|
||||
{
|
||||
$deleteFile = FileResit::find($request->fileresit_id);
|
||||
|
||||
$directory = "/{$deleteFile->user_id}/{$deleteFile->lelong_id}/";
|
||||
$imageExtension = $deleteFile->file_type;
|
||||
|
||||
$deleteFile_id = $deleteFile->id;
|
||||
|
||||
$resitImageFileName = "${deleteFile_id}.${imageExtension}";
|
||||
|
||||
Storage::disk('resit')->delete("{$directory}${resitImageFileName}");
|
||||
$deleteFile->delete();
|
||||
|
||||
return response()->json(['success' => true]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -117,18 +117,12 @@ class ResitPhotoService
|
||||
$lelong_id = $resit->lelong_id;
|
||||
$fileresit_id = $resit->id;
|
||||
|
||||
// $photo_type_name = $marhun->photo_type === 1 ? 'overall_photo' : 'by_marhun_photo';
|
||||
|
||||
$directory = "/{$user_id}/{$lelong_id}/";
|
||||
$imageExtension = $resit->file_type;
|
||||
|
||||
$resitImageFileName = "overall.{$imageExtension}";
|
||||
$resitImageFileName = "{$fileresit_id}.{$imageExtension}";
|
||||
|
||||
if (!empty($fileresit_id)) {
|
||||
$resitImageFileName = "overall.$imageExtension";
|
||||
}
|
||||
|
||||
return Storage::disk('marhun')->get("{$directory}${resitImageFileName}");
|
||||
return Storage::disk('resit')->get("{$directory}${resitImageFileName}");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ class CreateFileresitTable extends Migration
|
||||
Schema::create('fileresit', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->unsignedBigInteger('user_id')->unsigned();
|
||||
$table->unsignedBigInteger('lelong_id')->unsigned();
|
||||
$table->unsignedBigInteger('payment_id')->unsigned();
|
||||
$table->string('file_type');
|
||||
$table->datetime('deleted_at')->nullable();
|
||||
@@ -26,9 +27,9 @@ class CreateFileresitTable extends Migration
|
||||
->references('id')->on('users')
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->foreign('payment_id')
|
||||
->references('id')->on('payment')
|
||||
->onDelete('cascade');
|
||||
// $table->foreign('payment_id')
|
||||
// ->references('id')->on('payment')
|
||||
// ->onDelete('cascade');
|
||||
});
|
||||
|
||||
// once the table is created use a raw query to ALTER it and add the MEDIUMBLOB
|
||||
|
||||
+8
-1
@@ -103,7 +103,14 @@ Route::group(['middleware' => ['auth:sanctum']], function () {
|
||||
//===========PAY======================
|
||||
//get invoice detail
|
||||
Route::get('/invoice', [LelongMobileController::class, 'getInvoiceId']);
|
||||
|
||||
//get invoice detail
|
||||
Route::get('/listPhotoResit', [LelongMobileController::class, 'listPhotoResit']);
|
||||
//add photo resit
|
||||
Route::post('/addPhotoResit',[LelongMobileController::class, 'addPhotoResit']);
|
||||
//show photo resit
|
||||
Route::get('/showPhotoResit',[LelongMobileController::class, 'showPhotoResit']);
|
||||
//delete photo resit
|
||||
Route::post('/deletePhotoResit',[LelongMobileController::class, 'deletePhotoResit']);
|
||||
|
||||
|
||||
// Lelong
|
||||
|
||||
Reference in New Issue
Block a user