Skip to content

Commit 8ad61b6

Browse files
pandigresikvickyrolandaFirlianiFagungsugiartoapidong
authored
Rilis v2506.0.0 (#490)
Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Abah Roland <[email protected]> Co-authored-by: Firliani Fauziah <[email protected]> Co-authored-by: Agung Sugiarto <[email protected]> Co-authored-by: Afila <[email protected]> Co-authored-by: sarwono <[email protected]> Co-authored-by: scqolbu24 <[email protected]> Co-authored-by: agungsugiarto <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: misarianto <[email protected]> Co-authored-by: misarianto <[email protected]> Co-authored-by: Habibie <[email protected]>
1 parent a0c585e commit 8ad61b6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1448
-325
lines changed

.github/workflows/deploy_prod.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Deploy Pantau to Production
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
deploy:
9+
name: Deploy to Production Server
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Setup SSH
17+
uses: appleboy/ssh-action@v1
18+
with:
19+
host: ${{ secrets.PROD_HOST }}
20+
username: ${{ secrets.PROD_USER }}
21+
key: ${{ secrets.PROD_SSH_KEY }}
22+
port: ${{ secrets.PROD_PORT }}
23+
script: |
24+
cd ${{ secrets.PROD_DEPLOY_PATH }}
25+
# Restore to the state of the remote branch
26+
git fetch origin ${{ secrets.BRANCH || 'main' }}
27+
git reset --hard origin/${{ secrets.BRANCH || 'main' }}
28+
# Pull the latest changes from the remote branch
29+
git pull origin ${{ secrets.BRANCH || 'main' }}
30+
composer install --no-interaction --prefer-dist --optimize-autoloader
31+
php artisan migrate --force
32+
php artisan config:cache
33+
php artisan route:cache
34+
php artisan view:cache
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Deploy Pantau to Staging
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
deploy:
9+
name: Deploy to Staging Server
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Setup SSH
17+
uses: appleboy/ssh-action@v1
18+
with:
19+
host: ${{ secrets.STAG_HOST }}
20+
username: ${{ secrets.STAG_USER }}
21+
key: ${{ secrets.STAG_SSH_KEY }}
22+
port: ${{ secrets.STAG_PORT }}
23+
script: |
24+
cd ${{ secrets.STAG_DEPLOY_PATH }}
25+
# Restore to the state of the remote branch
26+
git fetch origin ${{ secrets.BRANCH || 'main' }}
27+
git reset --hard origin/${{ secrets.BRANCH || 'main' }}
28+
# Pull the latest changes from the remote branch
29+
git pull origin ${{ secrets.BRANCH || 'main' }}
30+
composer install --no-interaction --prefer-dist --optimize-autoloader
31+
php artisan migrate --force
32+
php artisan config:cache
33+
php artisan route:cache
34+
php artisan view:cache

.github/workflows/test.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Laravel Test
2+
3+
on:
4+
pull_request:
5+
branches: [master, rilis-dev, bug-fix]
6+
7+
jobs:
8+
laravel-tests:
9+
10+
runs-on: ubuntu-latest
11+
services:
12+
mysql:
13+
image: mysql:8.0
14+
env:
15+
MYSQL_DATABASE: testing_db
16+
MYSQL_ROOT_PASSWORD: secret
17+
ports:
18+
- 3306:3306
19+
options: >-
20+
--health-cmd="mysqladmin ping --silent"
21+
--health-interval=10s
22+
--health-timeout=5s
23+
--health-retries=3
24+
25+
steps:
26+
- name: Setup PHP
27+
uses: shivammathur/setup-php@v2
28+
with:
29+
php-version: '8.1'
30+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv
31+
coverage: none
32+
33+
- uses: actions/checkout@v4
34+
- name: Copy .env
35+
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
36+
37+
- name: Install Dependencies
38+
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
39+
40+
- name: Generate key
41+
run: php artisan key:generate
42+
43+
- name: Directory Permissions
44+
run: chmod -R 777 storage bootstrap/cache
45+
46+
- name: Extract database testing
47+
run: |
48+
tar -xzf database/database_test.sql.tar.gz -C database
49+
50+
- name: Wait for MySQL
51+
run: sleep 15
52+
53+
- name: Import SQL file into MySQL
54+
run: |
55+
mysql -h 127.0.0.1 -P 3306 -u root -psecret testing_db < ./database/database_test.sql
56+
57+
- name: Execute tests (Unit and Feature tests) via PHPUnit/Pest
58+
env:
59+
DB_CONNECTION: mysql
60+
DB_DATABASE: testing_db
61+
DB_USERNAME: root
62+
DB_PASSWORD: secret
63+
run: php artisan migrate && php artisan test

app/Exports/MargaExport.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace App\Exports;
4+
5+
use Maatwebsite\Excel\Concerns\FromCollection;
6+
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
7+
use Maatwebsite\Excel\Concerns\WithHeadings;
8+
9+
class MargaExport implements FromCollection, WithHeadings, ShouldAutoSize
10+
{
11+
protected $data;
12+
13+
public function __construct($data)
14+
{
15+
$this->data = $data;
16+
}
17+
18+
public function collection()
19+
{
20+
return $this->data->map(function ($item, $index) {
21+
return [
22+
'no' => $index + 1, // Menambahkan nomor urut berdasarkan index
23+
'nama_marga' => $item->name,
24+
'nama_suku' => $item->suku->name,
25+
'kode_wilayah' => $item->suku->region->region_code,
26+
'nama_provinsi' => $item->suku->region->region_name,
27+
];
28+
});
29+
}
30+
31+
public function headings(): array
32+
{
33+
return [
34+
'NO',
35+
'NAMA MARGA',
36+
'NAMA SUKU',
37+
'KODE WILAYAH',
38+
'NAMA PROVINSI',
39+
];
40+
}
41+
}

app/Exports/SukuExport.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44

55
use Maatwebsite\Excel\Concerns\FromCollection;
66
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
7+
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
78
use Maatwebsite\Excel\Concerns\WithHeadings;
9+
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
810

9-
class SukuExport implements FromCollection, WithHeadings, ShouldAutoSize
11+
class SukuExport implements FromCollection, WithHeadings, ShouldAutoSize, WithColumnFormatting
1012
{
1113
protected $data;
1214

@@ -18,11 +20,13 @@ public function __construct($data)
1820
public function collection()
1921
{
2022
return $this->data->map(function ($item, $index) {
23+
$jumlahMarga = $item->marga_count ?? 0;
2124
return [
2225
'no' => $index + 1, // Menambahkan nomor urut berdasarkan index
2326
'nama_suku' => $item->name,
2427
'kode_wilayah' => $item->region->region_code,
2528
'nama_provinsi' => $item->region->region_name,
29+
'marga_count' => $jumlahMarga > 0 ? $jumlahMarga : '0',
2630
];
2731
});
2832
}
@@ -34,6 +38,14 @@ public function headings(): array
3438
'NAMA SUKU',
3539
'KODE WILAYAH',
3640
'NAMA PROVINSI',
41+
'JUMLAH MARGA',
42+
];
43+
}
44+
45+
public function columnFormats(): array
46+
{
47+
return [
48+
'E' => NumberFormat::FORMAT_NUMBER, // Format kolom E sebagai angka
3749
];
3850
}
3951
}

app/Helpers/helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212
function pantau_versi()
1313
{
14-
return 'v2505.0.0';
14+
return 'v2506.0.0';
1515
}
1616
}
1717

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Admin;
4+
5+
use App\Exports\MargaExport;
6+
use App\Http\Controllers\Controller;
7+
use App\Http\Requests\MargaRequest;
8+
use App\Imports\MargaImport;
9+
use App\Models\Marga;
10+
use App\Models\Suku;
11+
use Illuminate\Http\Request;
12+
use Illuminate\Support\Facades\Storage;
13+
use Maatwebsite\Excel\Facades\Excel;
14+
use Yajra\DataTables\DataTables;
15+
16+
class MargaController extends Controller
17+
{
18+
public function index(Request $request)
19+
{
20+
if ($request->excel) {
21+
$paramDatatable = json_decode($request->get('params'), 1);
22+
$request->merge($paramDatatable);
23+
}
24+
25+
if ($request->ajax() || $request->excel) {
26+
$provinsi = $request->kode_provinsi;
27+
$suku = $request->suku;
28+
$query = DataTables::of(Marga::with(['suku' => static fn($q) => $q->with('region')])
29+
->when($provinsi, static fn($q) => $q->whereHas('suku.region', static fn($q) => $q->where('region_code', $provinsi)))
30+
->when($suku, static fn($q) => $q->where('ethnic_group_id', $suku))
31+
);
32+
if ($request->excel) {
33+
$query->filtering();
34+
35+
return Excel::download(new MargaExport($query->results()), 'Wilayah-Marga.xlsx');
36+
}
37+
38+
return $query->addIndexColumn()
39+
->addColumn('action', function ($data) {
40+
$edit = '<a href="'.route('marga.edit', $data->id).'" class="btn btn-sm btn-warning btn-sm"><i class="fas fa-pencil-alt"></i></a>';
41+
$delete = '<button data-href="'.route('marga.destroy', $data->id).'" class="btn btn-sm btn-danger" data-toggle="modal" data-target="#confirm-delete"><i class="fas fa-trash"></i></button>';
42+
43+
return '<div class="btn btn-group">'.$edit.$delete.'</div>';
44+
})
45+
->rawColumns(['action'])
46+
->make(true);
47+
}
48+
$fillters = [
49+
'kode_provinsi' => [],
50+
'suku' => [],
51+
];
52+
if($request->suku){
53+
$suku = Suku::with('region')->findOrFail($request->suku);
54+
$fillters = [
55+
'kode_provinsi' => ['id' => $suku->region->region_code, 'name' => $suku->region->region_name],
56+
'suku' => ['id' => $suku->id, 'name' => $suku->name],
57+
];
58+
}
59+
60+
return view('admin.marga.index', compact('fillters'));
61+
}
62+
63+
public function create()
64+
{
65+
return view('admin.marga.create');
66+
}
67+
68+
public function store(MargaRequest $request)
69+
{
70+
$input = $request->all();
71+
if (Marga::create($input)) {
72+
return redirect('marga')->with('success', 'Data berhasil disimpan');
73+
}
74+
75+
return back()->with('error', 'Data gagal disimpan');
76+
}
77+
78+
public function edit($id)
79+
{
80+
return view('admin.marga.edit', [
81+
'marga' => Marga::with(['suku' => static fn($q) => $q->with('region')])->findOrFail($id),
82+
]);
83+
}
84+
85+
public function update(MargaRequest $request, $id)
86+
{
87+
$input = $request->all();
88+
$marga = Marga::findOrFail($id);
89+
90+
if ($marga->update($input)) {
91+
return redirect('marga')->with('success', 'Data berhasil diubah');
92+
}
93+
94+
return back()->with('error', 'Data gagal diubah');
95+
}
96+
97+
public function import()
98+
{
99+
return view('admin.marga.import');
100+
}
101+
102+
public function prosesImport(Request $request)
103+
{
104+
try {
105+
Excel::import(new MargaImport, $request->file('file')->store('temp'));
106+
} catch (\Exception $e) {
107+
report($e);
108+
109+
return back()->with('error', 'Data gagal diimport');
110+
}
111+
112+
// Hapus folder temp ketika sudah selesai
113+
Storage::deleteDirectory('temp');
114+
115+
return redirect('marga')->with('success', 'Data berhasil diimport');
116+
}
117+
118+
public function contohImport()
119+
{
120+
$file = public_path('/assets/import/data_marga.xlsx');
121+
122+
return response()->download($file);
123+
}
124+
125+
public function destroy($id)
126+
{
127+
if (Marga::destroy($id)) {
128+
return redirect('marga')->with('success', 'Data berhasil dihapus');
129+
}
130+
131+
return redirect('marga')->with('error', 'Data gagal dihapus');
132+
}
133+
}

app/Http/Controllers/Admin/SukuController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function index(Request $request)
2323
}
2424

2525
if ($request->ajax() || $request->excel) {
26-
$query = DataTables::of(Suku::with('region'));
26+
$query = DataTables::of(Suku::with('region')->withCount('marga'));
2727
if ($request->excel) {
2828
$query->filtering();
2929

@@ -32,10 +32,11 @@ public function index(Request $request)
3232

3333
return $query->addIndexColumn()
3434
->addColumn('action', function ($data) {
35+
$detail = '<a href="'.route('marga.index', ['suku' => $data->id]).'" class="btn btn-sm btn-info btn-sm"><i class="fas fa-list-alt"></i></a>';
3536
$edit = '<a href="'.route('suku.edit', $data->id).'" class="btn btn-sm btn-warning btn-sm"><i class="fas fa-pencil-alt"></i></a>';
3637
$delete = '<button data-href="'.route('suku.destroy', $data->id).'" class="btn btn-sm btn-danger" data-toggle="modal" data-target="#confirm-delete"><i class="fas fa-trash"></i></button>';
3738

38-
return '<div class="btn btn-group">'.$edit.$delete.'</div>';
39+
return '<div class="btn btn-group">'.$detail.$edit.$delete.'</div>';
3940
})
4041
->rawColumns(['action'])
4142
->make(true);

0 commit comments

Comments
 (0)