update module debitur
This commit is contained in:
parent
99a55080dc
commit
cf23254f07
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Modules\Writeoff\DataTables;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder as QueryBuilder;
|
||||
use Modules\Writeoff\Entities\Branch;
|
||||
use Modules\Writeoff\Entities\Debitur;
|
||||
@ -28,14 +29,15 @@
|
||||
->orWhere('name', 'like', "%" . $search['value'] . "%");
|
||||
}
|
||||
})->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) {
|
||||
return $row->branch_id ? Branch::find($row->branch_id)->name : '-';
|
||||
})->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>';
|
||||
return $status.' '.$oto;
|
||||
})->rawColumns(['action'])->addColumn('action', function ($debitur) {
|
||||
})->rawColumns(['action','status'])->addColumn('action', function ($debitur) {
|
||||
return view('writeoff::parameter.debitur._actions', compact('debitur'));
|
||||
})->setRowId('id');
|
||||
}
|
||||
|
@ -1,26 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Modules\Writeoff\Entities\Branch;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
return new class extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
public function up()
|
||||
: void
|
||||
{
|
||||
Schema::create('debitur', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignIdFor(Branch::class)->constrained()->onDelete('cascade');
|
||||
$table->string('kode',4)->unique();
|
||||
$table->string('kode', 6)->unique();
|
||||
$table->string('name');
|
||||
$table->timestamp('registered_at')->nullable();
|
||||
$table->date('registered_at')->nullable();
|
||||
$table->text('address')->nullable();
|
||||
$table->string('npwp',16)->nullable();
|
||||
$table->char('status', 1)->default('A');
|
||||
$table->string('npwp', 16)->nullable();
|
||||
$table->boolean('status')->default(true)->nullable();
|
||||
$table->timestamps();
|
||||
$table->timestamp('authorized_at')->nullable();
|
||||
$table->char('authorized_status', 1)->nullable();
|
||||
@ -36,8 +36,9 @@ use Illuminate\Support\Facades\Schema;
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
public function down()
|
||||
: void
|
||||
{
|
||||
Schema::dropIfExists('debitur');
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@ -16,4 +16,8 @@
|
||||
'authorized_by',
|
||||
];
|
||||
|
||||
public function debiturs()
|
||||
{
|
||||
return $this->hasMany(Debitur::class);
|
||||
}
|
||||
}
|
||||
|
@ -18,4 +18,14 @@
|
||||
'authorized_by',
|
||||
];
|
||||
|
||||
public function branch()
|
||||
{
|
||||
return $this->belongsTo(Branch::class);
|
||||
}
|
||||
|
||||
public function rekenings()
|
||||
{
|
||||
return $this->hasMany(Rekening::class);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -28,10 +28,10 @@
|
||||
: array
|
||||
{
|
||||
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',
|
||||
'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',
|
||||
'npwp' => 'nullable|string|max:16|min:16',
|
||||
'registered_at' => 'nullable|date_format:Y-m-d'
|
||||
@ -75,11 +75,4 @@
|
||||
'messages' => 'Debitur created failed.'
|
||||
], JsonResponse::HTTP_UNPROCESSABLE_ENTITY));
|
||||
}
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'status' => $this->status ? 'A' : 'I'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -33,10 +33,10 @@
|
||||
$this->_id = json_decode(json_decode(file_get_contents('php://input'))->components[0]->snapshot)->data->id;
|
||||
|
||||
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',
|
||||
'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',
|
||||
'npwp' => 'nullable|string|max:16|min:16',
|
||||
'registered_at' => 'nullable|date_format:Y-m-d'
|
||||
@ -72,11 +72,4 @@
|
||||
'messages' => 'Debitur updated failed.'
|
||||
], JsonResponse::HTTP_UNPROCESSABLE_ENTITY));
|
||||
}
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'status' => $this->status ? 'A' : 'I'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
use Modules\Writeoff\Entities\Branch;
|
||||
use Modules\Writeoff\Entities\Debitur;
|
||||
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
|
||||
{
|
||||
@ -48,7 +48,6 @@
|
||||
'address' => $this->address,
|
||||
'npwp' => $this->npwp,
|
||||
'registered_at' => $this->registered_at,
|
||||
|
||||
];
|
||||
|
||||
|
||||
@ -80,7 +79,7 @@
|
||||
$this->kode = $debitur->kode;
|
||||
$this->name = $debitur->name;
|
||||
$this->branch_id = $debitur->branch_id;
|
||||
$this->status = $debitur->status;
|
||||
$this->status = $debitur->status==1?true:false;
|
||||
$this->address = $debitur->address;
|
||||
$this->npwp = $debitur->npwp;
|
||||
$this->registered_at = $debitur->registered_at;
|
||||
@ -103,13 +102,10 @@
|
||||
protected function rules()
|
||||
{
|
||||
if ($this->edit_mode) {
|
||||
$request = new UpdateDebiturRequest();
|
||||
$request = new UpdateRekeningRequest();
|
||||
} else {
|
||||
$request = new StoreDebiturRequest();
|
||||
}
|
||||
|
||||
dd($request->rules());
|
||||
|
||||
return $request->rules();
|
||||
}
|
||||
}
|
||||
|
@ -99,12 +99,13 @@
|
||||
<span class="text-danger">{{ $message }}</span> @enderror
|
||||
</div>
|
||||
<!--end::Input group-->
|
||||
|
||||
<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">
|
||||
Aktif
|
||||
</label>
|
||||
@error('status')
|
||||
<span class="text-danger">{{ $message }}</span> @enderror
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<x-default-layout>
|
||||
|
||||
@section('title')
|
||||
Cabang
|
||||
Debitur
|
||||
@endsection
|
||||
|
||||
@section('breadcrumbs')
|
||||
|
Loading…
Reference in New Issue
Block a user