Skip to content

Commit

Permalink
Merge pull request #16 from billalxcode/dev
Browse files Browse the repository at this point in the history
Fitur download template dan view maintenance mode
  • Loading branch information
billalxcode authored Nov 4, 2023
2 parents b02fd25 + f9363b6 commit 7b32d05
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 2 deletions.
19 changes: 18 additions & 1 deletion app/Http/Controllers/Operator/SiswaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
use App\Imports\SiswaImport;
use App\Models\Kehadiran;
use App\Models\Ruangan;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\Storage;
use Maatwebsite\Excel\Facades\Excel;

class SiswaController extends Controller
Expand Down Expand Up @@ -60,6 +62,21 @@ public function import(StoreImportSiswaRequest $storeImportSiswaRequest) {
return redirect()->back()->with('success', 'data berhasil disimpan');
}

/**
* Download and convert template
*/
public function convert(Request $request, $filetype) {
$filetype = Str::lower($filetype);
if (!Storage::exists('excel/MS.T-Master.xlsx')) {
return redirect()->back()->with('error', 'maaf file tidak ditemukan. silahkan lapor jika ini merupakan bug');
}
$storage = Storage::path('excel/MS.T-Master.xlsx');

if ($filetype == "xlsx") {
return response()->download($storage, Str::lower(config('app.name')) . '-template.xlsx');
}
}

/**
* Display the specified resource.
*/
Expand Down
37 changes: 37 additions & 0 deletions resources/views/errors/503.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!doctype html>
<html lang="en">

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>{{ config('app.name') ?? 'PintarNet' }}</title>
<!-- CSS files -->
<link href="{{ asset('assets/css/tabler.min.css?1684106062') }}" rel="stylesheet" />
<style>
@import url('https://rsms.me/inter/inter.css');
:root {
--tblr-font-sans-serif: 'Inter Var', -apple-system, BlinkMacSystemFont, San Francisco, Segoe UI, Roboto, Helvetica Neue, sans-serif;
}
body {
font-feature-settings: "cv03", "cv04", "cv11";
}
</style>
</head>

<body>
<div class="container h-100">
<div class="row h-100 justify-content-center align-items-center">
<div class="col-12">
<h1>503 Service Unavailable</h1>
<p>Saat ini layanan tidak tersedia, tunggu beberapa saat</p>
</div>
</div>
</div>
@stack('modals')
@stack('scripts')
</body>

</html>
2 changes: 1 addition & 1 deletion resources/views/layout/app.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>MasterApp</title>
<title>{{ config('app.name') ?? 'PintarNet' }}</title>
<!-- CSS files -->
<link href="{{ asset('assets/css/tabler.min.css?1684106062') }}" rel="stylesheet" />
<link href="{{ asset('assets/css/tabler-flags.min.css?1684106062') }}" rel="stylesheet" />
Expand Down
8 changes: 8 additions & 0 deletions resources/views/operator/siswa/home.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,14 @@ class="btn btn-info">Detail</a>
<a href="#" class="btn btn-link link-secondary" data-bs-dismiss="modal">
Cancel
</a>
<div class="dropdown ms-auto">
<a href="#" class="btn dropdown-toggle" data-bs-toggle="dropdown">Download</a>

<div class="dropdown-menu">
<a href="{{ route('operator.siswa.convert', 'xlsx') }}" class="dropdown-item">XLSX</a>
{{-- <a href="{{ route('operator.siswa.convert', 'xls') }}" class="dropdown-item">XLS</a> --}}
</div>
</div>
<a href="#" class="btn btn-primary ms-auto btn-save">
<!-- Download SVG icon from http://tabler-icons.io/i/plus -->
<svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24"
Expand Down
1 change: 1 addition & 0 deletions routes/role/operator.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
Route::group(['prefix' => 'siswa', 'as' => 'siswa.'], function () {
Route::get('', [SiswaController::class, 'index'])->name('home');
Route::get('{siswa_id}', [SiswaController::class, 'show'])->name('show');
Route::get('download/{filetype}', [SiswaController::class, 'convert'])->name('convert');
Route::post('store', [SiswaController::class, 'store'])->name('store');
Route::post('import', [SiswaController::class, 'import'])->name('import');
Route::delete('destroy/{siswaId}', [SiswaController::class, 'destroy'])->name('destroy');
Expand Down

0 comments on commit 7b32d05

Please sign in to comment.