Skip to content

Commit

Permalink
Merge pull request #83 from andes2912/feature/spp
Browse files Browse the repository at this point in the history
Tambah Akun Bank
  • Loading branch information
andes2912 authored Jul 17, 2022
2 parents a66c1b6 + 1041ffc commit 72aa478
Show file tree
Hide file tree
Showing 13 changed files with 534 additions and 15 deletions.
7 changes: 1 addition & 6 deletions Modules/SPP/Entities/BankAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
}
4 changes: 2 additions & 2 deletions app/Http/Controllers/Backend/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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();

Expand Down
40 changes: 40 additions & 0 deletions app/Http/Controllers/Backend/SettingController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace App\Http\Controllers\Backend;

use App\Http\Controllers\Controller;
use App\Models\Bank;
use ErrorException;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Session;
use Modules\SPP\Entities\BankAccount;

class SettingController extends Controller
{
// setting
public function index()
{
$bank = Bank::all();
return view('backend.settings.index', compact('bank'));
}

// Tambah Bank
public function addBank(Request $request)
{
try {
BankAccount::create([
'user_id' => 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());
}
}
}
25 changes: 25 additions & 0 deletions app/Models/Bank.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

/*
* This file is part of the IndoBank package.
*
* (c) Andri Desmana <andridesmana.pw | andridesmana29@gmail.com>
*
*/

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
* Bank Model.
*/
class Bank extends Model
{
/**
* Table name.
*
* @var string
*/
protected $table = 'banks';
}
10 changes: 10 additions & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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');
}
}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
137 changes: 135 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions database/migrations/2021_08_08_100000_create_banks_tables.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

/*
* This file is part of the IndoBank package.
*
* (c) Andri Desmana <andridesmana.pw | andridesmana29@gmail.com>
*
*/

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');
}
}
33 changes: 33 additions & 0 deletions database/seeders/IndoBankSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/*
* This file is part of the IndoBank package.
*
* (c) Andri Desmana <andridesmana.pw | andridesmana29@gmail.com>
*
*/

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);
}
}
Loading

0 comments on commit 72aa478

Please sign in to comment.