Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions apps/backend/app/Http/Controllers/Api/LetterCategoryController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use app\Services\LetterCategoryService;
use Illuminate\Http\JsonResponse;

class LetterCategoryController extends Controller
{
public function __construct(
private readonly LetterCategoryService $service,
) {}

public function index(): JsonResponse
{
return response()->json(['data' => $this->service->getAllCategories()]);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

namespace App\Http\Controllers;
namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class NotificationController extends Controller
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

namespace App\Http\Controllers;
namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Models\Citizen;
use App\Models\Letter;
use Carbon\Carbon;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Models\User;
use app\Models\User;
use Illuminate\Auth\Events\Registered;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/app/Http/Requests/Auth/LoginRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Http\Requests\Auth;

use App\Models\User;
use app\Models\User;
use Illuminate\Auth\Events\Lockout;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
Expand Down
36 changes: 36 additions & 0 deletions apps/backend/app/Models/LetterCategory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace App\Models;

use Database\Factories\LetterCategoriesFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;

class LetterCategory extends Model
{
/** @use HasFactory<LetterCategoriesFactory> */
use HasFactory;

protected $fillable = [
'code',
'name',
'description',
'handler_class',
'is_active',
];

protected $casts = [
'is_active' => 'boolean',
];

public function flows(): HasMany
{
return $this->hasMany(ApprovalFlow::class, 'category_id');
}

public function letterTypes(): HasMany
{
return $this->hasMany(LetterType::class, 'category_id');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Notifications;

use App\Models\Letter;
use app\Models\Letter;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;

Expand Down
24 changes: 24 additions & 0 deletions apps/backend/app/Repositories/LetterCategoryRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace app\Repositories;

use app\Models\LetterCategory;
use Illuminate\Database\Eloquent\Collection;

class LetterCategoryRepository
{
public function findByCode(string $code): ?LetterCategory
{
return LetterCategory::query()->where('code', $code)->first();
}

public function findAllActive(): Collection
{
return LetterCategory::query()->where('is_active', true)->get();
}

public function all(): Collection
{
return LetterCategory::query()->orderBy('id')->get();
}
}
6 changes: 3 additions & 3 deletions apps/backend/app/Services/KadusApprovalService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace App\Services;

use App\Models\Letter;
use App\Models\Official;
use App\Models\User;
use app\Models\Letter;
use app\Models\Official;
use app\Models\User;
use App\Notifications\LetterStatusNotification;
use Illuminate\Support\Facades\DB;

Expand Down
4 changes: 2 additions & 2 deletions apps/backend/app/Services/KasiApprovalService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace App\Services;

use App\Enums\LetterStatus;
use App\Models\Letter;
use App\Models\User;
use app\Models\Letter;
use app\Models\User;
use App\Notifications\LetterStatusNotification;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\DB;
Expand Down
4 changes: 2 additions & 2 deletions apps/backend/app/Services/LetterApprovalService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace App\Services;

use App\Models\Letter;
use App\Models\Official;
use app\Models\Letter;
use app\Models\Official;
use Illuminate\Validation\ValidationException;

class LetterApprovalService
Expand Down
38 changes: 38 additions & 0 deletions apps/backend/app/Services/LetterCategoryService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace app\Services;

use app\Repositories\LetterCategoryRepository;
use Illuminate\Database\Eloquent\Collection;

class LetterCategoryService
{
public function __construct(
private readonly LetterCategoryRepository $repository,
) {}

/**
* Ambil seluruh kategori surat (termasuk yang nonaktif), sesuai
* kontrak GET /letter-categories di api_spec_v5.
*/
public function getAllCategories(): Collection
{
return $this->repository->all();
}

/**
* Ambil satu kategori berdasarkan code, atau null bila tidak ada.
*/
public function getByCode(string $code)
{
return $this->repository->findByCode($code);
}

/**
* Ambil seluruh kategori yang aktif saja.
*/
public function getActiveCategories(): Collection
{
return $this->repository->findAllActive();
}
}
8 changes: 4 additions & 4 deletions apps/backend/app/Services/LetterService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace App\Services;

use App\Models\Letter;
use App\Models\LetterStatusLog;
use App\Models\LetterType;
use App\Models\User;
use app\Models\Letter;
use app\Models\LetterStatusLog;
use app\Models\LetterType;
use app\Models\User;
use App\Notifications\LetterStatusNotification;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\DB;
Expand Down
8 changes: 4 additions & 4 deletions apps/backend/app/Services/OfficialService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace App\Services;

use App\Models\Citizen;
use App\Models\Letter;
use App\Models\Official;
use App\Models\User;
use app\Models\Citizen;
use app\Models\Letter;
use app\Models\Official;
use app\Models\User;

class OfficialService
{
Expand Down
6 changes: 3 additions & 3 deletions apps/backend/app/Services/PdfService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace App\Services;

use App\Enums\LetterStatus;
use App\Models\Letter;
use App\Models\Official;
use App\Models\User;
use app\Models\Letter;
use app\Models\Official;
use app\Models\User;
use Barryvdh\DomPDF\Facade\Pdf;
use Symfony\Component\HttpFoundation\Response;

Expand Down
6 changes: 3 additions & 3 deletions apps/backend/app/Services/RtApprovalService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace App\Services;

use App\Models\Letter;
use App\Models\Official;
use App\Models\User;
use app\Models\Letter;
use app\Models\Official;
use app\Models\User;
use App\Notifications\LetterStatusNotification;
use Illuminate\Support\Facades\DB;

Expand Down
4 changes: 2 additions & 2 deletions apps/backend/app/Services/RwApprovalService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace App\Services;

use App\Enums\LetterStatus;
use App\Models\Letter;
use App\Models\User;
use app\Models\Letter;
use app\Models\User;
use App\Notifications\LetterStatusNotification;
use Illuminate\Support\Facades\DB;

Expand Down
2 changes: 1 addition & 1 deletion apps/backend/config/auth.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use App\Models\User;
use app\Models\User;

return [

Expand Down
24 changes: 24 additions & 0 deletions apps/backend/database/factories/LetterCategoriesFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Database\Factories;

use app\Models\LetterCategory;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @extends Factory<LetterCategory>
*/
class LetterCategoriesFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
//
];
}
}
18 changes: 18 additions & 0 deletions apps/backend/database/factories/LetterCategoryFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Database\Factories;

use app\Models\LetterCategory;
use Illuminate\Database\Eloquent\Factories\Factory;

class LetterCategoryFactory extends Factory
{
protected $model = LetterCategory::class;

public function definition(): array
{
return [

];
}
}
2 changes: 1 addition & 1 deletion apps/backend/database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Database\Factories;

use App\Models\User;
use app\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('letter_categories', function (Blueprint $table) {
$table->id();
$table->enum('code', [
'approval_normal',
'upload_mandiri',
'dokumen_pendukung',
'update_data',
])->unique();
$table->string('name', 100);
$table->text('description')->nullable();
$table->string('handler_class', 150);
$table->boolean('is_active')->default(true);
$table->timestamps();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('letter_categories');
}
};
2 changes: 1 addition & 1 deletion apps/backend/database/seeders/AdminSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Database\Seeders;

use App\Models\User;
use app\Models\User;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;

Expand Down
2 changes: 1 addition & 1 deletion apps/backend/database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Database\Seeders;

use App\Models\User;
use app\Models\User;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;

Expand Down
Loading
Loading