From 1041ffc2d6917a6b65530bac4232de0ab7b1fd1c Mon Sep 17 00:00:00 2001 From: Andri Desmana Date: Sun, 17 Jul 2022 21:43:42 +0700 Subject: [PATCH] Tambah Akun Bank --- Modules/SPP/Entities/BankAccount.php | 7 +- .../Controllers/Backend/ProfileController.php | 4 +- .../Controllers/Backend/SettingController.php | 40 +++++ app/Models/Bank.php | 25 +++ app/Models/User.php | 10 ++ composer.json | 1 + composer.lock | 137 +++++++++++++- .../2021_08_08_100000_create_banks_tables.php | 39 ++++ database/seeders/IndoBankSeeder.php | 33 ++++ .../views/backend/settings/addBank.blade.php | 67 +++++++ .../views/backend/settings/index.blade.php | 167 ++++++++++++++++++ .../views/layouts/backend/header.blade.php | 8 +- routes/web.php | 11 +- 13 files changed, 534 insertions(+), 15 deletions(-) create mode 100644 app/Http/Controllers/Backend/SettingController.php create mode 100644 app/Models/Bank.php create mode 100644 database/migrations/2021_08_08_100000_create_banks_tables.php create mode 100644 database/seeders/IndoBankSeeder.php create mode 100644 resources/views/backend/settings/addBank.blade.php create mode 100644 resources/views/backend/settings/index.blade.php diff --git a/Modules/SPP/Entities/BankAccount.php b/Modules/SPP/Entities/BankAccount.php index aa040b2..c82c6a9 100644 --- a/Modules/SPP/Entities/BankAccount.php +++ b/Modules/SPP/Entities/BankAccount.php @@ -9,10 +9,5 @@ class BankAccount extends Model { use HasFactory; - protected $fillable = []; - - protected static function newFactory() - { - return \Modules\SPP\Database\factories\BankAccountFactory::new(); - } + protected $guarded = []; } diff --git a/app/Http/Controllers/Backend/ProfileController.php b/app/Http/Controllers/Backend/ProfileController.php index 62b0681..c94000e 100644 --- a/app/Http/Controllers/Backend/ProfileController.php +++ b/app/Http/Controllers/Backend/ProfileController.php @@ -9,7 +9,7 @@ use App\Http\Requests\ProfileSettingsRequest; use App\Http\Requests\ChangePasswordRequest; use ErrorException; -use Session; +use Illuminate\Support\Facades\Session; class ProfileController extends Controller { @@ -110,7 +110,7 @@ public function changePassword(ChangePasswordRequest $request, $id) $profile = User::find($id); $profile->password = bcrypt($request->password); $profile->save(); - + Session::flash('success','Password Berhasil diudate !'); return back(); diff --git a/app/Http/Controllers/Backend/SettingController.php b/app/Http/Controllers/Backend/SettingController.php new file mode 100644 index 0000000..a58b8ad --- /dev/null +++ b/app/Http/Controllers/Backend/SettingController.php @@ -0,0 +1,40 @@ + Auth::id(), + 'account_number' => $request->account_number, + 'account_name' => $request->account_name, + 'bank_name' => $request->bank_name, + 'is_active' => $request->is_active, + 'is_primary' => 1 + ]); + Session::flash('success','Akun Bank Berhasil Ditambah.'); + return back(); + } catch (\ErrorException $e) { + throw new ErrorException($e->getMessage()); + } + } +} diff --git a/app/Models/Bank.php b/app/Models/Bank.php new file mode 100644 index 0000000..ae31429 --- /dev/null +++ b/app/Models/Bank.php @@ -0,0 +1,25 @@ + + * + */ + +namespace App\Models; + +use Illuminate\Database\Eloquent\Model; + +/** + * Bank Model. + */ +class Bank extends Model +{ + /** + * Table name. + * + * @var string + */ + protected $table = 'banks'; +} \ No newline at end of file diff --git a/app/Models/User.php b/app/Models/User.php index bef1566..cc135d6 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -10,6 +10,7 @@ use Modules\Perpustakaan\Entities\Member; use Modules\PPDB\Entities\BerkasMurid; use Modules\PPDB\Entities\DataOrangTua; +use Modules\SPP\Entities\BankAccount; use Modules\SPP\Entities\PaymentSpp; use Spatie\Permission\Traits\HasRoles; @@ -80,4 +81,13 @@ public function payment() { return $this->hasOne(PaymentSpp::class,'user_id'); } + + public function bank() + { + return $this->hasOne(BankAccount::class,'user_id'); + } + public function banks() + { + return $this->hasMany(BankAccount::class,'user_id'); + } } diff --git a/composer.json b/composer.json index 06e6360..b0278ce 100644 --- a/composer.json +++ b/composer.json @@ -6,6 +6,7 @@ "license": "MIT", "require": { "php": "^7.3|^8.0", + "andes2912/indobank": "^0.7.0", "fruitcake/laravel-cors": "^2.0", "guzzlehttp/guzzle": "^7.0.1", "laravel/framework": "^8.75", diff --git a/composer.lock b/composer.lock index dce2887..8a00d64 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,77 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "91ee1bd4978c99ea984b35c1d703e2e8", + "content-hash": "0f631e7797bc710179d32d3105ce04f0", "packages": [ + { + "name": "andes2912/indobank", + "version": "0.7", + "source": { + "type": "git", + "url": "https://github.com/andes2912/indobank.git", + "reference": "9e45b91d3e770cd0e53cc626d35a3e03b5c713a9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/andes2912/indobank/zipball/9e45b91d3e770cd0e53cc626d35a3e03b5c713a9", + "reference": "9e45b91d3e770cd0e53cc626d35a3e03b5c713a9", + "shasum": "" + }, + "require": { + "parsecsv/php-parsecsv": "^1.1" + }, + "require-dev": { + "phpunit/phpunit": "4.8.*" + }, + "type": "liblary", + "extra": { + "laravel": { + "providers": [ + "Andes2912\\IndoBank\\IndoBankServiceProvider" + ], + "aliases": [] + } + }, + "autoload": { + "files": [ + "src/RawDataGetter.php" + ], + "psr-4": { + "Andes2912\\IndoBank\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Andri Desmana", + "email": "andridesmana29@gmail.com" + } + ], + "description": "List Bank of Indonesian", + "homepage": "https://andridesmana.pw/", + "keywords": [ + "Bank", + "csv", + "indonesia", + "laravel", + "nama bank", + "php" + ], + "support": { + "issues": "https://github.com/andes2912/indobank/issues", + "source": "https://github.com/andes2912/indobank/tree/0.7" + }, + "funding": [ + { + "url": "https://saweria.co/andes2912", + "type": "custom" + } + ], + "time": "2022-06-09T03:32:27+00:00" + }, { "name": "asm89/stack-cors", "version": "v2.1.1", @@ -1883,6 +1952,70 @@ }, "time": "2022-01-27T09:35:39+00:00" }, + { + "name": "parsecsv/php-parsecsv", + "version": "1.3.2", + "source": { + "type": "git", + "url": "https://github.com/parsecsv/parsecsv-for-php.git", + "reference": "2d6236cae09133e0533d34ed45ba1e1ecafffebb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/parsecsv/parsecsv-for-php/zipball/2d6236cae09133e0533d34ed45ba1e1ecafffebb", + "reference": "2d6236cae09133e0533d34ed45ba1e1ecafffebb", + "shasum": "" + }, + "require": { + "php": ">=5.5" + }, + "require-dev": { + "phpunit/phpunit": "^6", + "squizlabs/php_codesniffer": "^3.5" + }, + "suggest": { + "illuminate/support": "Fluent array interface for map functions" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "ParseCsv\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jim Myhrberg", + "email": "contact@jimeh.me" + }, + { + "name": "William Knauss", + "email": "will.knauss@gmail.com" + }, + { + "name": "Susann Sgorzaly", + "homepage": "https://github.com/susgo" + }, + { + "name": "Christian Bläul", + "homepage": "https://github.com/Fonata" + } + ], + "description": "CSV data parser for PHP", + "support": { + "issues": "https://github.com/parsecsv/parsecsv-for-php/issues", + "source": "https://github.com/parsecsv/parsecsv-for-php" + }, + "time": "2021-11-07T14:15:46+00:00" + }, { "name": "phpoption/phpoption", "version": "1.8.1", @@ -7753,5 +7886,5 @@ "php": "^7.3|^8.0" }, "platform-dev": [], - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.3.0" } diff --git a/database/migrations/2021_08_08_100000_create_banks_tables.php b/database/migrations/2021_08_08_100000_create_banks_tables.php new file mode 100644 index 0000000..7e21426 --- /dev/null +++ b/database/migrations/2021_08_08_100000_create_banks_tables.php @@ -0,0 +1,39 @@ + + * + */ + +use Illuminate\Support\Facades\Schema; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Database\Migrations\Migration; + +class CreateBanksTables extends Migration +{ + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('banks', function(Blueprint $table){ + $table->id(); + $table->string('sandi_bank',20); + $table->string('nama_bank'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('banks'); + } +} \ No newline at end of file diff --git a/database/seeders/IndoBankSeeder.php b/database/seeders/IndoBankSeeder.php new file mode 100644 index 0000000..6dcf0ad --- /dev/null +++ b/database/seeders/IndoBankSeeder.php @@ -0,0 +1,33 @@ + + * + */ + +namespace Database\Seeders; + +use Illuminate\Database\Seeder; +use Andes2912\IndoBank\RawDataGetter; +use Illuminate\Support\Facades\DB; + +class IndoBankSeeder extends Seeder +{ + /** + * Run the database seeds. + * + * @deprecated + * + * @return void + */ + public function run() + { + // Get Data + $banks = RawDataGetter::getBanks(); + + // Insert Data to Database + DB::table('banks')->insert($banks); + } +} \ No newline at end of file diff --git a/resources/views/backend/settings/addBank.blade.php b/resources/views/backend/settings/addBank.blade.php new file mode 100644 index 0000000..523b558 --- /dev/null +++ b/resources/views/backend/settings/addBank.blade.php @@ -0,0 +1,67 @@ +
+ + +
\ No newline at end of file diff --git a/resources/views/backend/settings/index.blade.php b/resources/views/backend/settings/index.blade.php new file mode 100644 index 0000000..02077bc --- /dev/null +++ b/resources/views/backend/settings/index.blade.php @@ -0,0 +1,167 @@ +@extends('layouts.backend.app') + +@section('title') + Settings +@endsection + +@section('content') + @if ($message = Session::get('success')) + + @elseif($message = Session::get('error')) + + @endif + + @if ($errors->any()) + + @endif +
+
+
+
+
+ +
+
+
+ +
+
+ +
+ +
+ + + +
+
+
+
+ +
+ @if (Auth::user()->bank == NULL) + +
+ @csrf +
+
+
+ + +
+
+
+
+ + +
+
+ +
+
+ + +
+
+
+
+ +
+
+ + +
+
+ + +
+
+
+
+
+ + Batal +
+
+
+ + @else + + @endif +
+ +
+
+
+
+ +
+
+ + @include('backend.settings.addBank') +
+
+@endsection \ No newline at end of file diff --git a/resources/views/layouts/backend/header.blade.php b/resources/views/layouts/backend/header.blade.php index 260025e..e47be3a 100644 --- a/resources/views/layouts/backend/header.blade.php +++ b/resources/views/layouts/backend/header.blade.php @@ -1,10 +1,10 @@