update module debitur

This commit is contained in:
Daeng Deni Mardaeni 2023-11-15 15:04:25 +07:00
parent 99a55080dc
commit cf23254f07
9 changed files with 68 additions and 68 deletions

View File

@ -2,6 +2,7 @@
namespace Modules\Writeoff\DataTables; namespace Modules\Writeoff\DataTables;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder as QueryBuilder; use Illuminate\Database\Eloquent\Builder as QueryBuilder;
use Modules\Writeoff\Entities\Branch; use Modules\Writeoff\Entities\Branch;
use Modules\Writeoff\Entities\Debitur; use Modules\Writeoff\Entities\Debitur;
@ -28,14 +29,15 @@
->orWhere('name', 'like', "%" . $search['value'] . "%"); ->orWhere('name', 'like', "%" . $search['value'] . "%");
} }
})->addIndexColumn()->editColumn('registered_at', function ($row) { })->addIndexColumn()->editColumn('registered_at', function ($row) {
return $row->registered_at->locale('id')->translatedFormat('d F Y H:i:s'); $date = Carbon::create($row->registered_at);
return $date->locale('id')->translatedFormat('d F Y');
})->editColumn('cabang', function ($row) { })->editColumn('cabang', function ($row) {
return $row->branch_id ? Branch::find($row->branch_id)->name : '-'; return $row->branch_id ? Branch::find($row->branch_id)->name : '-';
})->editColumn('status', function ($row) { })->editColumn('status', function ($row) {
$status = $row->status=='A' ? '<span class="badge badge-light-success">Aktif</span>' : '<span class="badge badge-light-danger">Tidak Aktif</span>'; $status = $row->status ? '<span class="badge badge-light-success">Aktif</span>' : '<span class="badge badge-light-danger">Tidak Aktif</span>';
$oto = $row->authorized_at !== null ? '<span class="badge badge-light-success">Authorised</span>' : '<span class="badge badge-light-danger">Not Authorised</span>'; $oto = $row->authorized_at !== null ? '<span class="badge badge-light-success">Authorised</span>' : '<span class="badge badge-light-danger">Not Authorised</span>';
return $status.' '.$oto; return $status.' '.$oto;
})->rawColumns(['action'])->addColumn('action', function ($debitur) { })->rawColumns(['action','status'])->addColumn('action', function ($debitur) {
return view('writeoff::parameter.debitur._actions', compact('debitur')); return view('writeoff::parameter.debitur._actions', compact('debitur'));
})->setRowId('id'); })->setRowId('id');
} }

View File

@ -5,22 +5,22 @@ use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
use Modules\Writeoff\Entities\Branch; use Modules\Writeoff\Entities\Branch;
return new class extends Migration return new class extends Migration {
{
/** /**
* Run the migrations. * Run the migrations.
*/ */
public function up(): void public function up()
: void
{ {
Schema::create('debitur', function (Blueprint $table) { Schema::create('debitur', function (Blueprint $table) {
$table->id(); $table->id();
$table->foreignIdFor(Branch::class)->constrained()->onDelete('cascade'); $table->foreignIdFor(Branch::class)->constrained()->onDelete('cascade');
$table->string('kode',4)->unique(); $table->string('kode', 6)->unique();
$table->string('name'); $table->string('name');
$table->timestamp('registered_at')->nullable(); $table->date('registered_at')->nullable();
$table->text('address')->nullable(); $table->text('address')->nullable();
$table->string('npwp', 16)->nullable(); $table->string('npwp', 16)->nullable();
$table->char('status', 1)->default('A'); $table->boolean('status')->default(true)->nullable();
$table->timestamps(); $table->timestamps();
$table->timestamp('authorized_at')->nullable(); $table->timestamp('authorized_at')->nullable();
$table->char('authorized_status', 1)->nullable(); $table->char('authorized_status', 1)->nullable();
@ -36,7 +36,8 @@ use Illuminate\Support\Facades\Schema;
/** /**
* Reverse the migrations. * Reverse the migrations.
*/ */
public function down(): void public function down()
: void
{ {
Schema::dropIfExists('debitur'); Schema::dropIfExists('debitur');
} }

View File

@ -16,4 +16,8 @@
'authorized_by', 'authorized_by',
]; ];
public function debiturs()
{
return $this->hasMany(Debitur::class);
}
} }

View File

@ -18,4 +18,14 @@
'authorized_by', 'authorized_by',
]; ];
public function branch()
{
return $this->belongsTo(Branch::class);
}
public function rekenings()
{
return $this->hasMany(Rekening::class);
}
} }

View File

@ -28,10 +28,10 @@
: array : array
{ {
return [ return [
'kode' => 'required|string|max:9|min:9|unique:debitur,kode', 'kode' => 'required|string|max:6|min:6|unique:debitur,kode',
'name' => 'required|string|max:100', 'name' => 'required|string|max:100',
'branch_id' => 'required|integer|exists:branches,id', 'branch_id' => 'required|integer|exists:branches,id',
'status' => 'required|string|max:1|min:1|in:A,I', 'status' => 'required|boolean',
'address' => 'nullable|string|max:255', 'address' => 'nullable|string|max:255',
'npwp' => 'nullable|string|max:16|min:16', 'npwp' => 'nullable|string|max:16|min:16',
'registered_at' => 'nullable|date_format:Y-m-d' 'registered_at' => 'nullable|date_format:Y-m-d'
@ -75,11 +75,4 @@
'messages' => 'Debitur created failed.' 'messages' => 'Debitur created failed.'
], JsonResponse::HTTP_UNPROCESSABLE_ENTITY)); ], JsonResponse::HTTP_UNPROCESSABLE_ENTITY));
} }
protected function prepareForValidation()
{
$this->merge([
'status' => $this->status ? 'A' : 'I'
]);
}
} }

View File

@ -33,10 +33,10 @@
$this->_id = json_decode(json_decode(file_get_contents('php://input'))->components[0]->snapshot)->data->id; $this->_id = json_decode(json_decode(file_get_contents('php://input'))->components[0]->snapshot)->data->id;
return [ return [
'kode' => 'required|string|max:9|min:9|unique:debitur,kode,' . $this->_id, 'kode' => 'required|string|max:6|min:6|unique:debitur,kode,' . $this->_id,
'name' => 'required|string|max:100', 'name' => 'required|string|max:100',
'branch_id' => 'required|integer|exists:branches,id', 'branch_id' => 'required|integer|exists:branches,id',
'status' => 'required|string|max:1|min:1|in:A,I|default:A', 'status' => 'required|boolean',
'address' => 'nullable|string|max:255', 'address' => 'nullable|string|max:255',
'npwp' => 'nullable|string|max:16|min:16', 'npwp' => 'nullable|string|max:16|min:16',
'registered_at' => 'nullable|date_format:Y-m-d' 'registered_at' => 'nullable|date_format:Y-m-d'
@ -72,11 +72,4 @@
'messages' => 'Debitur updated failed.' 'messages' => 'Debitur updated failed.'
], JsonResponse::HTTP_UNPROCESSABLE_ENTITY)); ], JsonResponse::HTTP_UNPROCESSABLE_ENTITY));
} }
protected function prepareForValidation()
{
$this->merge([
'status' => $this->status ? 'A' : 'I'
]);
}
} }

View File

@ -7,7 +7,7 @@
use Modules\Writeoff\Entities\Branch; use Modules\Writeoff\Entities\Branch;
use Modules\Writeoff\Entities\Debitur; use Modules\Writeoff\Entities\Debitur;
use Modules\Writeoff\Http\Requests\Debitur\StoreDebiturRequest; use Modules\Writeoff\Http\Requests\Debitur\StoreDebiturRequest;
use Modules\Writeoff\Http\Requests\Debitur\UpdateDebiturRequest; use Modules\Writeoff\Http\Requests\Debitur\UpdateRekeningRequest;
class DebiturModal extends Component class DebiturModal extends Component
{ {
@ -48,7 +48,6 @@
'address' => $this->address, 'address' => $this->address,
'npwp' => $this->npwp, 'npwp' => $this->npwp,
'registered_at' => $this->registered_at, 'registered_at' => $this->registered_at,
]; ];
@ -80,7 +79,7 @@
$this->kode = $debitur->kode; $this->kode = $debitur->kode;
$this->name = $debitur->name; $this->name = $debitur->name;
$this->branch_id = $debitur->branch_id; $this->branch_id = $debitur->branch_id;
$this->status = $debitur->status; $this->status = $debitur->status==1?true:false;
$this->address = $debitur->address; $this->address = $debitur->address;
$this->npwp = $debitur->npwp; $this->npwp = $debitur->npwp;
$this->registered_at = $debitur->registered_at; $this->registered_at = $debitur->registered_at;
@ -103,13 +102,10 @@
protected function rules() protected function rules()
{ {
if ($this->edit_mode) { if ($this->edit_mode) {
$request = new UpdateDebiturRequest(); $request = new UpdateRekeningRequest();
} else { } else {
$request = new StoreDebiturRequest(); $request = new StoreDebiturRequest();
} }
dd($request->rules());
return $request->rules(); return $request->rules();
} }
} }

View File

@ -99,12 +99,13 @@
<span class="text-danger">{{ $message }}</span> @enderror <span class="text-danger">{{ $message }}</span> @enderror
</div> </div>
<!--end::Input group--> <!--end::Input group-->
<div class="form-check form-switch form-check-custom form-check-solid" style="display: block!important;"> <div class="form-check form-switch form-check-custom form-check-solid" style="display: block!important;">
<input class="form-check-input h-20px w-30px me-5" type="checkbox"wire:model.defer="status" name="status" value="A"/> <input class="form-check-input h-20px w-30px me-5" type="checkbox" wire:model.defer="status" id="status" name="status"/>
<label class="form-check-label" for="status"> <label class="form-check-label" for="status">
Aktif Aktif
</label> </label>
@error('status')
<span class="text-danger">{{ $message }}</span> @enderror
</div> </div>
</div> </div>

View File

@ -1,7 +1,7 @@
<x-default-layout> <x-default-layout>
@section('title') @section('title')
Cabang Debitur
@endsection @endsection
@section('breadcrumbs') @section('breadcrumbs')