Compare commits

...

3 Commits

  1. 21
      app/Http/Controllers/API/v1/DisposalApi/DisposalApiController.php
  2. 4
      app/Http/Controllers/API/v1/PeminjamanApi/PeminjamanApiController.php
  3. 60
      app/Http/Controllers/API/v1/TransferApi/TransferApiController.php
  4. 2
      database/migrations/2023_11_17_075418_create_disposals_table.php
  5. 2
      routes/api.php

21
app/Http/Controllers/API/v1/DisposalApi/DisposalApiController.php

@ -0,0 +1,21 @@
<?php
namespace App\Http\Controllers\API\v1\DisposalApi;
use Illuminate\Http\Request;
use App\Helpers\ResponseFormatter;
use App\Http\Controllers\Controller;
class DisposalApiController extends Controller
{
public function index()
{
$disposals = \App\Models\Disposal::get();
return ResponseFormatter::success([
'status' => true,
'message' => 'Data Disposal Peti berhasil diambil',
'disposals' => $disposals
], 200);
}
}

4
app/Http/Controllers/API/v1/PeminjamanApi/PeminjamanApiController.php

@ -58,6 +58,8 @@ class PeminjamanApiController extends Controller
{ {
$mobile_id = $request->input('mobile_id'); $mobile_id = $request->input('mobile_id');
$peti_id = $request->input('peti_id'); $peti_id = $request->input('peti_id');
$customer_id = $request->input('customer_id');
$warehouse_id = $request->input('warehouse_id');
$exit_at = $request->input('exit_at'); $exit_at = $request->input('exit_at');
$exit_pic = $request->input('exit_pic'); $exit_pic = $request->input('exit_pic');
$exit_warehouse = $request->input('exit_warehouse'); $exit_warehouse = $request->input('exit_warehouse');
@ -87,6 +89,8 @@ class PeminjamanApiController extends Controller
$newRecord = new asset_status; $newRecord = new asset_status;
$newRecord->mobile_id = $mobile_id; $newRecord->mobile_id = $mobile_id;
$newRecord->peti_id = $peti_id; $newRecord->peti_id = $peti_id;
$newRecord->customer_id = $customer_id;
$newRecord->warehouse_id = $warehouse_id;
$newRecord->exit_at = $exit_at; $newRecord->exit_at = $exit_at;
$newRecord->exit_pic = $exit_pic; $newRecord->exit_pic = $exit_pic;
$newRecord->exit_warehouse = $exit_warehouse; $newRecord->exit_warehouse = $exit_warehouse;

60
app/Http/Controllers/API/v1/TransferApi/TransferApiController.php

@ -0,0 +1,60 @@
<?php
namespace App\Http\Controllers\API\v1\TransferApi;
use App\Models\Transfer;
use Illuminate\Http\Request;
use App\Helpers\ResponseFormatter;
use App\Http\Controllers\Controller;
class TransferApiController extends Controller
{
public function index()
{
// $tipePeti = \App\Models\Type_peti::get();
$transfer = \App\Models\Transfer::get();
return ResponseFormatter::success([
'status' => true,
'message' => 'Data Transfer Peti berhasil diambil',
'transfer_peti' => $transfer
]);
}
public function store(Request $request)
{
$mobile_id = $request->input('mobile_id');
$peti_id = $request->input('peti_id');
$name_customer = $request->input('name_customer');
$source_warehouse = $request->input('source_warehouse');
$destination_warehouse = $request->input('destination_warehouse');
$transfer_date = $request->input('date');
$created_by = $request->input('created_by');
$created_at = $request->input('created_at');
$transfer = Transfer::create([
'mobile_id' => $mobile_id,
'peti_id' => $peti_id,
'name_customer' => $name_customer,
'source_warehouse' => $source_warehouse,
'destination_warehouse' => $destination_warehouse,
'date' => $transfer_date,
'created_by' => $created_by,
'created_at' => $created_at
]);
if ($transfer) {
return ResponseFormatter::success([
'status' => true,
'message' => 'Data Transfer Peti berhasil ditambahkan',
'transfer_peti' => $transfer
]);
} else {
return ResponseFormatter::error([
'status' => false,
'message' => 'Data Transfer Peti gagal ditambahkan',
'transfer_peti' => $transfer
]);
}
}
}

2
database/migrations/2023_11_17_075418_create_disposals_table.php

@ -12,7 +12,7 @@ return new class extends Migration
public function up(): void public function up(): void
{ {
Schema::create('disposals', function (Blueprint $table) { Schema::create('disposals', function (Blueprint $table) {
$table->id(); $table->id('id');
$table->uuid('mobile_id')->nullable(); $table->uuid('mobile_id')->nullable();
$table->foreignId('peti_id')->constrained('petis'); $table->foreignId('peti_id')->constrained('petis');
$table->foreignId('customer_id')->constrained('customers'); $table->foreignId('customer_id')->constrained('customers');

2
routes/api.php

@ -50,6 +50,8 @@ Route::prefix('v1')->group(function () {
Route::get('/m-transfer-peti', [App\Http\Controllers\API\v1\TransferApi\TransferApiController::class, 'index'])->name('transfer-peti'); Route::get('/m-transfer-peti', [App\Http\Controllers\API\v1\TransferApi\TransferApiController::class, 'index'])->name('transfer-peti');
Route::post('/m-transfer-peti/store', [App\Http\Controllers\API\v1\TransferApi\TransferApiController::class, 'store'])->name('transfer-peti.store'); Route::post('/m-transfer-peti/store', [App\Http\Controllers\API\v1\TransferApi\TransferApiController::class, 'store'])->name('transfer-peti.store');
Route::get('/m-disposal-peti', [App\Http\Controllers\API\v1\DisposalApi\DisposalApiController::class, 'index'])->name('disposal-peti');
}); });
Route::middleware('auth:sanctum')->get('/user', function (Request $request) { Route::middleware('auth:sanctum')->get('/user', function (Request $request) {

Loading…
Cancel
Save