Skip to content

Commit

Permalink
Penambahan unduh dan lihat pada halaman unduhan dokumen website (#948)
Browse files Browse the repository at this point in the history
  • Loading branch information
arifpriadi authored Jun 14, 2024
1 parent 05b9360 commit f1379ba
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 18 deletions.
25 changes: 8 additions & 17 deletions app/Http/Controllers/FrontEnd/DownloadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
use App\Http\Controllers\FrontEndController;
use App\Models\Prosedur;
use App\Models\Regulasi;
use Illuminate\Support\Facades\DB;
use App\Models\FormDokumen;
use Yajra\DataTables\DataTables;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\Controller;

class DownloadController extends FrontEndController
{
Expand Down Expand Up @@ -118,28 +120,17 @@ public function indexFormDokumen()

public function getDataDokumen()
{
$query = DB::table('das_form_dokumen')->selectRaw('id, nama_dokumen, file_dokumen');

return DataTables::of($query->get())
return DataTables::of(FormDokumen::query())
->addColumn('aksi', function ($row) {
$data['download_url'] = asset($row->file_dokumen);
$data['show_url'] = asset($row->file_dokumen);
$data['download_url'] = route('unduhan.form-dokumen.download', $row->id);

return view('forms.aksi', $data);
})->make();
}

public function showDokumen($nama_dokumen)
{
$dokumen = dokumen::where('judul', str_replace('-', ' ', $nama_regulasi))->first();
$page_title = 'Detail Dokumen :'.$dokumen->judul;

return view('pages.unduhan.dokumen_show', compact('page_title', 'dokumen'));
}

public function downloadDokumen($file)
public function downloadDokumen(FormDokumen $file)
{
$getFile = Dokumen::where('judul', str_replace('-', ' ', $file))->firstOrFail();

return response()->download($getFile->file_dokumen);
return response()->download($file->file_dokumen);
}
}
1 change: 1 addition & 0 deletions catatan_rilis.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Di rilis versi v2406.1.0 di versi ini terdapat [untuk diisi] dan perbaikan lain

1. [#262](https://github.com/OpenSID/OpenDK/issues/262) Penambahan modul themes.
2. [#960](https://github.com/OpenSID/OpenDK/issues/960) Penambahan filter berdasarkan desa pada modul berkaitan dengan data desa.
3. [#962](https://github.com/OpenSID/OpenDK/issues/962) Penambahan unduh dan lihat pada halaman unduhan dokumen website.


#### BUG
Expand Down
2 changes: 1 addition & 1 deletion resources/views/forms/aksi.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</a>
@endif
@if (isset($show_url))
<a href="{!! empty($show_url) ? 'javascript:void(0)' : $show_url !!}" class="{!! empty($show_url) ? 'disabled' : '' !!}" title="Lihat" data-button="show">
<a href="{!! empty($show_url) ? 'javascript:void(0)' : $show_url !!}" class="{!! empty($show_url) ? 'disabled' : '' !!}" title="Lihat" data-button="show" target="_blank">
<button type="button" class="btn btn-warning btn-sm" style="width: 40px;"><i class="fa fa-eye fa-fw"></i></button>
</a>
@endif
Expand Down
1 change: 1 addition & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
Route::permanentRedirect('/', '/');
Route::get('/', 'DownloadController@indexFormDokumen')->name('unduhan.form-dokumen');
Route::get('getdata', 'DownloadController@getDataDokumen')->name('unduhan.form-dokumen.getdata');
Route::get('unduh/{file}', 'DownloadController@downloadDokumen')->name('unduhan.form-dokumen.download');
});
});

Expand Down

0 comments on commit f1379ba

Please sign in to comment.