From 6958f8fd1aac83cbac01738b8df5d27968cbaa5b Mon Sep 17 00:00:00 2001 From: aspsptyd Date: Fri, 27 Oct 2023 23:16:59 +0700 Subject: [PATCH 1/9] Update README, update composer, tambah folder tests --- README.md | 21 ++++++++++++++++++++- composer.lock | 12 ++++++------ package-lock.json | 2 +- tests/CreatesApplication.php | 22 ++++++++++++++++++++++ tests/Feature/ExampleTest.php | 21 +++++++++++++++++++++ tests/TestCase.php | 10 ++++++++++ tests/Unit/ExampleTest.php | 18 ++++++++++++++++++ 7 files changed, 98 insertions(+), 8 deletions(-) create mode 100644 tests/CreatesApplication.php create mode 100644 tests/Feature/ExampleTest.php create mode 100644 tests/TestCase.php create mode 100644 tests/Unit/ExampleTest.php diff --git a/README.md b/README.md index 92fcb7a..267bdb3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,25 @@ ## Program Tagihan SPP Sekolah v1.1 Aplikasi untuk memaintain Tagihan Pembayaran Sekolah Berbasis Web Admin dengan Memanfaatkan Teknologi Laravel v9.x +### How to run it! + +```shell +# STEP 1 +$ git clone https://github.com/aspsptyd/program-tagihan-spp.git +# STEP 2 +$ cd program-tagihan-spp/ +# STEP 3 +$ composer update +# STEP 4 +$ composer install +# STEP 5 +$ cp .env.example .env +# STEP 6 +$ php artisan key:generate +# STEP 7 +$ php artisan serve +``` + ### Whats New! Update-update terbaru yang ditambahkan ke dalam proses development app yaitu sebagai berikut @@ -13,4 +32,4 @@ Installasi Update Feature -Soon \ No newline at end of file +_Soon_ \ No newline at end of file diff --git a/composer.lock b/composer.lock index 652a436..ffc97ae 100644 --- a/composer.lock +++ b/composer.lock @@ -1999,16 +1999,16 @@ }, { "name": "monolog/monolog", - "version": "2.9.1", + "version": "2.9.2", "source": { "type": "git", "url": "https://github.com/Seldaek/monolog.git", - "reference": "f259e2b15fb95494c83f52d3caad003bbf5ffaa1" + "reference": "437cb3628f4cf6042cc10ae97fc2b8472e48ca1f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/f259e2b15fb95494c83f52d3caad003bbf5ffaa1", - "reference": "f259e2b15fb95494c83f52d3caad003bbf5ffaa1", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/437cb3628f4cf6042cc10ae97fc2b8472e48ca1f", + "reference": "437cb3628f4cf6042cc10ae97fc2b8472e48ca1f", "shasum": "" }, "require": { @@ -2085,7 +2085,7 @@ ], "support": { "issues": "https://github.com/Seldaek/monolog/issues", - "source": "https://github.com/Seldaek/monolog/tree/2.9.1" + "source": "https://github.com/Seldaek/monolog/tree/2.9.2" }, "funding": [ { @@ -2097,7 +2097,7 @@ "type": "tidelift" } ], - "time": "2023-02-06T13:44:46+00:00" + "time": "2023-10-27T15:25:26+00:00" }, { "name": "nesbot/carbon", diff --git a/package-lock.json b/package-lock.json index 24de6ee..aa14193 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "tagihan-spp", + "name": "program-tagihan-spp", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/tests/CreatesApplication.php b/tests/CreatesApplication.php new file mode 100644 index 0000000..547152f --- /dev/null +++ b/tests/CreatesApplication.php @@ -0,0 +1,22 @@ +make(Kernel::class)->bootstrap(); + + return $app; + } +} diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php new file mode 100644 index 0000000..1eafba6 --- /dev/null +++ b/tests/Feature/ExampleTest.php @@ -0,0 +1,21 @@ +get('/'); + + $response->assertStatus(200); + } +} diff --git a/tests/TestCase.php b/tests/TestCase.php new file mode 100644 index 0000000..2932d4a --- /dev/null +++ b/tests/TestCase.php @@ -0,0 +1,10 @@ +assertTrue(true); + } +} From 8e8b10fe2dd9254994812218b30056f194206f94 Mon Sep 17 00:00:00 2001 From: aspsptyd Date: Fri, 27 Oct 2023 23:22:13 +0700 Subject: [PATCH 2/9] Update feature info in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 267bdb3..af0ddc9 100644 --- a/README.md +++ b/README.md @@ -32,4 +32,4 @@ Installasi Update Feature -_Soon_ \ No newline at end of file +- Integrasi Register & Login #2 \ No newline at end of file From e365189cd496c20663da5fb4e92225d9824d76f3 Mon Sep 17 00:00:00 2001 From: aspsptyd Date: Fri, 27 Oct 2023 23:27:28 +0700 Subject: [PATCH 3/9] Add middle ware php artisan make:middleware (Admin, Operator & Wali) --- app/Http/Middleware/Admin.php | 21 +++++++++++++++++++++ app/Http/Middleware/Operator.php | 21 +++++++++++++++++++++ app/Http/Middleware/Wali.php | 21 +++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 app/Http/Middleware/Admin.php create mode 100644 app/Http/Middleware/Operator.php create mode 100644 app/Http/Middleware/Wali.php diff --git a/app/Http/Middleware/Admin.php b/app/Http/Middleware/Admin.php new file mode 100644 index 0000000..ed4411f --- /dev/null +++ b/app/Http/Middleware/Admin.php @@ -0,0 +1,21 @@ + Date: Sat, 28 Oct 2023 00:16:44 +0700 Subject: [PATCH 4/9] Tambah middleware untuk php artisan make:middleware (Admin, Operator & Wali) --- app/Http/Middleware/Admin.php | 5 ++++- app/Http/Middleware/Operator.php | 5 ++++- app/Http/Middleware/Wali.php | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/Http/Middleware/Admin.php b/app/Http/Middleware/Admin.php index ed4411f..7f66dcf 100644 --- a/app/Http/Middleware/Admin.php +++ b/app/Http/Middleware/Admin.php @@ -16,6 +16,9 @@ class Admin */ public function handle(Request $request, Closure $next) { - return $next($request); + if ($request->user()->akses == 'admin') { + return $next($request); + } + abort(403, 'Akses khusus admin'); } } diff --git a/app/Http/Middleware/Operator.php b/app/Http/Middleware/Operator.php index e82e278..0334944 100644 --- a/app/Http/Middleware/Operator.php +++ b/app/Http/Middleware/Operator.php @@ -16,6 +16,9 @@ class Operator */ public function handle(Request $request, Closure $next) { - return $next($request); + if ($request->user()->akses == 'operator' || $request->user()->akses == 'admin' ) { + return $next($request); + } + abort(403, 'Akses khusus Operator'); } } diff --git a/app/Http/Middleware/Wali.php b/app/Http/Middleware/Wali.php index 9bc8eec..70bd735 100644 --- a/app/Http/Middleware/Wali.php +++ b/app/Http/Middleware/Wali.php @@ -16,6 +16,9 @@ class Wali */ public function handle(Request $request, Closure $next) { - return $next($request); + if ($request->user()->akses == 'wali') { + return $next($request); + } + abort(403, 'Akses khusus wali murid'); } } From 67c690dab3929ba4ffaddc53c47803a41178ea25 Mon Sep 17 00:00:00 2001 From: aspsptyd Date: Sat, 28 Oct 2023 00:17:14 +0700 Subject: [PATCH 5/9] Daftarkan router index Operator & Wali --- routes/web.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/routes/web.php b/routes/web.php index bf53cd0..c14795f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,5 +1,8 @@ name('home'); + +Route::prefix('operator')->middleware(['auth', 'auth.operator'])->group(function () { + //ini route khusus untuk operator + Route::get('beranda', [BerandaOperatorController::class, 'index'])->name('operator.beranda'); +}); + + +Route::prefix('wali')->middleware(['auth', 'auth.wali'])->group(function () { + //ini route khusus untuk wali-murid + Route::get('beranda', [BerandaWaliController::class, 'index'])->name('wali.beranda'); +}); + + +Route::prefix('admin')->middleware(['auth', 'auth.admin'])->group(function () { + //ini route khusus untuk admin +}); + +Route::get('logout', function () { + Auth::logout(); +}); From 42dca82906efe72840a7a3ee8f2c3028a2889396 Mon Sep 17 00:00:00 2001 From: aspsptyd Date: Sat, 28 Oct 2023 00:17:29 +0700 Subject: [PATCH 6/9] Daftarkan middleware --- app/Http/Controllers/Auth/LoginController.php | 14 ++++++++++++++ app/Http/Kernel.php | 3 +++ 2 files changed, 17 insertions(+) diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 18a0d08..f1ef83d 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -5,6 +5,7 @@ use App\Http\Controllers\Controller; use App\Providers\RouteServiceProvider; use Illuminate\Foundation\Auth\AuthenticatesUsers; +use Illuminate\Http\Request; class LoginController extends Controller { @@ -37,4 +38,17 @@ public function __construct() { $this->middleware('guest')->except('logout'); } + + public function authenticated(Request $request, $user) + { + if ($user->akses == 'operator' || $user->akses == 'admin') { + return redirect()->route('operator.beranda'); + } elseif ($user->akses == 'wali') { + return redirect()->route('wali.beranda'); + } else { + Auth::user()->logout(); + flash('Anda tidak memiliki hak akses')->error(); + return redirect()->route('login'); + } + } } diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 0079688..f475cfd 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -63,5 +63,8 @@ class Kernel extends HttpKernel 'signed' => \App\Http\Middleware\ValidateSignature::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, + 'auth.admin' => \App\Http\Middleware\Admin::class, + 'auth.wali' => \App\Http\Middleware\Wali::class, + 'auth.operator' => \App\Http\Middleware\Operator::class, ]; } From 16ebe3d75d3ecf9a4cfe8665c44a7699707913d7 Mon Sep 17 00:00:00 2001 From: aspsptyd Date: Sat, 28 Oct 2023 00:17:42 +0700 Subject: [PATCH 7/9] Fillable create new user --- app/Models/User.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Models/User.php b/app/Models/User.php index 23b4063..4a454bc 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -21,6 +21,9 @@ class User extends Authenticatable 'name', 'email', 'password', + 'akses', + 'nohp', + 'nohp_verified_at', ]; /** From 651704bb490058f42ae3cd570b2fe728a010062d Mon Sep 17 00:00:00 2001 From: aspsptyd Date: Sat, 28 Oct 2023 00:17:57 +0700 Subject: [PATCH 8/9] Buat controller dan layout untuk Operator & Wali --- .../Controllers/BerandaOperatorController.php | 13 +++++++++++ .../Controllers/BerandaWaliController.php | 13 +++++++++++ .../views/operator/beranda_index.blade.php | 23 +++++++++++++++++++ resources/views/wali/beranda_index.blade.php | 23 +++++++++++++++++++ 4 files changed, 72 insertions(+) create mode 100644 app/Http/Controllers/BerandaOperatorController.php create mode 100644 app/Http/Controllers/BerandaWaliController.php create mode 100644 resources/views/operator/beranda_index.blade.php create mode 100644 resources/views/wali/beranda_index.blade.php diff --git a/app/Http/Controllers/BerandaOperatorController.php b/app/Http/Controllers/BerandaOperatorController.php new file mode 100644 index 0000000..16373e8 --- /dev/null +++ b/app/Http/Controllers/BerandaOperatorController.php @@ -0,0 +1,13 @@ + +
+
+
+
Hi, Operator!
+ +
+ @if (session('status')) + + @endif + + {{ __('You are logged in!') }} +
+
+
+
+ +@endsection diff --git a/resources/views/wali/beranda_index.blade.php b/resources/views/wali/beranda_index.blade.php new file mode 100644 index 0000000..b487be9 --- /dev/null +++ b/resources/views/wali/beranda_index.blade.php @@ -0,0 +1,23 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+
Hi, Wali!
+ +
+ @if (session('status')) + + @endif + + {{ __('You are logged in!') }} +
+
+
+
+
+@endsection From 0aa433a9345053310c8749220adef7fb7518eb32 Mon Sep 17 00:00:00 2001 From: aspsptyd Date: Sun, 29 Oct 2023 00:31:51 +0700 Subject: [PATCH 9/9] Sesuaikan fungsi logout --- app/Http/Controllers/Auth/LoginController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index f1ef83d..1980213 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -6,6 +6,7 @@ use App\Providers\RouteServiceProvider; use Illuminate\Foundation\Auth\AuthenticatesUsers; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Auth; class LoginController extends Controller { @@ -46,7 +47,7 @@ public function authenticated(Request $request, $user) } elseif ($user->akses == 'wali') { return redirect()->route('wali.beranda'); } else { - Auth::user()->logout(); + Auth::logout(); flash('Anda tidak memiliki hak akses')->error(); return redirect()->route('login'); }