Skip to content

Commit c9965ad

Browse files
committed
fix seeder, migration, and admin pnel on report
1 parent 15bf259 commit c9965ad

File tree

9 files changed

+48
-2
lines changed

9 files changed

+48
-2
lines changed

app/Http/Controllers/Admin/ReportController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function index()
3131
public function show($id)
3232
{
3333
$jobtask = JobtaskResult::where('report_task_id', $id)
34-
->with('subordinate')
34+
->with(['subordinate', 'sector'])
3535
->get();
3636
return ResponseFormatter::success($jobtask, 'Detail Laporan Pekerjaan', 200);
3737
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Admin;
4+
5+
use App\Http\Controllers\Controller;
6+
use App\Models\Sector;
7+
use Illuminate\Http\Request;
8+
9+
class SectorController extends Controller
10+
{
11+
public function getAllSector()
12+
{
13+
$sectors = Sector::all();
14+
return json_encode(['data' => $sectors]);
15+
}
16+
}

app/Models/JobtaskResult.php

+4
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,8 @@ public function subordinate()
2323
{
2424
return $this->belongsTo(User::class, 'subordinate', 'user_id');
2525
}
26+
27+
public function sector(){
28+
return $this->belongsTo(Sector::class, 'sector_id');
29+
}
2630
}

app/Models/Sector.php

+5
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,9 @@ public function news()
1919
{
2020
return $this->hasMany(News::class, 'news_id');
2121
}
22+
23+
public function jobtaskResult()
24+
{
25+
return $this->hasMany(JobtaskResult::class, 'job_task_id');
26+
}
2227
}

database/migrations/2022_07_10_155056_create_jobtask_results_table.php

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ public function up()
2323
$table->unsignedBigInteger('job_task_id')->nullable();
2424
$table->foreign('job_task_id')->references('job_task_id')->on('jobtasks')->onDelete('cascade');
2525

26+
$table->unsignedBigInteger('sector_id')->nullable();
27+
$table->foreign('sector_id')->references('sector_id')->on('sectors')->onDelete('cascade');
28+
2629
$table->unsignedBigInteger('subordinate');
2730
$table->foreign('subordinate')->references('user_id')->on('users');
2831

database/seeders/JobtaskResultSeeder.php

+10
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public function run()
2020
[
2121
[
2222
'report_task_id' => null,
23+
'sector_id' => null,
2324
'report_type' => 'Rutin',
2425
'job_task_id' => 1,
2526
'subordinate' => 3,
@@ -38,6 +39,7 @@ public function run()
3839
],
3940
[
4041
'report_task_id' => null,
42+
'sector_id' => null,
4143
'report_type' => 'Rutin',
4244
'job_task_id' => 1,
4345
'subordinate' => 4,
@@ -58,6 +60,7 @@ public function run()
5860

5961
[
6062
'report_task_id' => null,
63+
'sector_id' => null,
6164
'report_type' => 'Rutin',
6265
'job_task_id' => 2,
6366
'subordinate' => 3,
@@ -76,6 +79,7 @@ public function run()
7679
],
7780
[
7881
'report_task_id' => null,
82+
'sector_id' => null,
7983
'report_type' => 'Rutin',
8084
'job_task_id' => 2,
8185
'subordinate' => 4,
@@ -94,6 +98,7 @@ public function run()
9498
],
9599
[
96100
'report_task_id' => null,
101+
'sector_id' => null,
97102
'report_type' => 'Rutin',
98103
'job_task_id' => 2,
99104
'subordinate' => 4,
@@ -112,6 +117,7 @@ public function run()
112117
],
113118
[
114119
'report_task_id' => null,
120+
'sector_id' => null,
115121
'report_type' => 'Rutin',
116122
'job_task_id' => 3,
117123
'subordinate' => 3,
@@ -131,6 +137,7 @@ public function run()
131137

132138
[
133139
'report_task_id' => 1,
140+
'sector_id' => 5,
134141
'report_type' => 'Isidentil',
135142
'job_task_id' => null,
136143
'subordinate' => 3,
@@ -152,6 +159,7 @@ public function run()
152159

153160
[
154161
'report_task_id' => 1,
162+
'sector_id' => 5,
155163
'report_type' => 'Isidentil',
156164
'report_about' => 'Penangkapan Oknum Petugas Bandara Kasus Bobol Koper Penumpang',
157165
'report_source_information' => 'Aduan Masyarakat',
@@ -171,6 +179,7 @@ public function run()
171179

172180
[
173181
'report_task_id' => 3,
182+
'sector_id' => 4,
174183
'report_type' => 'Isidentil',
175184
'report_about' => 'Tawuran STM di gunung pasir',
176185
'report_source_information' => 'Aduan Masyarakat',
@@ -190,6 +199,7 @@ public function run()
190199

191200
[
192201
'report_task_id' => 2,
202+
'sector_id' => 8,
193203
'report_type' => 'Isidentil',
194204
'report_about' => 'Laka Lantas Tunggal',
195205
'report_source_information' => 'Aduan Masyarakat',

database/seeders/SectorSeeder.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ public function run()
2323
['sector_name' => 'Keamanan'],
2424
['sector_name' => 'Kriminal'],
2525
['sector_name' => 'Polri'],
26-
['sector_name' => 'Masyarakat']
26+
['sector_name' => 'Masyarakat'],
27+
['sector_name' => 'Laka Lantas']
2728
]
2829
);
2930
}

resources/views/report/index.blade.php

+6
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@
6565
<p id="report_subordinate"></p>
6666
</div>
6767

68+
<div class="mb-3">
69+
<label for="report_sector"> <b> Bidang Laporan </b> </label>
70+
<p id="report_sector"></p>
71+
</div>
72+
6873
<div class="mb-3">
6974
<label for="report_about"> <b> Perihal Laporan </b> </label>
7075
<p id="report_about"></p>
@@ -160,6 +165,7 @@
160165
$('#formViewReport').trigger('reset');
161166
162167
$('#report_subordinate').text(data.data[0].subordinate.name);
168+
$('#report_sector').text(data.data[0].sector.sector_name);
163169
$('#report_about').text(data.data[0].report_about);
164170
$('#report_source_information').text(data.data[0].report_source_information);
165171
$('#report_place').text(data.data[0].report_source_information);

routes/web.php

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
Route::get('getAllJobtask', [App\Http\Controllers\Admin\JobtaskController::class, 'getAllJobtask'])->name('getAllJobtask');
2626
Route::get('getAllNews', [App\Http\Controllers\Admin\NewsController::class, 'getAllNews'])->name('getAllNews');
2727
Route::get('getAllReport', [App\Http\Controllers\Admin\ReportController::class, 'getAllReport'])->name('getAllReport');
28+
Route::get('getAllSector', [App\Http\Controllers\Admin\SectorController::class, 'getAllSector'])->name('getAllSector');
2829

2930

3031

0 commit comments

Comments
 (0)