ekosistem dan framework
This commit is contained in:
@@ -23,7 +23,7 @@ class ValueBasisDataController extends Controller
|
||||
{
|
||||
public function index(Request $request, string $tabelId): View
|
||||
{
|
||||
if (!Gate::any(['super_admin', 'admin'])) {
|
||||
if (!Gate::any(['super_admin', 'admin', 'fasilitator'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
@@ -44,13 +44,15 @@ class ValueBasisDataController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
$tabel = TabelBasisData::find($tabelId);
|
||||
$tabel = TabelBasisData::with('kolom')
|
||||
->whereHas('kolom', function ($query) {
|
||||
$query->where('is_active', true);
|
||||
})->find($tabelId);
|
||||
if (!$tabel) {
|
||||
abort(404, 'Data tabel tidak ditemukan.');
|
||||
}
|
||||
$kolom = KolomBasisData::where('tabel_id', $tabelId)
|
||||
$kolom = KolomBasisData::where('tabel_id', $tabel->id)
|
||||
->where('is_active', true)
|
||||
->where('is_browse', true)
|
||||
->get();
|
||||
if ($kolom->isEmpty()) {
|
||||
abort(404, 'Data kolom tidak ditemukan untuk tabel ini.');
|
||||
@@ -165,7 +167,10 @@ class ValueBasisDataController extends Controller
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$tabel = TabelBasisData::find($tabelId);
|
||||
$tabel = TabelBasisData::with('kolom')
|
||||
->whereHas('kolom', function ($query) {
|
||||
$query->where('is_active', true);
|
||||
})->find($tabelId);
|
||||
if (!$tabel) {
|
||||
abort(404, 'Data tabel tidak ditemukan.');
|
||||
}
|
||||
@@ -213,7 +218,10 @@ class ValueBasisDataController extends Controller
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$tabel = TabelBasisData::find($tabelId);
|
||||
$tabel = TabelBasisData::with('kolom')
|
||||
->whereHas('kolom', function ($query) {
|
||||
$query->where('is_active', true);
|
||||
})->find($tabelId);
|
||||
if (!$tabel) {
|
||||
abort(404, 'Data tabel tidak ditemukan.');
|
||||
}
|
||||
@@ -282,7 +290,10 @@ class ValueBasisDataController extends Controller
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$tabel = TabelBasisData::find($tabelId);
|
||||
$tabel = TabelBasisData::with('kolom')
|
||||
->whereHas('kolom', function ($query) {
|
||||
$query->where('is_active', true);
|
||||
})->find($tabelId);
|
||||
if (!$tabel) {
|
||||
abort(404, 'Data tabel tidak ditemukan.');
|
||||
}
|
||||
@@ -339,7 +350,10 @@ class ValueBasisDataController extends Controller
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$tabel = TabelBasisData::find($tabelId);
|
||||
$tabel = TabelBasisData::with('kolom')
|
||||
->whereHas('kolom', function ($query) {
|
||||
$query->where('is_active', true);
|
||||
})->find($tabelId);
|
||||
if (!$tabel) {
|
||||
abort(404, 'Data tabel tidak ditemukan.');
|
||||
}
|
||||
@@ -402,7 +416,10 @@ class ValueBasisDataController extends Controller
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$tabel = TabelBasisData::find($tabelId);
|
||||
$tabel = TabelBasisData::with('kolom')
|
||||
->whereHas('kolom', function ($query) {
|
||||
$query->where('is_active', true);
|
||||
})->find($tabelId);
|
||||
if (!$tabel) {
|
||||
abort(404, 'Data tabel tidak ditemukan.');
|
||||
}
|
||||
|
||||
@@ -54,6 +54,9 @@ class AktivitasController extends Controller
|
||||
'jenis_aktivitas' => ['required','string','max:255', Rule::in(['tujuan', 'aktivitas']),],
|
||||
'indikator' => ['required','string'],
|
||||
'deskripsi' => ['required','string'],
|
||||
'parent_id' => [
|
||||
Rule::requiredIf($request->jenis_aktivitas === 'aktivitas'),
|
||||
'nullable','exists:program_aktivitas,id',],
|
||||
]);
|
||||
|
||||
Aktivitas::create([...$validated,
|
||||
@@ -125,6 +128,9 @@ class AktivitasController extends Controller
|
||||
'jenis_aktivitas' => ['required','string','max:255', Rule::in(['tujuan', 'aktivitas']),],
|
||||
'indikator' => ['required','string'],
|
||||
'deskripsi' => ['required','string'],
|
||||
'parent_id' => [
|
||||
Rule::requiredIf($request->jenis_aktivitas === 'aktivitas'),
|
||||
'nullable','exists:program_aktivitas,id'],
|
||||
]);
|
||||
|
||||
$aktivitas->update([...$validated,
|
||||
|
||||
@@ -102,7 +102,8 @@ class FrameworkController extends Controller
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$framework = Framework::findOrFail($id);
|
||||
$framework = Framework::with('transformasi')->with('transformasi.tujuan')
|
||||
->findOrFail($id);
|
||||
$program = Program::all();
|
||||
|
||||
return view('program.framework.edit', compact('framework', 'program'));
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Web\Program;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
use App\Models\Program\Framework;
|
||||
use App\Models\Program\Realisasi;
|
||||
|
||||
class RealisasiController extends Controller
|
||||
{
|
||||
public function index(Request $request): View
|
||||
{
|
||||
if (!Gate::any(['super_admin', 'admin'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$framework = Framework::when($request->has('frameworkid'), function ($query) use ($request) {
|
||||
$query->where('id', $request->frameworkid);
|
||||
})->latest()->first();
|
||||
if ($framework == null) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
return view('program.realisasi.index', compact('framework'));
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
if (!Gate::any(['super_admin', 'admin'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$validated = $request->validate([
|
||||
'target_id' => ['required', 'integer', 'exists:program_target,id'],
|
||||
'realisasi_integer' => ['nullable', 'integer'],
|
||||
'realisasi_float' => ['nullable', 'numeric'],
|
||||
'realisasi_boolean' => ['nullable', 'boolean'],
|
||||
]);
|
||||
|
||||
$realisasi = Realisasi::create([...$validated,
|
||||
'created_by' => auth()->id(),
|
||||
'updated_by' => auth()->id()
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Target berhasil ditambahkan.'
|
||||
], 201);
|
||||
}
|
||||
|
||||
public function show(string $id)
|
||||
{
|
||||
if (!Gate::any(['super_admin', 'admin'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$realisasi = Realisasi::with('target', 'target.aktivitas', 'target.aktivitas.transformasi')
|
||||
->find($id);
|
||||
if (!$realisasi) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Data realisasi tidak ditemukan.'
|
||||
], 404);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'data' => $realisasi
|
||||
]);
|
||||
}
|
||||
|
||||
public function edit(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function update(Request $request, string $id): JsonResponse
|
||||
{
|
||||
if (!Gate::any(['super_admin', 'admin'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$realisasi = Realisasi::find($id);
|
||||
if (!$realisasi) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Data realisasi tidak ditemukan.'
|
||||
], 404);
|
||||
}
|
||||
|
||||
$validated = $request->validate([
|
||||
'target_id' => ['required', 'integer', 'exists:program_target,id'],
|
||||
'realisasi_integer' => ['nullable', 'integer'],
|
||||
'realisasi_float' => ['nullable', 'numeric'],
|
||||
'realisasi_boolean' => ['nullable', 'boolean'],
|
||||
]);
|
||||
|
||||
$realisasi->update([...$validated,
|
||||
'updated_by' => auth()->id(),
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Target berhasil diperbarui.'
|
||||
], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -69,6 +69,16 @@ class TargetController extends Controller
|
||||
'nullable',
|
||||
'boolean'
|
||||
],
|
||||
'tipe_realisasi' => [
|
||||
'nullable',
|
||||
'string',
|
||||
Rule::in(['manual', 'referensi'])
|
||||
],
|
||||
'value_query' => [
|
||||
Rule::requiredIf($request->tipe_realisasi === 'referensi'),
|
||||
'nullable',
|
||||
'string'
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -77,9 +87,6 @@ class TargetController extends Controller
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request, string $frameworkId, string $transformasiId, string $aktivitasId): JsonResponse
|
||||
{
|
||||
if (!Gate::any(['super_admin', 'admin'])) {
|
||||
@@ -109,12 +116,32 @@ class TargetController extends Controller
|
||||
], 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
public function show(string $frameworkId, string $transformasiId, string $aktivitasId, string $id)
|
||||
{
|
||||
//
|
||||
if (!Gate::any(['super_admin', 'admin'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$target = Target::with('realisasi', 'latestRealisasi')
|
||||
->whereHas('aktivitas.transformasi', function ($query) use ($frameworkId) {
|
||||
$query->where('framework_id', $frameworkId);
|
||||
})
|
||||
->whereHas('aktivitas', function ($query) use ($transformasiId) {
|
||||
$query->where('transformasi_id', $transformasiId);
|
||||
})
|
||||
->where('aktivitas_id', $aktivitasId)->find($id);
|
||||
|
||||
if (!$target) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Data target tidak ditemukan.'
|
||||
], 404);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'data' => $target
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,16 +155,67 @@ class TargetController extends Controller
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
public function update(Request $request, string $frameworkId, string $transformasiId, string $aktivitasId, string $id)
|
||||
{
|
||||
//
|
||||
if (!Gate::any(['super_admin', 'admin'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$target = Target::whereHas('aktivitas.transformasi', function ($query) use ($frameworkId) {
|
||||
$query->where('framework_id', $frameworkId);
|
||||
})
|
||||
->whereHas('aktivitas', function ($query) use ($transformasiId) {
|
||||
$query->where('transformasi_id', $transformasiId);
|
||||
})
|
||||
->where('aktivitas_id', $aktivitasId)->find($id);
|
||||
|
||||
if (!$target) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Data target tidak ditemukan.'
|
||||
], 404);
|
||||
}
|
||||
|
||||
$validated = $this->validated($request);
|
||||
$target->update([...$validated,
|
||||
'updated_by' => auth()->id(),
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Target berhasil diperbarui.'
|
||||
], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
public function destroy(string $frameworkId, string $transformasiId, string $aktivitasId, string $id)
|
||||
{
|
||||
//
|
||||
if (!Gate::any(['super_admin', 'admin'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$target = Target::whereHas('aktivitas.transformasi', function ($query) use ($frameworkId) {
|
||||
$query->where('framework_id', $frameworkId);
|
||||
})
|
||||
->whereHas('aktivitas', function ($query) use ($transformasiId) {
|
||||
$query->where('transformasi_id', $transformasiId);
|
||||
})
|
||||
->where('aktivitas_id', $aktivitasId)->find($id);
|
||||
|
||||
if (!$target) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Data target tidak ditemukan.'
|
||||
], 404);
|
||||
}
|
||||
|
||||
$target->update([
|
||||
'deleted_by' => auth()->id(),
|
||||
]);
|
||||
$target->delete();
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Target berhasil dihapus.'
|
||||
], 200);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Web\Program;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
use App\Models\Program\Framework;
|
||||
use App\Models\Program\Realisasi;
|
||||
use App\Models\Program\Verifikasi;
|
||||
|
||||
class VerifikasiController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
if (!Gate::any(['super_admin', 'admin'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$validated = $request->validate([
|
||||
'realisasi_id' => ['required', 'integer', 'exists:program_realisasi,id'],
|
||||
'dokumen' => ['required', 'string'],
|
||||
'link_dokumen' => ['required', 'url'],
|
||||
]);
|
||||
|
||||
$verifikasi = Verifikasi::create([...$validated,
|
||||
'created_by' => auth()->id(),
|
||||
'updated_by' => auth()->id()
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Dokumen bukti berhasil ditambahkan.'
|
||||
], 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id): JsonResponse
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user