Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Halaman Unduh dan Lihat Dokumen #948

Merged
merged 5 commits into from
Jun 14, 2024
Merged
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
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