Warna_SMART
This commit is contained in:
commit
9b857d704f
|
@ -0,0 +1,18 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.{yml,yaml}]
|
||||
indent_size = 2
|
||||
|
||||
[docker-compose.yml]
|
||||
indent_size = 4
|
|
@ -0,0 +1,53 @@
|
|||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=base64:1hWWCHAxccLrVyJglZNmV+LqQmBnEMCaWWrR4bFsEuQ=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
APP_FORCE_HTTPS=true
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_DEPRECATIONS_CHANNEL=null
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=warna_smart
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
FILESYSTEM_DRIVER=local
|
||||
QUEUE_CONNECTION=sync
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=smtp
|
||||
MAIL_HOST=smtp.gmail.com
|
||||
MAIL_USERNAME=farelramadhan1130@gmail.com
|
||||
MAIL_PASSWORD="cfwo gtzr wrbr xqlx"
|
||||
MAIL_PORT=587
|
||||
MAIL_ENCRYPTION=tls
|
||||
MAIL_FROM_ADDRESS="wahanaartaperdana@gmail.com"
|
||||
MAIL_FROM_NAME="KSP. Wahana Arta Perdana"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=auto
|
||||
AWS_BUCKET=cdn-progriva
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
PUSHER_APP_ID=
|
||||
PUSHER_APP_KEY=
|
||||
PUSHER_APP_SECRET=
|
||||
PUSHER_APP_CLUSTER=mt1
|
||||
|
||||
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
|
@ -0,0 +1,52 @@
|
|||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_DEPRECATIONS_CHANNEL=null
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=laravel
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
FILESYSTEM_DRIVER=local
|
||||
QUEUE_CONNECTION=sync
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=smtp
|
||||
MAIL_HOST=mailhog
|
||||
MAIL_PORT=1025
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
MAIL_FROM_ADDRESS=null
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
PUSHER_APP_ID=
|
||||
PUSHER_APP_KEY=
|
||||
PUSHER_APP_SECRET=
|
||||
PUSHER_APP_CLUSTER=mt1
|
||||
|
||||
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
|
@ -0,0 +1,8 @@
|
|||
RewriteEngine On
|
||||
RewriteCond %{HTTPS} off
|
||||
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
|
||||
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteRule ^(.*)$ public/$1 [L]
|
||||
</IfModule>
|
|
@ -0,0 +1,14 @@
|
|||
php:
|
||||
preset: laravel
|
||||
version: 8
|
||||
disabled:
|
||||
- no_unused_imports
|
||||
finder:
|
||||
not-name:
|
||||
- index.php
|
||||
- server.php
|
||||
js:
|
||||
finder:
|
||||
not-name:
|
||||
- webpack.mix.js
|
||||
css: true
|
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'name' => 'User'
|
||||
];
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\User\Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UserDatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
Model::unguard();
|
||||
|
||||
// $this->call("OthersTableSeeder");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,211 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\User\Http\Controllers;
|
||||
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use DataTables;
|
||||
use GuzzleHttp\Client;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use App\Models\Alternatif;
|
||||
|
||||
class NasabahController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
if ($request->ajax()) {
|
||||
$data = Alternatif::select('*');
|
||||
// Convert the Eloquent Collection to a regular PHP array
|
||||
$data->each(function ($item, $key) {
|
||||
$item->rowIndex = $key + 1;
|
||||
});
|
||||
|
||||
return Datatables::of($data)
|
||||
->addIndexColumn()
|
||||
->addColumn('title-post', function ($row) {
|
||||
$text = '
|
||||
<p class="mb-0">' . $row->nama_alternatif . '</p>
|
||||
';
|
||||
return $text;
|
||||
})
|
||||
->addColumn('kode', function ($row) {
|
||||
return $row->id_alternatif;
|
||||
})
|
||||
->rawColumns(['title-post', 'kode'])
|
||||
->filter(function ($query) use ($request) {
|
||||
if ($request->has('search')) {
|
||||
$search = $request->get('search')['value'];
|
||||
if (!empty($search)) {
|
||||
$query->where('nama_alternatif', 'LIKE', "%$search%");
|
||||
} else {
|
||||
$query->get();
|
||||
}
|
||||
}
|
||||
})
|
||||
->make(true);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'subtitle' => 'Nasabah',
|
||||
'button' => true,
|
||||
'module' => [
|
||||
'url' => route('nasabah.create'),
|
||||
'name' => 'Tambah Baru'
|
||||
]
|
||||
];
|
||||
|
||||
return view('user::nasabah.index', compact('data'));
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$kodeNasabah = $this->generateKodeNasabah();
|
||||
$data = [
|
||||
'subtitle' => 'Tambah baru',
|
||||
'kodeNasabah' => $kodeNasabah
|
||||
];
|
||||
|
||||
return view('user::nasabah.add', compact('data'));
|
||||
}
|
||||
|
||||
// Metode untuk menghasilkan kode nasabah
|
||||
private function generateKodeNasabah()
|
||||
{
|
||||
$lastNasabah = Alternatif::orderBy('id_alternatif', 'desc')->first();
|
||||
$lastNumber = $lastNasabah ? (int)substr($lastNasabah->id_alternatif, 3) : 0;
|
||||
$newNumber = $lastNumber + 1;
|
||||
return 'NSB' . str_pad($newNumber, 3, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
// 'id_alternatif' => 'required',
|
||||
'nama_alternatif' => 'required',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect()->back()->withInput()->with('error', 'Unexpected error, please try again. code: ' . $validator->errors()->first());
|
||||
}
|
||||
|
||||
// $input = $request->all();
|
||||
// $post = new Alternatif([
|
||||
// 'id_alternatif' => $input['id_alternatif'], // Membersihkan input judul menggunakan Purifier
|
||||
// 'nama_alternatif' => $input['nama_alternatif'], // Membersihkan input deskripsi menggunakan Purifier
|
||||
// 'uplink' => user()->id
|
||||
|
||||
$kodeNasabah = $this->generateKodeNasabah();
|
||||
$post = new Alternatif([
|
||||
'id_alternatif' => $kodeNasabah,
|
||||
'nama_alternatif' => $request->input('nama_alternatif'),
|
||||
'uplink' => user()->id
|
||||
]);
|
||||
|
||||
// $check = Alternatif::where('id_alternatif', $input['id_alternatif'])->count();
|
||||
// if ($check == 0) {
|
||||
// if ($post->save()) {
|
||||
// return redirect()->route('nasabah')->with('success', 'You have successfully added data');
|
||||
// } else {
|
||||
// return redirect()->route('nasabah')->with('error', 'An error occurred in the query');
|
||||
// }
|
||||
// } else {
|
||||
// return redirect()->route('nasabah')->with('error', 'Title already exists');
|
||||
// }
|
||||
$check = Alternatif::where('id_alternatif', $kodeNasabah)->count();
|
||||
if ($check == 0) {
|
||||
if ($post->save()) {
|
||||
return redirect()->route('nasabah')->with('success', 'You have successfully added data');
|
||||
} else {
|
||||
return redirect()->route('nasabah')->with('error', 'An error occurred in the query');
|
||||
}
|
||||
} else {
|
||||
return redirect()->route('nasabah')->with('error', 'Title already exists');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data = [
|
||||
'subtitle' => 'Edit: ' . Alternatif::where('id_alternatif', $id)->first()->title,
|
||||
];
|
||||
$alternatif = Alternatif::FindOrFail($id);
|
||||
|
||||
return view('user::nasabah.edit', compact('data', 'alternatif', 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
// Validasi input sebelum memperbarui data
|
||||
$validator = Validator::make($request->all(), [
|
||||
'id_alternatif' => 'required',
|
||||
'nama_alternatif' => 'required',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect()->back()->withInput()->with('error', 'Unexpected error, please try again. code: ' . $validator->errors()->first());
|
||||
}
|
||||
|
||||
// Cari data berdasarkan ID
|
||||
$alternatif = Alternatif::find($id);
|
||||
|
||||
// Jika data ditemukan
|
||||
if ($alternatif) {
|
||||
|
||||
// Update data dengan data baru dari form yang telah dibersihkan
|
||||
$alternatif->id_alternatif = $request->input('id_alternatif');
|
||||
$alternatif->nama_alternatif = $request->input('nama_alternatif');
|
||||
// Simpan perubahan pada database
|
||||
$alternatif->save();
|
||||
return redirect()->route('nasabah')->with('success', 'You are successfully added new records');
|
||||
} else {
|
||||
return redirect()->route('nasabah')->with('error', 'Unexpected error');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
// Cari data berdasarkan ID
|
||||
$post = Alternatif::find($id);
|
||||
// Jika data ditemukan
|
||||
if ($post) {
|
||||
// Hapus data dari database
|
||||
$post->delete();
|
||||
return redirect()->route('nasabah')->with('success', 'You are successfully deleted records');
|
||||
} else {
|
||||
return redirect()->route('nasabah')->with('error', 'Data not found');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,237 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\User\Http\Controllers;
|
||||
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
use DataTables;
|
||||
use GuzzleHttp\Client;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use App\Models\Nilai;
|
||||
use App\Models\Kriteria;
|
||||
use App\Models\Subkriteria;
|
||||
use App\Models\Alternatif;
|
||||
|
||||
class NilaiController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
|
||||
if ($request->ajax()) {
|
||||
$data = Nilai::select('*');
|
||||
// Convert the Eloquent Collection to a regular PHP array
|
||||
$data->each(function ($item, $key) {
|
||||
$item->rowIndex = $key + 1;
|
||||
});
|
||||
|
||||
return Datatables::of($data)
|
||||
->addIndexColumn()
|
||||
->addColumn('nama', function ($row) {
|
||||
if ($row->nasabah) {
|
||||
return $row->alternatif_kode . ' - ' . $row->nasabah->nama_alternatif;
|
||||
} else {
|
||||
return 'Nasabah tidak ditemukan';
|
||||
}
|
||||
})
|
||||
->addColumn('kriteria', function ($row) {
|
||||
if ($row->kriteria) {
|
||||
return $row->kriteria_kode . ' - ' . $row->kriteria->nama_kriteria;
|
||||
} else {
|
||||
return 'Kriteria tidak ditemukan';
|
||||
}
|
||||
})
|
||||
->rawColumns(['nama', 'kriteria'])
|
||||
->filter(function ($query) use ($request) {
|
||||
if ($request->has('search')) {
|
||||
$search = $request->get('search')['value'];
|
||||
if (!empty($search)) {
|
||||
$nasabah = Alternatif::where('nama_alternatif', 'LIKE', '%' . $search . '%')->first();
|
||||
if ($nasabah) {
|
||||
$query->where('alternatif_kode', $nasabah->id_alternatif);
|
||||
} else {
|
||||
// If no nasabah found, return an empty result
|
||||
$query->where('alternatif_kode', '!=', null); // Change this to a condition that always fails
|
||||
}
|
||||
} else {
|
||||
$query->get();
|
||||
}
|
||||
}
|
||||
})
|
||||
->make(true);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'subtitle' => 'Nilai',
|
||||
'button' => true,
|
||||
'module' => [
|
||||
'url' => route('nilai.create'),
|
||||
'name' => 'Tambah Baru'
|
||||
]
|
||||
];
|
||||
|
||||
return view('user::nilai.index', compact('data'));
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$data = [
|
||||
'subtitle' => 'Tambah baru',
|
||||
];
|
||||
|
||||
$bobot = Nilai::all();
|
||||
$alternatif = Alternatif::all();
|
||||
$kriteria = Kriteria::all();
|
||||
$subkriteria = Subkriteria::all();
|
||||
|
||||
return view('user::nilai.add', compact('data', 'bobot', 'alternatif', 'kriteria', 'subkriteria'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'alternatif_kode' => 'required',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect()->back()->withInput()->with('error', 'Unexpected error, please try again. code: ' . $validator->errors()->first());
|
||||
}
|
||||
|
||||
if (empty($request->input('kriteria_kode'))) {
|
||||
return redirect()->back()->withInput()->with('error', 'Unexpected error, please try again. code: Kriteria Kode');
|
||||
}
|
||||
|
||||
if (empty($request->input('nilaiFaktor'))) {
|
||||
return redirect()->back()->withInput()->with('error', 'Unexpected error, please try again. code: Nilai Faktor');
|
||||
}
|
||||
|
||||
$input = $request->all();
|
||||
$countDataPost = count($_POST['kriteria_kode']);
|
||||
$data = [];
|
||||
|
||||
for ($i = 0; $i < $countDataPost; $i++) {
|
||||
$data[] = [
|
||||
'alternatif_kode' => $_POST['alternatif_kode'],
|
||||
'kriteria_kode' => $_POST['kriteria_kode'][$i],
|
||||
'nilai_faktor' => $_POST['nilaiFaktor'][$i],
|
||||
];
|
||||
}
|
||||
|
||||
$check = Nilai::where('alternatif_kode', '=', $request->input('alternatif_kode'))->first();
|
||||
if (!$check) {
|
||||
$insert = DB::table('tbl_nilai')->insert($data);
|
||||
if ($insert) {
|
||||
return redirect()->route('nilai')->with('success', 'You are successfully added records');
|
||||
} else {
|
||||
return redirect()->back()->withInput()->with('error', 'Unexpected error, please try again');
|
||||
}
|
||||
} else {
|
||||
return redirect()->back()->withInput()->with('error', 'Data sudah ada');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data = [
|
||||
'subtitle' => 'Edit: ' . Nilai::where('id', $id)->first()->title,
|
||||
];
|
||||
|
||||
$nilai = Nilai::find($id);
|
||||
$kriteria = Kriteria::all();
|
||||
$subkriteria = Subkriteria::all();
|
||||
return view('user::nilai.edit', compact('data', 'id', 'nilai', 'kriteria', 'subkriteria'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request)
|
||||
{
|
||||
// Validasi input sebelum memperbarui data
|
||||
$validator = Validator::make($request->all(), [
|
||||
'nilaiId' => 'required',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect()->back()->withInput()->with('error', 'Unexpected error, please try again. code: ' . $validator->errors()->first());
|
||||
}
|
||||
|
||||
$nilaiId = $_POST['nilaiId'];
|
||||
$altKode = $_POST['altKode'];
|
||||
$kriKode = $_POST['kriKode'];
|
||||
$nilaiFaktor = $_POST['nilaiFaktor'];
|
||||
|
||||
// print_r($_POST); die();
|
||||
|
||||
$updateBanyak = count($nilaiId);
|
||||
$jml = 0;
|
||||
// $error_data = [];
|
||||
for ($x = 0; $x < $updateBanyak; $x++) {
|
||||
$query = DB::table('tbl_nilai')->where('id', $nilaiId[$x])->update([
|
||||
'alternatif_kode' => $altKode[$x],
|
||||
'kriteria_kode' => $kriKode[$x],
|
||||
'nilai_faktor' => $nilaiFaktor[$x],
|
||||
]);
|
||||
if ($query) {
|
||||
$jml++;
|
||||
} else {
|
||||
// $error_data[] = $nilaiId[$x];
|
||||
// return redirect()->back()->withInput()->with('error', 'Terjadi error pada menyimpan data');
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->route('nilai')->with('success', 'You are successfully modified records. record updated: '.$jml.' records');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
// Cari data berdasarkan ID
|
||||
$post = Nilai::where('alternatif_kode', "$id");
|
||||
// Jika data ditemukan
|
||||
if ($post) {
|
||||
// Hapus data dari database
|
||||
$post->delete();
|
||||
return redirect()->route('nilai')->with('success', 'You are successfully deleted records');
|
||||
} else {
|
||||
return redirect()->route('nilai')->with('error', 'Data not found');
|
||||
}
|
||||
}
|
||||
|
||||
public function ranking()
|
||||
{
|
||||
$data = [
|
||||
'subtitle' => 'Ranking',
|
||||
];
|
||||
|
||||
return view('user::nilai.ranking', compact('data'));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\User\Http\Controllers;
|
||||
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use DataTables;
|
||||
use GuzzleHttp\Client;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use App\Models\Alternatif;
|
||||
use App\Models\PengajuanNasabah;
|
||||
use App\Models\Nilai;
|
||||
|
||||
class PengajuanController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
if ($request->ajax()) {
|
||||
$data = PengajuanNasabah::select('*');
|
||||
// Convert the Eloquent Collection to a regular PHP array
|
||||
$data->each(function ($item, $key) {
|
||||
$item->rowIndex = $key + 1;
|
||||
});
|
||||
|
||||
return Datatables::of($data)
|
||||
->addIndexColumn()
|
||||
->addColumn('nasabah', function($row){
|
||||
return $row->nasabah->nama_alternatif;
|
||||
})
|
||||
->addColumn('uplink', function($row){
|
||||
return 'aa';
|
||||
})
|
||||
->addColumn('status_pengajuan', function($row){
|
||||
if ($row->status == 1) {
|
||||
return '<span class="mb-1 badge font-medium badge-success py-2 px-3 fs-7">Diterima</span>';
|
||||
} elseif($row->status == 0) {
|
||||
return '<span class="mb-1 badge font-medium badge-primary py-2 px-3 fs-7">Menunggu Respon</span>';
|
||||
} else {
|
||||
return '<span class="mb-1 badge font-medium badge-danger py-2 px-3 fs-7">Tidak diterima</span>';
|
||||
}
|
||||
})
|
||||
->rawColumns(['nasabah', 'uplink', 'status_pengajuan'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'subtitle' => 'Pengajuan Nasabah'
|
||||
];
|
||||
|
||||
return view('admin.app.content.pengajuan.index', compact('data'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function add(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'nasabah_kode' => 'required',
|
||||
'hasil_preferensi' => 'required',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect()->route('pengajuan')->withInput()->with('error', 'Unexpected error, please try again. code: ' . $validator->errors()->first());
|
||||
}
|
||||
|
||||
$input = $request->all();
|
||||
|
||||
$post = new PengajuanNasabah([
|
||||
'id_nasabah' => $input['nasabah_kode'], // Membersihkan input judul menggunakan Purifier
|
||||
'skor' => $input['hasil_preferensi'], // Membersihkan input deskripsi menggunakan Purifier
|
||||
'uplink' => user()->id,
|
||||
'status' => 0,
|
||||
]);
|
||||
|
||||
$check = PengajuanNasabah::where('id_nasabah', $input['nasabah_kode'])->where('skor', $input['hasil_preferensi'])->count();
|
||||
if ($check == 0) {
|
||||
if ($post->save()) {
|
||||
return redirect()->route('nasabah')->with('success', 'You have successfully added data');
|
||||
} else {
|
||||
return redirect()->route('nasabah')->with('error', 'An error occurred in the query');
|
||||
}
|
||||
} else {
|
||||
return redirect()->route('nasabah')->with('error', 'Title already exists');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\User\Http\Controllers;
|
||||
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use App\Models\PengajuanNasabah;
|
||||
use App\Models\Alternatif;
|
||||
use App\Models\User;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$data = [
|
||||
'subtitle' => 'Diagnosa',
|
||||
];
|
||||
|
||||
$totalPengajuan = PengajuanNasabah::where('uplink', user()->id)->count();
|
||||
$totalPengajuanDiterima = PengajuanNasabah::where('uplink', user()->id)->where('status', 1)->count();
|
||||
$totalPengajuanDitolak = PengajuanNasabah::where('uplink', user()->id)->where('status', 2)->count();
|
||||
$totalNasabah = Alternatif::where('uplink', user()->id)->count();
|
||||
|
||||
return view('user::index', compact('data', 'totalPengajuan', 'totalPengajuanDiterima', 'totalPengajuanDitolak', 'totalNasabah'));
|
||||
}
|
||||
|
||||
public function profile()
|
||||
{
|
||||
$data = [
|
||||
'subtitle' => 'Akun anda',
|
||||
];
|
||||
|
||||
return view('user::setting', compact('data'));
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
$id = user()->id;
|
||||
$validator = Validator::make($request->all(), [
|
||||
'name' => 'required',
|
||||
'email' => 'required',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect()->back()->with('error', $validator->errors()->first())->withInput();
|
||||
}
|
||||
|
||||
$input = $request->all();
|
||||
$findUser = User::find($id);
|
||||
|
||||
if($findUser) {
|
||||
// update data
|
||||
$findUser->name = $input['name'];
|
||||
$findUser->email = $input['email'];
|
||||
if(!empty($input['password'])) {
|
||||
$findUser->password = bcrypt($input['password']);
|
||||
}
|
||||
|
||||
// save data
|
||||
$findUser->save();
|
||||
return redirect()->back()->with('success', 'Data berhasil disimpan');
|
||||
} else {
|
||||
return redirect()->back()->with('error', 'Tidak ditemukan data!');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\User\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The module namespace to assume when generating URLs to actions.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $moduleNamespace = 'Modules\User\Http\Controllers';
|
||||
|
||||
/**
|
||||
* Called before routes are registered.
|
||||
*
|
||||
* Register any model bindings or pattern based filters.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
parent::boot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function map()
|
||||
{
|
||||
$this->mapApiRoutes();
|
||||
|
||||
$this->mapWebRoutes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "web" routes for the application.
|
||||
*
|
||||
* These routes all receive session state, CSRF protection, etc.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapWebRoutes()
|
||||
{
|
||||
Route::middleware('web')
|
||||
->namespace($this->moduleNamespace)
|
||||
->group(module_path('User', '/Routes/web.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "api" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapApiRoutes()
|
||||
{
|
||||
Route::prefix('api')
|
||||
->middleware('api')
|
||||
->namespace($this->moduleNamespace)
|
||||
->group(module_path('User', '/Routes/api.php'));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\User\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Database\Eloquent\Factory;
|
||||
|
||||
class UserServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* @var string $moduleName
|
||||
*/
|
||||
protected $moduleName = 'User';
|
||||
|
||||
/**
|
||||
* @var string $moduleNameLower
|
||||
*/
|
||||
protected $moduleNameLower = 'user';
|
||||
|
||||
/**
|
||||
* Boot the application events.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->registerTranslations();
|
||||
$this->registerConfig();
|
||||
$this->registerViews();
|
||||
$this->loadMigrationsFrom(module_path($this->moduleName, 'Database/Migrations'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->register(RouteServiceProvider::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register config.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerConfig()
|
||||
{
|
||||
$this->publishes([
|
||||
module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'),
|
||||
], 'config');
|
||||
$this->mergeConfigFrom(
|
||||
module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register views.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function registerViews()
|
||||
{
|
||||
$viewPath = resource_path('views/modules/' . $this->moduleNameLower);
|
||||
|
||||
$sourcePath = module_path($this->moduleName, 'Resources/views');
|
||||
|
||||
$this->publishes([
|
||||
$sourcePath => $viewPath
|
||||
], ['views', $this->moduleNameLower . '-module-views']);
|
||||
|
||||
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register translations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function registerTranslations()
|
||||
{
|
||||
$langPath = resource_path('lang/modules/' . $this->moduleNameLower);
|
||||
|
||||
if (is_dir($langPath)) {
|
||||
$this->loadTranslationsFrom($langPath, $this->moduleNameLower);
|
||||
} else {
|
||||
$this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provides()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
private function getPublishableViewPaths(): array
|
||||
{
|
||||
$paths = [];
|
||||
foreach (\Config::get('view.paths') as $path) {
|
||||
if (is_dir($path . '/modules/' . $this->moduleNameLower)) {
|
||||
$paths[] = $path . '/modules/' . $this->moduleNameLower;
|
||||
}
|
||||
}
|
||||
return $paths;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,132 @@
|
|||
@include('components.theme.pages.header')
|
||||
<section>
|
||||
<div class="row mb-4">
|
||||
<div class="col-md-4 mb-2">
|
||||
<div class="card border-left-primary shadow py-2">
|
||||
<div class="card-body">
|
||||
<div class="row no-gutters align-items-center">
|
||||
<div class="col mr-2">
|
||||
<div class="text-xs font-weight-bold text-primary text-uppercase mb-1">
|
||||
Total Pengajuan Diterima</div>
|
||||
<div class="h5 mb-0 font-weight-bold text-gray-800">{{ $totalPengajuanDiterima }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 mb-2">
|
||||
<div class="card border-left-primary shadow py-2">
|
||||
<div class="card-body">
|
||||
<div class="row no-gutters align-items-center">
|
||||
<div class="col mr-2">
|
||||
<div class="text-xs font-weight-bold text-primary text-uppercase mb-1">
|
||||
Total Pengajuan Ditolak</div>
|
||||
<div class="h5 mb-0 font-weight-bold text-gray-800">{{ $totalPengajuanDitolak }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 mb-2">
|
||||
<div class="card border-left-primary shadow py-2">
|
||||
<div class="card-body">
|
||||
<div class="row no-gutters align-items-center">
|
||||
<div class="col mr-2">
|
||||
<div class="text-xs font-weight-bold text-primary text-uppercase mb-1">
|
||||
Total Nasabah</div>
|
||||
<div class="h5 mb-0 font-weight-bold text-gray-800">{{ $totalNasabah }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12 mt-4">
|
||||
<div class="card shadow">
|
||||
<div class="card-header d-flex align-items-center">
|
||||
<h6 class="m-0 text-primary">Tentang Layanan</h6>
|
||||
<span class="ml-auto">{{ date('j F Y, H:i:s') }}</span>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h5>Layanan Uji Kelayakan Pemberian Pinjaman Calon Nasabah KSP. Wahana Arta Perdana</h5>
|
||||
<p>Pada website ini, pengguna dapat melakukan penilaian menggunakan skoring untuk menentukan calon
|
||||
nasabah yang memenuhi kriteria dan dapat diproses untuk pengajuan pinjaman. Untuk memudahkan
|
||||
proses penilaian, sistem kami memiliki pembobotan nilai menggunakan tabel tingkat kepentingan
|
||||
yang telah ditentukan sebagai berikut:</p>
|
||||
<table class="table table-bordered text-center ">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>No</th>
|
||||
<th>Tingkat Kepentingan</th>
|
||||
<th>Nilai</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td>Tidak Prioritas</td>
|
||||
<td>1</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>2</td>
|
||||
<td>Kurang Prioritas</td>
|
||||
<td>2</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>3</td>
|
||||
<td>Cukup Prioritas</td>
|
||||
<td>3</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>4</td>
|
||||
<td>Prioritas</td>
|
||||
<td>4</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>5</td>
|
||||
<td>Sangat Prioritas</td>
|
||||
<td>5</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12 mt-4">
|
||||
<div class="card shadow">
|
||||
<div class="card-header d-flex align-items-center">
|
||||
<h6 class="m-0 text-primary">Tentang Info Kelayakan</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table" id="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Judul</th>
|
||||
<th>Link URL</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (\App\Models\Pages::all() as $items)
|
||||
<tr>
|
||||
<td>{{ $items->title }}</td>
|
||||
<td><a href="{{ $items->description }}"
|
||||
noreferrerpolicy="no-referrer">tonton</a></td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@push('scripts')
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
var table = $('#data-table').DataTable();
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
@include('components.theme.pages.footer')
|
|
@ -0,0 +1,48 @@
|
|||
@include('components.theme.pages.header')
|
||||
|
||||
<section>
|
||||
<!-- basic table -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
{{ Form::open(['route' => 'nasabah.store']) }}
|
||||
@csrf
|
||||
@if(session()->has('success'))
|
||||
<div class="alert alert-success">
|
||||
{{ session()->get('success') }}
|
||||
</div>
|
||||
@else
|
||||
@if(session()->has('error'))
|
||||
<div class="alert alert-danger">
|
||||
{{ session()->get('error') }}
|
||||
</div>
|
||||
@endif
|
||||
@endif
|
||||
<div class="form-group mb-3">
|
||||
<label for="exampleEmail1">Nama Nasabah</label>
|
||||
<input type="text" class="form-control form-control-user {{ $errors->has('nama_alternatif') ? 'is-invalid' : '' }}" id="email" name="nama_alternatif" aria-describedby="emailHelp" placeholder="Enter Nama Nasabah." value="<?= old('nama_alternatif') ?>">
|
||||
@if($errors->has('nama_alternatif'))<span class="small text-danger mt-2">{{ $errors->first('nama_alternatif') }}</span>@endif
|
||||
</div>
|
||||
{{-- <div class="form-group mb-3">
|
||||
<label for="exampleEmail1">Kode Nasabah</label>
|
||||
<input type="text" class="form-control form-control-user {{ $errors->has('id_alternatif') ? 'is-invalid' : '' }}" id="email" name="id_alternatif" aria-describedby="emailHelp" placeholder="Enter Kode Nasabah." value="<?= old('id_alternatif') ?>">
|
||||
@if($errors->has('id_alternatif'))<span class="small text-danger mt-2">{{ $errors->first('id_alternatif') }}</span>@endif
|
||||
</div> --}}
|
||||
<div class="form-group mb-3">
|
||||
<label for="exampleEmail1">Kode Nasabah</label>
|
||||
<input type="text" class="form-control form-control-user {{ $errors->has('id_alternatif') ? 'is-invalid' : '' }}" id="email" name="id_alternatif" aria-describedby="emailHelp" placeholder="Kode Nasabah" value="{{ old('id_alternatif', $data['kodeNasabah'] ?? '') }}" readonly>
|
||||
@if($errors->has('id_alternatif'))<span class="small text-danger mt-2">{{ $errors->first('id_alternatif') }}</span>@endif
|
||||
</div>
|
||||
<div class="form-group mb-0">
|
||||
<button type="submit" class="btn btn-primary">Simpan</button>
|
||||
<a href="{{ route('nasabah') }}" class="btn btn-light btn-light">Kembali</a>
|
||||
</div>
|
||||
{{ Form::close() }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@include('components.theme.pages.footer')
|
|
@ -0,0 +1,43 @@
|
|||
@include('components.theme.pages.header')
|
||||
|
||||
<section>
|
||||
<!-- basic table -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
{{ Form::open(['route' => ['nasabah.update', 'id' => $id], 'id' => 'form-tag-update']) }}
|
||||
@csrf
|
||||
@if(session()->has('success'))
|
||||
<div class="alert alert-success">
|
||||
{{ session()->get('success') }}
|
||||
</div>
|
||||
@else
|
||||
@if(session()->has('error'))
|
||||
<div class="alert alert-danger">
|
||||
{{ session()->get('error') }}
|
||||
</div>
|
||||
@endif
|
||||
@endif
|
||||
<div class="form-group mb-3">
|
||||
<label for="exampleEmail1">Nama Nasabah</label>
|
||||
<input type="text" class="form-control form-control-user {{ $errors->has('nama_alternatif') ? 'is-invalid' : '' }}" id="email" name="nama_alternatif" aria-describedby="emailHelp" placeholder="Enter Nama Nasabah." value="{{ $alternatif->nama_alternatif }}">
|
||||
@if($errors->has('nama_alternatif'))<span class="small text-danger mt-2">{{ $errors->first('nama_alternatif') }}</span>@endif
|
||||
</div>
|
||||
<div class="form-group mb-3">
|
||||
<label for="exampleEmail1">Kode Nasabah</label>
|
||||
<input type="text" class="form-control form-control-user {{ $errors->has('id_alternatif') ? 'is-invalid' : '' }}" id="email" name="id_alternatif" aria-describedby="emailHelp" placeholder="Enter Kode Nasabah." value="{{ $alternatif->id_alternatif }}" readonly>
|
||||
@if($errors->has('id_alternatif'))<span class="small text-danger mt-2">{{ $errors->first('id_alternatif') }}</span>@endif
|
||||
</div>
|
||||
<div class="form-group mb-0">
|
||||
<button type="submit" class="btn btn-primary">Simpan</button>
|
||||
<a href="{{ route('nasabah') }}" class="btn btn-light btn-light">Kembali</a>
|
||||
</div>
|
||||
{{ Form::close() }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@include('components.theme.pages.footer')
|
|
@ -0,0 +1,115 @@
|
|||
@include('components.theme.pages.header')
|
||||
<section>
|
||||
<!-- basic table -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
|
||||
<div class="d-flex mb-4">
|
||||
<h1 class="h3 text-gray-800">{{ $data['subtitle'] }}</h1>
|
||||
@if (!empty($data['button']))
|
||||
<!--begin::Action-->
|
||||
<div class="ml-auto">
|
||||
@php
|
||||
$url = $data['module']['url'];
|
||||
@endphp
|
||||
<a href="{{ $data['module']['url'] }}" class="btn btn-primary">
|
||||
{{ explode(' ', $data['module']['name'])[0] }} <span
|
||||
class="d-none d-sm-inline ps-2">{{ ucfirst(explode(' ', $data['module']['name'])[1]) }}</span>
|
||||
</a>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
@if (session()->has('success'))
|
||||
<div class="alert alert-success">
|
||||
{{ session()->get('success') }}
|
||||
</div>
|
||||
@else
|
||||
@if (session()->has('error'))
|
||||
<div class="alert alert-danger">
|
||||
{{ session()->get('error') }}
|
||||
</div>
|
||||
@endif
|
||||
@endif
|
||||
<!--end::Wrapper-->
|
||||
<div class="table-responsive">
|
||||
<table id="data-table" class="table" width="100%">
|
||||
<thead>
|
||||
<tr class="text-start">
|
||||
<th>ID</th>
|
||||
<th>Nama Nasabah</th>
|
||||
<th>Kode Nasabah</th>
|
||||
<th>Tanggal</th>
|
||||
<th>Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@push('scripts')
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
|
||||
var table = $('#data-table').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: "{{ route('nasabah') }}",
|
||||
columns: [{
|
||||
data: null,
|
||||
name: 'id_alternatif'
|
||||
},
|
||||
{
|
||||
data: 'title-post',
|
||||
name: 'title-post'
|
||||
},
|
||||
{
|
||||
data: 'kode',
|
||||
name: 'kode'
|
||||
},
|
||||
{
|
||||
data: 'created_at',
|
||||
name: 'created_at'
|
||||
},
|
||||
{
|
||||
data: null,
|
||||
name: 'action',
|
||||
orderable: false,
|
||||
searchable: false
|
||||
},
|
||||
],
|
||||
columnDefs: [{
|
||||
targets: -1,
|
||||
data: null,
|
||||
orderable: false,
|
||||
render: function(data, type, row) {
|
||||
return `
|
||||
<button class="btn btn-secondary btn-sm dropdown-toggle" type="button"
|
||||
id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true"
|
||||
aria-expanded="false">
|
||||
Aksi
|
||||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
<a class="dropdown-item" href="{{ site_url('user', 'nasabah') . '/edit' }}/${row.id_alternatif}">Edit</a>
|
||||
<a class="dropdown-item" href="{{ site_url('user', 'nasabah') . '/delete' }}/${row.id_alternatif}">Hapus</a>
|
||||
</div>
|
||||
`;
|
||||
},
|
||||
}],
|
||||
createdRow: function(row, data, dataIndex) {
|
||||
// Set the sequential number starting from 1
|
||||
$('td', row).eq(0).html(dataIndex + 1);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
@include('components.theme.pages.footer')
|
|
@ -0,0 +1,62 @@
|
|||
@include('components.theme.pages.header')
|
||||
|
||||
<section>
|
||||
<!-- basic table -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
{{ Form::open(['route' => 'nilai.store']) }}
|
||||
@csrf
|
||||
@if(session()->has('success'))
|
||||
<div class="alert alert-success">
|
||||
{{ session()->get('success') }}
|
||||
</div>
|
||||
@else
|
||||
@if(session()->has('error'))
|
||||
<div class="alert alert-danger">
|
||||
{{ session()->get('error') }}
|
||||
</div>
|
||||
@endif
|
||||
@endif
|
||||
<div class="form-group mb-3">
|
||||
<label for="exampleEmail1">Nasabah</label>
|
||||
<select class="form-control" name="alternatif_kode">
|
||||
<option value="">Pilih Nasabah...</option>
|
||||
@foreach($alternatif as $alt)
|
||||
<option value="{{ $alt->id_alternatif }}">{{ $alt->id_alternatif }} - {{ $alt->nama_alternatif }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="col text-center">Isi Nilai Faktor Dibawah Ini !!</label>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
@foreach($kriteria as $kri)
|
||||
<div class="col-md-4 mb-3">
|
||||
<label for="nilaiFaktor">{{ $kri->id_kriteria }} - {{ $kri->nama_kriteria }}</label>
|
||||
<input type="hidden" name="kriteria_kode[]" value="{{ $kri->id_kriteria }}">
|
||||
<select class="form-control" name="nilaiFaktor[]">
|
||||
<option selected>Choose...</option>
|
||||
@foreach(\App\Models\Subkriteria::where('kriteria_kode', $kri->id_kriteria)->get() as $subKriteria)
|
||||
<option value="{{ $subKriteria->subkriteria_bobot }}">{{ $subKriteria->keterangan }} - Bobot: {{ $subKriteria->subkriteria_bobot }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
<div class="form-group mb-0">
|
||||
<button type="submit" class="btn btn-primary">Simpan</button>
|
||||
<a href="{{ route('nilai') }}" class="btn btn-light btn-light">Kembali</a>
|
||||
</div>
|
||||
{{ Form::close() }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@include('components.theme.pages.footer')
|
|
@ -0,0 +1,58 @@
|
|||
@include('components.theme.pages.header')
|
||||
|
||||
<section>
|
||||
<!-- basic table -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h6 class="m-0 text-primary font-weight-bold">Perbarui Nilai</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
{{ Form::open(['route' => ['nilai.update', 'id' => $id], 'id' => 'form-tag-update']) }}
|
||||
@csrf
|
||||
@if(session()->has('success'))
|
||||
<div class="alert alert-success">
|
||||
{{ session()->get('success') }}
|
||||
</div>
|
||||
@else
|
||||
@if(session()->has('error'))
|
||||
<div class="alert alert-danger">
|
||||
{{ session()->get('error') }}
|
||||
</div>
|
||||
@endif
|
||||
@endif
|
||||
|
||||
<div class="form-group mb-3">
|
||||
<label>Nasabah Kode</label>
|
||||
<select class="form-control" name="alternatif_kode">
|
||||
@foreach(\App\Models\Alternatif::all() as $alternatif)
|
||||
<option value="{{ $alternatif->id_alternatif }}" @if($alternatif->id_alternatif == $nilai->alternatif_kode) selected @endif>({{ $alternatif->id_alternatif }}) {{ $alternatif->nama_alternatif }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group mb-3">
|
||||
<label>Kriteria Kode</label>
|
||||
<select class="form-control" name="kriteria_kode">
|
||||
@foreach(\App\Models\Subkriteria::where('kriteria_kode', $nilai->kriteria_kode)->get() as $kriteria)
|
||||
@php
|
||||
$nama = \App\Models\Kriteria::where('id_kriteria', $nilai->kriteria_kode)->first()->nama_kriteria;
|
||||
@endphp
|
||||
<option value="{{ $kriteria->subkriteria_bobot }}" @if($kriteria->subkriteria_bobot == $nilai->nilai_faktor) selected @endif>{{ $kriteria->keterangan }}, Nilai Bobot: {{ $kriteria->subkriteria_bobot }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group mb-0">
|
||||
<button type="submit" class="btn btn-primary">Simpan</button>
|
||||
<a href="{{ route('nilai') }}" class="btn btn-light btn-light">Kembali</a>
|
||||
</div>
|
||||
{{ Form::close() }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@include('components.theme.pages.footer')
|
|
@ -0,0 +1,198 @@
|
|||
@include('components.theme.pages.header')
|
||||
<section>
|
||||
<!-- basic table -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
|
||||
<div class="d-flex mb-4">
|
||||
<h1 class="h3 text-gray-800">{{ $data['subtitle'] }}</h1>
|
||||
@if (!empty($data['button']))
|
||||
<!--begin::Action-->
|
||||
<div class="ml-auto">
|
||||
@php
|
||||
$url = $data['module']['url'];
|
||||
@endphp
|
||||
<a href="{{ $data['module']['url'] }}" class="btn btn-primary">
|
||||
{{ explode(' ', $data['module']['name'])[0] }} <span
|
||||
class="d-none d-sm-inline ps-2">{{ ucfirst(explode(' ', $data['module']['name'])[1]) }}</span>
|
||||
</a>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
@if (session()->has('success'))
|
||||
<div class="alert alert-success">
|
||||
{{ session()->get('success') }}
|
||||
</div>
|
||||
@else
|
||||
@if (session()->has('error'))
|
||||
<div class="alert alert-danger">
|
||||
{{ session()->get('error') }}
|
||||
</div>
|
||||
@endif
|
||||
@endif
|
||||
<!--end::Wrapper-->
|
||||
<div class="table-responsive">
|
||||
<table id="data-table" class="table" width="100%">
|
||||
<thead>
|
||||
<tr class="text-start">
|
||||
<th>ID</th>
|
||||
<th>Nama Nasabah</th>
|
||||
<th>Kriteria</th>
|
||||
<th>Nilai Faktor</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- @foreach (\App\Models\Nilai::all() as $nilai)
|
||||
@php
|
||||
$nasabah = \App\Models\Alternatif::find($nilai->alternatif_kode);
|
||||
$kriteria = \App\Models\Kriteria::find($nilai->kriteria_kode);
|
||||
@endphp
|
||||
<tr>
|
||||
<td>{{ $nilai->id }}</td>
|
||||
<td>{{ $nilai->alternatif_kode . ' - ' . $nasabah->nama_alternatif }}</td>
|
||||
<td>{{ $nilai->kriteria_kode . ' - ' . $kriteria->nama_kriteria }}</td>
|
||||
<td>{{ $nilai->nilai_faktor }}</td>
|
||||
<td>
|
||||
<button class="btn btn-secondary btn-sm dropdown-toggle" type="button"
|
||||
id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true"
|
||||
aria-expanded="false">
|
||||
Aksi
|
||||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
<a href="#" class="dropdown-item" data-toggle="modal" data-target="#modalEdit{{ $nilai->id }}">Edit</a>
|
||||
<a class="dropdown-item" href="{{ site_url('user', 'nilai') . '/delete/' . $nilai->id }}">Hapus</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@foreach (\App\Models\Alternatif::all() as $alternatif)
|
||||
<div class="modal fade" id="modalEdit{{ $alternatif->id_alternatif }}" tabindex="-1" role="dialog"
|
||||
aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="exampleModalLabel">Perbarui Nilai</h5>
|
||||
<button class="close" type="button" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form action="{{ site_url('user', 'nilai/update') }}" method="POST">
|
||||
@csrf
|
||||
@php
|
||||
$alt_kode = $alternatif->id_alternatif;
|
||||
|
||||
@endphp
|
||||
@foreach (\App\Models\Nilai::where('alternatif_kode', $alt_kode)->orderBy('kriteria_kode')->get() as $data_nilai)
|
||||
<div class="form-group mb-2">
|
||||
<input type="hidden" name="nilaiId[]" value="{{ $data_nilai->id }}">
|
||||
<input type="hidden" name="altKode[]" value="{{ $data_nilai->alternatif_kode }}">
|
||||
<input type="hidden" name="kriKode[]" value="{{ $data_nilai->kriteria_kode }}">
|
||||
|
||||
<?php
|
||||
$kri_kode = $data_nilai->kriteria_kode;
|
||||
foreach (\App\Models\Kriteria::where('id_kriteria', $kri_kode)->get() as $data_kriteria) {
|
||||
?>
|
||||
<label for="kriNama">{{ $data_kriteria->id_kriteria }} -
|
||||
{{ $data_kriteria->nama_kriteria }}</label>
|
||||
<select class="form-control" name="nilaiFaktor[]">
|
||||
<?php
|
||||
foreach (\App\Models\SubKriteria::where('kriteria_kode', $kri_kode)->get() as $subKriteria) {
|
||||
?>
|
||||
<option value="{{ $subKriteria['subkriteria_bobot'] }}"
|
||||
{{ $subKriteria['subkriteria_bobot'] == $data_nilai['nilai_faktor'] ? 'selected' : '' }}>
|
||||
{{ $subKriteria['keterangan'] . ' (bobot : ' . $subKriteria['subkriteria_bobot'] . ')' }}
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<?php } ?>
|
||||
</div>
|
||||
@endforeach
|
||||
<div class="mb-0">
|
||||
<button type="submit" class="btn btn-primary w-100" name="save">Simpan</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var table = $('#data-table').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: "{{ route('nilai') }}",
|
||||
columns: [{
|
||||
data: null,
|
||||
name: 'id'
|
||||
},
|
||||
{
|
||||
data: 'nama',
|
||||
name: 'nama'
|
||||
},
|
||||
{
|
||||
data: 'kriteria',
|
||||
name: 'kriteria'
|
||||
},
|
||||
{
|
||||
data: 'nilai_faktor',
|
||||
name: 'nilai_faktor'
|
||||
},
|
||||
{
|
||||
data: null,
|
||||
name: 'action',
|
||||
orderable: false,
|
||||
searchable: false
|
||||
},
|
||||
],
|
||||
columnDefs: [{
|
||||
targets: -1,
|
||||
data: null,
|
||||
orderable: false,
|
||||
render: function(data, type, row) {
|
||||
if (row.kriteria_kode == "C1") {
|
||||
return `
|
||||
<button class="btn btn-secondary btn-sm dropdown-toggle" type="button"
|
||||
id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true"
|
||||
aria-expanded="false">
|
||||
Aksi
|
||||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
<a href="#" class="dropdown-item" data-toggle="modal" data-target="#modalEdit${row.alternatif_kode}">Edit</a>
|
||||
<a class="dropdown-item" href="{{ site_url('user', 'nilai') . '/delete' }}/${row.alternatif_kode}">Hapus</a>
|
||||
</div>
|
||||
`;
|
||||
} else {
|
||||
return '~';
|
||||
}
|
||||
},
|
||||
}],
|
||||
createdRow: function(row, data, dataIndex) {
|
||||
// Set the sequential number starting from 1
|
||||
$('td', row).eq(0).html(dataIndex + 1);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
<!-- <script>
|
||||
$('#data-table').dataTable();
|
||||
</script> -->
|
||||
@endpush
|
||||
@include('components.theme.pages.footer')
|
|
@ -0,0 +1,354 @@
|
|||
@include('components.theme.pages.header')
|
||||
<section>
|
||||
<?php $ranks = []; ?>
|
||||
<div class="row mb-4">
|
||||
<!-- Tabel Normalisasi Bobot Kriteria -->
|
||||
<div class="col-md-12 mb-3">
|
||||
<div class="card shadow">
|
||||
<div class="card-header">
|
||||
<h6 class="text-primary m-0">Tabel Normalisasi Bobot Kriteria</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<tr class="text-center">
|
||||
<th>Kriteria</th>
|
||||
<th>Bobot Kriteria</th>
|
||||
<th>Normalisasi Bobot Kriteria</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="text-center">
|
||||
<?php
|
||||
$total_bobot = 0;
|
||||
|
||||
// Hitung total bobot untuk normalisasi
|
||||
foreach (\App\Models\Kriteria::all() as $bobot_kriteria) {
|
||||
$total_bobot += $bobot_kriteria->bobot_kriteria;
|
||||
}
|
||||
|
||||
// Lakukan normalisasi bobot kriteria
|
||||
foreach (\App\Models\Kriteria::all() as $kriteria) {
|
||||
$normalisasi_bobot = $kriteria->bobot_kriteria / $total_bobot;
|
||||
?>
|
||||
<tr>
|
||||
<td>({{ $kriteria->id_kriteria }}) {{ $kriteria->nama_kriteria }}</td>
|
||||
<td>{{ $kriteria->bobot_kriteria }}</td>
|
||||
<td>{{ $normalisasi_bobot }}</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12 mb-3">
|
||||
<div class="card shadow">
|
||||
<div class="card-header">
|
||||
<h6 class="text-primary m-0">Tabel Penilaian Nasabah</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th rowspan="2" class="align-middle text-center">No</th>
|
||||
<th rowspan="2" class="align-middle text-center">Nama Nasabah</th>
|
||||
<th colspan="{{ \App\Models\Kriteria::count() }}" class="align-middle text-center">Nama
|
||||
Kriteria</th>
|
||||
</tr>
|
||||
<tr>
|
||||
@foreach (\App\Models\Kriteria::all() as $kri)
|
||||
<td>({{ $kri->id_kriteria }}) {{ $kri->nama_kriteria }}</td>
|
||||
@endforeach
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="text-center">
|
||||
@php
|
||||
$no = 1;
|
||||
@endphp
|
||||
@foreach (\App\Models\Alternatif::all() as $alt)
|
||||
<tr>
|
||||
<td>{{ $no++ }}</td>
|
||||
<td>{{ $alt->nama_alternatif }}</td>
|
||||
@foreach (\App\Models\Nilai::where('alternatif_kode', $alt->id_alternatif)->orderBy('kriteria_kode')->get() as $data_nilai)
|
||||
<td>{{ $data_nilai->nilai_faktor }}</td>
|
||||
@endforeach
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
<tfoot class="text-center table-warning">
|
||||
<tr>
|
||||
<td colspan="2">Nilai Max</td>
|
||||
@foreach (\App\Models\Kriteria::all() as $kri)
|
||||
@php
|
||||
$max_value = \App\Models\Nilai::where('kriteria_kode', $kri->id_kriteria)->max(
|
||||
'nilai_faktor',
|
||||
);
|
||||
@endphp
|
||||
<td>{{ $max_value }}</td>
|
||||
@endforeach
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">Nilai Min</td>
|
||||
@foreach (\App\Models\Kriteria::all() as $kri)
|
||||
@php
|
||||
$min_value = \App\Models\Nilai::where('kriteria_kode', $kri->id_kriteria)->min(
|
||||
'nilai_faktor',
|
||||
);
|
||||
@endphp
|
||||
<td>{{ $min_value }}</td>
|
||||
@endforeach
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12 mb-3">
|
||||
<div class="card shadow">
|
||||
<div class="card-header">
|
||||
<h6 class="text-primary m-0">Tabel Perhitungan Utility</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<tr class="">
|
||||
<th rowspan="2" class="align-middle text-center">No</th>
|
||||
<th rowspan="2" class="align-middle text-center">Alternatif</th>
|
||||
<th colspan="{{ \App\Models\Kriteria::count() }}" class="align-middle text-center">
|
||||
Kriteria</th>
|
||||
</tr>
|
||||
<tr class="">
|
||||
@foreach (\App\Models\Kriteria::all() as $kri)
|
||||
<td>({{ $kri->id_kriteria }}) {{ $kri->nama_kriteria }}</td>
|
||||
@endforeach
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@php
|
||||
$no = 1;
|
||||
@endphp
|
||||
@foreach (\App\Models\Alternatif::all() as $alternatif)
|
||||
<tr>
|
||||
<td>{{ $no++ }}</td>
|
||||
<td>{{ $alternatif->nama_alternatif }}</td>
|
||||
@foreach (\App\Models\Nilai::where('alternatif_kode', $alternatif->id_alternatif)->orderBy('kriteria_kode')->get() as $data_nilai)
|
||||
@foreach (\App\Models\Kriteria::where('id_kriteria', $data_nilai->kriteria_kode)->get() as $kriteria)
|
||||
@if ($kriteria->kriteria_kategori == 'benefit')
|
||||
@php
|
||||
$nilai_Cmax = \App\Models\Nilai::where(
|
||||
'kriteria_kode',
|
||||
$kriteria->id_kriteria,
|
||||
)->max('nilai_faktor');
|
||||
$nilai_Cmin = \App\Models\Nilai::where(
|
||||
'kriteria_kode',
|
||||
$kriteria->id_kriteria,
|
||||
)->min('nilai_faktor');
|
||||
@endphp
|
||||
|
||||
<!-- proses nilai utiliti -->
|
||||
@php
|
||||
if ($nilai_Cmax - $nilai_Cmin == 0) {
|
||||
$nilai_utiliti = 0;
|
||||
} else {
|
||||
$nilai_utiliti =
|
||||
($data_nilai->nilai_faktor - $nilai_Cmin) /
|
||||
($nilai_Cmax - $nilai_Cmin);
|
||||
}
|
||||
@endphp
|
||||
<td>{{ $nilai_utiliti }}</td>
|
||||
@elseif($kriteria->kriteria_kategori === 'cost')
|
||||
@php
|
||||
$nilai_Cmax = \App\Models\Nilai::where(
|
||||
'kriteria_kode',
|
||||
$kriteria->id_kriteria,
|
||||
)->max('nilai_faktor');
|
||||
$nilai_Cmin = \App\Models\Nilai::where(
|
||||
'kriteria_kode',
|
||||
$kriteria->id_kriteria,
|
||||
)->min('nilai_faktor');
|
||||
@endphp
|
||||
<!-- proses nilai utiliti -->
|
||||
|
||||
@php
|
||||
if ($nilai_Cmax - $nilai_Cmin == 0) {
|
||||
$nilai_utiliti = 0;
|
||||
} else {
|
||||
$nilai_utiliti =
|
||||
($nilai_Cmax - $data_nilai->nilai_faktor) /
|
||||
($nilai_Cmax - $nilai_Cmin);
|
||||
}
|
||||
@endphp
|
||||
<td>{{ $nilai_utiliti }}</td>
|
||||
@endif
|
||||
@endforeach
|
||||
@endforeach
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12 mb-3">
|
||||
<div class="card shadow">
|
||||
<div class="card-header">
|
||||
<h6 class="text-primary m-0">Tabel Hasil Akhir</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<tr class="">
|
||||
<th rowspan="2" class="align-middle text-center">No</th>
|
||||
<th rowspan="2" class="align-middle text-center">Alternatif</th>
|
||||
<th colspan="{{ \App\Models\Kriteria::count() }}" class="align-middle text-center">
|
||||
Kriteria</th>
|
||||
<th rowspan="2" class="align-middle text-center">Nilai Akhir</th>
|
||||
</tr>
|
||||
<tr class="">
|
||||
@foreach (\App\Models\Kriteria::all() as $kri)
|
||||
<td>({{ $kri->id_kriteria }}) {{ $kri->nama_kriteria }}</td>
|
||||
@endforeach
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@php
|
||||
$no = 1;
|
||||
$total_bobot = 0;
|
||||
|
||||
foreach (\App\Models\Kriteria::all() as $bobot_kriteria) {
|
||||
$total_bobot += $bobot_kriteria->bobot_kriteria;
|
||||
}
|
||||
@endphp
|
||||
@foreach (\App\Models\Alternatif::all() as $alternatif)
|
||||
@php
|
||||
$hasil_preferensi = 0;
|
||||
@endphp
|
||||
<tr>
|
||||
<td>{{ $no++ }}</td>
|
||||
<td>{{ $alternatif->nama_alternatif }}</td>
|
||||
@foreach (\App\Models\Nilai::where('alternatif_kode', $alternatif->id_alternatif)->orderBy('kriteria_kode')->get() as $data_nilai)
|
||||
@foreach (\App\Models\Kriteria::where('id_kriteria', $data_nilai->kriteria_kode)->get() as $kriteria)
|
||||
@if ($kriteria->kriteria_kategori == 'benefit')
|
||||
@php
|
||||
$nilai_Cmax = \App\Models\Nilai::where(
|
||||
'kriteria_kode',
|
||||
$kriteria->id_kriteria,
|
||||
)->max('nilai_faktor');
|
||||
$nilai_Cmin = \App\Models\Nilai::where(
|
||||
'kriteria_kode',
|
||||
$kriteria->id_kriteria,
|
||||
)->min('nilai_faktor');
|
||||
$normalisasiBobot = $kriteria->bobot_kriteria / $total_bobot;
|
||||
@endphp
|
||||
|
||||
<!-- proses nilai utiliti -->
|
||||
@php
|
||||
if ($nilai_Cmax - $nilai_Cmin == 0) {
|
||||
$nilai_utiliti = 0;
|
||||
} else {
|
||||
$nilai_utiliti =
|
||||
($data_nilai->nilai_faktor - $nilai_Cmin) /
|
||||
($nilai_Cmax - $nilai_Cmin);
|
||||
$nilai_preferensi = $nilai_utiliti * $normalisasiBobot;
|
||||
$hasil_preferensi = $hasil_preferensi + $nilai_preferensi;
|
||||
}
|
||||
@endphp
|
||||
<td>{{ round($nilai_preferensi, 5) }}</td>
|
||||
@elseif($kriteria->kriteria_kategori === 'cost')
|
||||
@php
|
||||
$nilai_Cmax = \App\Models\Nilai::where(
|
||||
'kriteria_kode',
|
||||
$kriteria->id_kriteria,
|
||||
)->max('nilai_faktor');
|
||||
$nilai_Cmin = \App\Models\Nilai::where(
|
||||
'kriteria_kode',
|
||||
$kriteria->id_kriteria,
|
||||
)->min('nilai_faktor');
|
||||
$normalisasiBobot = $kriteria->bobot_kriteria / $total_bobot;
|
||||
@endphp
|
||||
<!-- proses nilai utiliti -->
|
||||
|
||||
@php
|
||||
if ($nilai_Cmax - $nilai_Cmin == 0) {
|
||||
$nilai_utiliti = 0;
|
||||
} else {
|
||||
$nilai_utiliti =
|
||||
($nilai_Cmax - $data_nilai->nilai_faktor) /
|
||||
($nilai_Cmax - $nilai_Cmin);
|
||||
$nilai_preferensi = $nilai_utiliti * $normalisasiBobot;
|
||||
$hasil_preferensi = $hasil_preferensi + $nilai_preferensi;
|
||||
}
|
||||
@endphp
|
||||
<td>{{ round($nilai_preferensi, 5) }}</td>
|
||||
@endif
|
||||
@endforeach
|
||||
@endforeach
|
||||
<td><?= round($hasil_preferensi, 5)
|
||||
//tampilkan hasil_preferensi
|
||||
?></td>
|
||||
<?php
|
||||
//masukan nilai hasil-sum, nama-alternatif, kode-alternatif ke dalam variabel $ranks(baris 26)
|
||||
$rank['hasil_preferensi'] = $hasil_preferensi;
|
||||
$rank['alternatifNama'] = $alternatif->nama_alternatif;
|
||||
$rank['alternatifKode'] = $alternatif->id_alternatif;
|
||||
array_push($ranks, $rank);
|
||||
?>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<div class="card shadow">
|
||||
<div class="card-header">
|
||||
<h6 class="text-primary m-0">Tabel Ranking</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<tr class="table-warning text-center">
|
||||
<th>Ranking</th>
|
||||
<th>Nasabah</th>
|
||||
<th>Nilai SMART</th>
|
||||
<th>Keputusan</th>
|
||||
<th>Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="text-center">
|
||||
<?php
|
||||
$ranking = 1;
|
||||
rsort($ranks);
|
||||
foreach ($ranks as $r) {
|
||||
?>
|
||||
<tr>
|
||||
<td class="text-center"><?= $ranking++ ?></td>
|
||||
<td><?= '(' . $r['alternatifKode'] . ') ' . $r['alternatifNama'] ?></td>
|
||||
<td><?= number_format($r['hasil_preferensi'], 2) ?></td>
|
||||
@if ($r['hasil_preferensi'] >= 0.7)
|
||||
<td class="bg-success text-white">Direkomendasikan</td>
|
||||
<td>
|
||||
<form method="POST" action="{{ site_url('user', 'pengajuan/add') }}">
|
||||
@csrf
|
||||
<input type="hidden" name="nasabah_kode"
|
||||
value="{{ $r['alternatifKode'] }}">
|
||||
<input type="hidden" name="hasil_preferensi"
|
||||
value="{{ $r['hasil_preferensi'] }}">
|
||||
<button type="submit" class="btn btn-primary btn-sm">Ajukan</button>
|
||||
</form>
|
||||
</td>
|
||||
@else
|
||||
<td class="bg-danger text-white">Tidak Direkomendasikan</td>
|
||||
<td>-</td>
|
||||
@endif
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@include('components.theme.pages.footer')
|
|
@ -0,0 +1,91 @@
|
|||
@include('components.theme.pages.header')
|
||||
<section>
|
||||
<!-- basic table -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
|
||||
<div class="d-flex mb-4">
|
||||
<h1 class="h3 text-gray-800">{{ $data['subtitle'] }}</h1>
|
||||
@if (!empty($data['button']))
|
||||
<!--begin::Action-->
|
||||
<div class="ml-auto">
|
||||
@php
|
||||
$url = $data['module']['url'];
|
||||
@endphp
|
||||
<a href="{{ $data['module']['url'] }}" class="btn btn-primary">
|
||||
{{ explode(' ', $data['module']['name'])[0] }} <span
|
||||
class="d-none d-sm-inline ps-2">{{ ucfirst(explode(' ', $data['module']['name'])[1]) }}</span>
|
||||
</a>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
@if (session()->has('success'))
|
||||
<div class="alert alert-success">
|
||||
{{ session()->get('success') }}
|
||||
</div>
|
||||
@else
|
||||
@if (session()->has('error'))
|
||||
<div class="alert alert-danger">
|
||||
{{ session()->get('error') }}
|
||||
</div>
|
||||
@endif
|
||||
@endif
|
||||
<!--end::Wrapper-->
|
||||
<div class="table-responsive">
|
||||
<table id="data-table" class="table" width="100%">
|
||||
<thead>
|
||||
<tr class="text-start">
|
||||
<th>ID</th>
|
||||
<th>Nama Nasabah</th>
|
||||
<th>Uplink AO</th>
|
||||
<th>Status Pengajuan</th>
|
||||
<th>Tanggal Ditambahkan</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@php $no = 1; @endphp
|
||||
@foreach (\App\Models\PengajuanNasabah::all() as $data)
|
||||
@php
|
||||
$nasabah = \App\Models\Alternatif::where(
|
||||
'id_alternatif',
|
||||
$data->id_nasabah,
|
||||
)->first();
|
||||
$uplink = \App\Models\User::where('id', $data->uplink)->first();
|
||||
@endphp
|
||||
<tr>
|
||||
<td>{{ $no++ }}</td>
|
||||
<td>{{ $nasabah->nama_alternatif }}</td>
|
||||
<td>{{ $uplink->name }}</td>
|
||||
<td>{{ round($data->skor, 5) }}</td>
|
||||
<td>
|
||||
@php
|
||||
if ($data->status == 1) {
|
||||
echo '<span class="mb-1 badge font-medium badge-success py-2 px-3 fs-7">Diterima</span>';
|
||||
} elseif ($data->status == 0) {
|
||||
echo '<span class="mb-1 badge font-medium badge-primary py-2 px-3 fs-7">Menunggu Respon</span>';
|
||||
} else {
|
||||
echo '<span class="mb-1 badge font-medium badge-danger py-2 px-3 fs-7">Tidak diterima</span>';
|
||||
}
|
||||
@endphp
|
||||
</td>
|
||||
<td>{{ \Carbon\Carbon::parse($data->created_at)->format('d F Y, H:i:s') }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
$('#data-table').dataTable();
|
||||
</script>
|
||||
@endpush
|
||||
@include('components.theme.pages.footer')
|
|
@ -0,0 +1,47 @@
|
|||
@include('components.theme.pages.header')
|
||||
<section>
|
||||
<div class="row">
|
||||
<div class="col-md-12 mt-9">
|
||||
@if(session()->has('success'))
|
||||
<div class="alert alert-success mb-2">
|
||||
{{ session()->get('success') }}
|
||||
</div>
|
||||
@else
|
||||
@if(session()->has('error'))
|
||||
<div class="alert alert-danger mb-2">
|
||||
{{ session()->get('error') }}
|
||||
</div>
|
||||
@endif
|
||||
@endif
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3 class="h6 mb-0 text-primary">Umum</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="{{ site_url('user', 'account/update') }}" method="POST">
|
||||
@csrf
|
||||
<div class="row mb-2">
|
||||
<div class="col-6 form-group">
|
||||
<label class="form-label">Nama Lengkap<sup class="ms-1 text-danger">*</sup></label>
|
||||
<input type="text" name="name" class="form-control form-control-solid mt-2" value="{{ user()->name }}" placeholder="Nama Lengkap">
|
||||
</div>
|
||||
<div class="col-6 form-group">
|
||||
<label class="form-label">Alamat Email<sup class="ms-1 text-danger">*</sup></label>
|
||||
<input type="email" name="email" class="form-control form-control-solid mt-2" id="email" value="{{ user()->email }}" placeholder="Alamat Email">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group mb-4">
|
||||
<label class="form-label">Kata Sandi<span class="ml-2 fs-8 text-danger small">opsional (kosongi jika tidak ingin merubah)</span></label>
|
||||
<input type="password" name="password" class="form-control form-control-solid mt-2" value="" placeholder="Kata Sandi">
|
||||
</div>
|
||||
<div class="form-group mb-0">
|
||||
<button type="submit" class="btn btn-primary">Simpan</button>
|
||||
<a href="{{ route('dashboard') }}" class="btn btn-light btn-light">Kembali</a>
|
||||
</div>
|
||||
{!! Form::close() !!}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@include('components.theme.pages.footer')
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| API Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is where you can register API routes for your application. These
|
||||
| routes are loaded by the RouteServiceProvider within a group which
|
||||
| is assigned the "api" middleware group. Enjoy building your API!
|
||||
|
|
||||
*/
|
||||
|
||||
Route::middleware('auth:api')->get('/user', function (Request $request) {
|
||||
return $request->user();
|
||||
});
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Web Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is where you can register web routes for your application. These
|
||||
| routes are loaded by the RouteServiceProvider within a group which
|
||||
| contains the "web" middleware group. Now create something great!
|
||||
|
|
||||
*/
|
||||
|
||||
Route::group(['prefix' => 'user', 'middleware' => ['auth', 'check.auth']], function () {
|
||||
Route::get('/', 'UserController@index');
|
||||
|
||||
Route::prefix('nasabah')->group(function () {
|
||||
// Gejala
|
||||
Route::get('/', 'NasabahController@index')->name('nasabah');
|
||||
Route::get('create', 'NasabahController@create')->name('nasabah.create');
|
||||
Route::post('store', 'NasabahController@store')->name('nasabah.store');
|
||||
Route::get('edit/{id}', 'NasabahController@edit')->name('nasabah.edit');
|
||||
Route::post('update/{id}', 'NasabahController@update')->name('nasabah.update');
|
||||
Route::get('delete/{id}', 'NasabahController@destroy')->name('nasabah.delete');
|
||||
});
|
||||
|
||||
Route::prefix('nilai')->group(function () {
|
||||
// Gejala
|
||||
Route::get('/', 'NilaiController@index')->name('nilai');
|
||||
Route::get('create', 'NilaiController@create')->name('nilai.create');
|
||||
Route::post('store', 'NilaiController@store')->name('nilai.store');
|
||||
Route::get('edit/{id}', 'NilaiController@edit')->name('nilai.edit');
|
||||
Route::post('update', 'NilaiController@update')->name('nilai.update');
|
||||
Route::get('delete/{id}', 'NilaiController@destroy')->name('nilai.delete');
|
||||
});
|
||||
|
||||
Route::prefix('account')->group(function () {
|
||||
Route::get('/', 'UserController@profile')->name('user.account');
|
||||
Route::post('update', 'UserController@update')->name('user.account.update');
|
||||
});
|
||||
|
||||
Route::prefix('pengajuan')->group(function () {
|
||||
Route::get('/', 'PengajuanController@index')->name('pengajuan');
|
||||
Route::post('add', 'PengajuanController@add')->name('pengajuan.add');
|
||||
});
|
||||
|
||||
Route::get('ranking', 'NilaiController@ranking')->name('ranking');
|
||||
});
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"name": "nwidart/user",
|
||||
"description": "",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Widart",
|
||||
"email": "n.widart@gmail.com"
|
||||
}
|
||||
],
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [],
|
||||
"aliases": {
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Modules\\User\\": ""
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"name": "User",
|
||||
"alias": "user",
|
||||
"description": "",
|
||||
"keywords": [],
|
||||
"priority": 0,
|
||||
"providers": [
|
||||
"Modules\\User\\Providers\\UserServiceProvider"
|
||||
],
|
||||
"aliases": {},
|
||||
"files": [],
|
||||
"requires": []
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "npm run development",
|
||||
"development": "mix",
|
||||
"watch": "mix watch",
|
||||
"watch-poll": "mix watch -- --watch-options-poll=1000",
|
||||
"hot": "mix watch --hot",
|
||||
"prod": "npm run production",
|
||||
"production": "mix --production"
|
||||
},
|
||||
"devDependencies": {
|
||||
"axios": "^0.21.4",
|
||||
"dotenv": "^10.0.0",
|
||||
"dotenv-expand": "^5.1.0",
|
||||
"laravel-mix": "^6.0.31",
|
||||
"laravel-mix-merge-manifest": "^2.0.0",
|
||||
"lodash": "^4.17.21",
|
||||
"postcss": "^8.3.7"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
const dotenvExpand = require('dotenv-expand');
|
||||
dotenvExpand(require('dotenv').config({ path: '../../.env'/*, debug: true*/}));
|
||||
|
||||
const mix = require('laravel-mix');
|
||||
require('laravel-mix-merge-manifest');
|
||||
|
||||
mix.setPublicPath('../../public').mergeManifest();
|
||||
|
||||
mix.js(__dirname + '/Resources/assets/js/app.js', 'js/user.js')
|
||||
.sass( __dirname + '/Resources/assets/sass/app.scss', 'css/user.css');
|
||||
|
||||
if (mix.inProduction()) {
|
||||
mix.version();
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Modules\Seller\Entities\PaymentModel as Payment;
|
||||
use App\Enums\GlobalEnum as Status;
|
||||
|
||||
class DepositCommand extends Command
|
||||
{
|
||||
protected $signature = 'deposit:update';
|
||||
protected $description = 'Update status in deposit every minutes';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$orders = Payment::where('is_status', Status::isDepositPending)->get(); // Sesuaikan dengan logika pengambilan data
|
||||
$currentTimestamp = time(); // Get the current timestamp
|
||||
|
||||
foreach ($orders as $order) {
|
||||
$createdAtTimestamp = strtotime($order->created_at);
|
||||
|
||||
// Add 3 days to the creation date timestamp
|
||||
$expiryTimestamp = $createdAtTimestamp + (3 * 24 * 60 * 60); // 3 days in seconds
|
||||
|
||||
// Compare the expiry timestamp with the current timestamp
|
||||
$isExpired = $expiryTimestamp < $currentTimestamp;
|
||||
$expired = $isExpired ? true : false;
|
||||
|
||||
if($expired == true) {
|
||||
$findOrder = Payment::find($order->id);
|
||||
$findOrder->is_status = Status::isDepositCancel;
|
||||
|
||||
// save
|
||||
$findOrder->save();
|
||||
}
|
||||
}
|
||||
|
||||
$this->info('Status updated successfully!');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Modules\User\Entities\OrderModel as Order;
|
||||
use App\Enums\GlobalEnum as Status;
|
||||
|
||||
class OrdersCommand extends Command
|
||||
{
|
||||
protected $signature = 'orders:update';
|
||||
protected $description = 'Update status in orders every minutes';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$orders = Order::where('is_status', Status::isOrderRequested)->get(); // Sesuaikan dengan logika pengambilan data
|
||||
$currentTimestamp = time(); // Get the current timestamp
|
||||
|
||||
foreach ($orders as $order) {
|
||||
$createdAtTimestamp = strtotime($order->created_at);
|
||||
|
||||
// Add 3 days to the creation date timestamp
|
||||
$expiryTimestamp = $createdAtTimestamp + (3 * 24 * 60 * 60); // 3 days in seconds
|
||||
|
||||
// Compare the expiry timestamp with the current timestamp
|
||||
$isExpired = $expiryTimestamp < $currentTimestamp;
|
||||
$expired = $isExpired ? true : false;
|
||||
|
||||
if($expired == true) {
|
||||
$findOrder = Order::find($order->id);
|
||||
$findOrder->is_status = Status::isOrderCancelled;
|
||||
$findOrder->last_buyer_message = 'Dibatalkan secara otomatis oleh sistem karena melebihi batas waktu 3 hari reseller tidak menanggapi permintaan pesanan';
|
||||
$findOrder->cancel_reason = 'Dibatalkan secara otomatis oleh sistem karena melebihi batas waktu 3 hari reseller tidak menanggapi permintaan pesanan';
|
||||
|
||||
// save
|
||||
$findOrder->save();
|
||||
}
|
||||
}
|
||||
|
||||
$this->info('Status updated successfully!');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Modules\Seller\Entities\PaymentModel as Payment;
|
||||
use Modules\Seller\Entities\AccountModel as User;
|
||||
use App\Enums\GlobalEnum as Status;
|
||||
|
||||
class RealtimeDepositCommand extends Command
|
||||
{
|
||||
protected $signature = 'realtime-deposit:update';
|
||||
protected $description = 'Update status in deposit every minutes';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$orders = Payment::where('is_status', Status::isDepositPending)->get(); // Sesuaikan dengan logika pengambilan data
|
||||
$currentTimestamp = time(); // Get the current timestamp
|
||||
|
||||
foreach ($orders as $order) {
|
||||
$merchantCode = app_info('duitku_merchant');
|
||||
$apiKey = app_info('duitku_client');
|
||||
$merchantOrderId = $order->deposit_number; // dari anda (merchant), bersifat unik
|
||||
$signature = md5($merchantCode . $merchantOrderId . $apiKey);
|
||||
|
||||
$params = array(
|
||||
'merchantCode' => $merchantCode,
|
||||
'merchantOrderId' => $merchantOrderId,
|
||||
'signature' => $signature
|
||||
);
|
||||
|
||||
$params_string = json_encode($params);
|
||||
if(app_info('duitku_sandbox') == 1) {
|
||||
$url = 'https://sandbox.duitku.com/webapi/api/merchant/transactionStatus'; // Sandbox
|
||||
} else {
|
||||
$url = 'https://passport.duitku.com/webapi/api/merchant/transactionStatus'; // Production
|
||||
}
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $params_string);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($params_string))
|
||||
);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
|
||||
//execute post
|
||||
$request = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
|
||||
if($httpCode == 200)
|
||||
{
|
||||
$results = json_decode($request, true);
|
||||
if($results['statusCode'] == 02) {
|
||||
$findOrder = Payment::find($order->id);
|
||||
$findOrder->is_status = Status::isDepositCancel;
|
||||
$findOrder->urlRedirect = NULL;
|
||||
|
||||
// save
|
||||
$findOrder->save();
|
||||
} elseif($results['statusCode'] == 00) {
|
||||
$findOrder = Payment::find($order->id);
|
||||
$findOrder->is_status = Status::isDepositPaid;
|
||||
$findOrder->urlRedirect = NULL;
|
||||
|
||||
$findUser = User::where('id', $order->user_id)->first();
|
||||
$findUser->balance = ($findUser->balance + $order->amount);
|
||||
|
||||
// save
|
||||
$findOrder->save();
|
||||
$findUser->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->info('Status updated successfully!');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
$schedule->command('orders:update')->everyFiveMinutes();
|
||||
$schedule->command('deposit:update')->everyFiveMinutes();
|
||||
$schedule->command('realtime-deposit:update')->everyFiveMinutes();
|
||||
}
|
||||
|
||||
protected function commands()
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,167 @@
|
|||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use MadWeb\Enum\Enum;
|
||||
|
||||
final class GlobalEnum extends Enum
|
||||
{
|
||||
// enum management menu
|
||||
const isAdmin = 1;
|
||||
const isEditor = 2;
|
||||
const isModerator = 3;
|
||||
const isMembers = 4;
|
||||
const isKepalaSekolah = 2;
|
||||
const isKonselor = 3;
|
||||
const isSiswa = 4;
|
||||
const isWaliMurid = 5;
|
||||
|
||||
// enum sites status
|
||||
const isWebsiteActive = 1;
|
||||
const isWebsiteInReview = 2;
|
||||
const isWebsiteNotActive = 3;
|
||||
const isWebsiteRejected = 4;
|
||||
const isWebsiteDeactivated = 5;
|
||||
|
||||
// enum domain status
|
||||
const isDomainActive = 1;
|
||||
const isDomainInReview = 2;
|
||||
const isDomainNotActive = 3;
|
||||
const isDomainRejected = 4;
|
||||
const isDomainDeactivated = 5;
|
||||
|
||||
// enum log type
|
||||
const LogOfLogin = 1;
|
||||
const LogOfGeneral = 2;
|
||||
|
||||
// enum buzzer services status
|
||||
const isServiceActive = 1;
|
||||
const isServiceNotActive = 2;
|
||||
|
||||
// enum withdrawal status
|
||||
const isWithdrawPending = 1;
|
||||
const isWithdrawOnProgress = 2;
|
||||
const isWithdrawPaid = 3;
|
||||
const isWithdrawCancel = 4;
|
||||
|
||||
// enum order status
|
||||
const isOrderRequested = 1;
|
||||
const isOrderOnWorking = 2;
|
||||
const isOrderSubmitted = 3;
|
||||
const isOrderRevision = 4;
|
||||
const isOrderCompleted = 5;
|
||||
const isOrderReqCancel = 6;
|
||||
const isOrderCancelled = 7;
|
||||
const isOrderRejected = 8;
|
||||
|
||||
// enum order history status
|
||||
const isHistoryDone = 1;
|
||||
const isHistoryRevision = 2;
|
||||
const isHistoryJobDone = 3;
|
||||
const isHistoryReqCancel = 4;
|
||||
const isHistoryCanceled = 5;
|
||||
|
||||
// enum product buzzer & services status
|
||||
const isProductActive = 1;
|
||||
const isProductNotActive = 2;
|
||||
|
||||
// enum product buzzer order status
|
||||
const isProductOrderPending = 1;
|
||||
const isProductOrderPaymentAlready = 2;
|
||||
const isProductOrderProcess = 3;
|
||||
const isProductOrderDone = 4;
|
||||
const isProductOrderCancel = 5;
|
||||
|
||||
const isProductOrderTypeMixed = 1;
|
||||
const isProductOrderTypeMen = 2;
|
||||
const isProductOrderTypeWomen = 3;
|
||||
|
||||
// enum product buzzer order detail comment status
|
||||
const isProductCommentPending = 1;
|
||||
const isProductCommentInReview = 2;
|
||||
const isProductCommentDeclined = 3;
|
||||
const isProductCommentApproved = 4;
|
||||
|
||||
// enum order type
|
||||
const isOrderSites = 1;
|
||||
const isOrderDomain = 2;
|
||||
|
||||
// enum user status
|
||||
const isActive = 1;
|
||||
const isInactive = 2;
|
||||
const isDeactive = 3;
|
||||
const isNotVerified = 4;
|
||||
|
||||
// enum seller status
|
||||
const isSellerActive = 1;
|
||||
const isSellerInActive = 2;
|
||||
|
||||
// enum order status
|
||||
const isOrderPending = 1;
|
||||
const isOrderProcessing = 2;
|
||||
const isOrderInReview = 3;
|
||||
const isOrderDeclined = 4;
|
||||
const isOrderSuccessed = 5;
|
||||
|
||||
// enum deposit status
|
||||
const isDepositPending = 1;
|
||||
const isDepositInquiry = 2;
|
||||
const isDepositFailed = 3;
|
||||
const isDepositPaid = 4;
|
||||
const isDepositCancel = 5;
|
||||
|
||||
// enum methodWithDeposit
|
||||
const isMethodPayLater = 0;
|
||||
const isMethodVirtual = 1;
|
||||
|
||||
// enum promotion status
|
||||
const isPromotionAvailable = 1;
|
||||
const isPromotionUsed = 2;
|
||||
|
||||
// enum content status
|
||||
const isPostPublished = 1;
|
||||
const isPostDraft = 2;
|
||||
|
||||
// enum ticket status
|
||||
const isTicketPending = 1;
|
||||
const isTicketClosed = 2;
|
||||
const isTicketReplied = 3;
|
||||
|
||||
/* enum website-config
|
||||
[1] SMTP Config
|
||||
[2] Maintenance Mode
|
||||
*/
|
||||
const isMailerEnabled = 1;
|
||||
const isMailerDisabled = 2;
|
||||
const isMaintenanceMode = 3;
|
||||
|
||||
/* enum for seller modules
|
||||
[1] Sites Listing
|
||||
[2] Rekening
|
||||
*/
|
||||
const isSiteActive = 1;
|
||||
const isSiteInReview = 2;
|
||||
const isSiteNotActive = 3;
|
||||
const isSiteRejected = 4;
|
||||
const isSiteDeactivated = 5;
|
||||
|
||||
const isSiteOwner = 1;
|
||||
const isSiteAuthor = 2;
|
||||
|
||||
const isSiteTypeDoFollow = 1;
|
||||
const isSiteTypeNoFollow = 2;
|
||||
|
||||
// rekening status
|
||||
const isRekeningActive = 1;
|
||||
const isRekeningInactive = 2;
|
||||
|
||||
// ticket status
|
||||
const isTicketSellerPending = 1;
|
||||
const isTicketUserReplied = 2;
|
||||
const isTicketAdminReplied = 3;
|
||||
const isTicketSellerClosed = 4;
|
||||
|
||||
const isTicketPriorityNormal = 1;
|
||||
const isTicketPriorityMedium = 2;
|
||||
const isTicketPriorityHigh = 3;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use MadWeb\Enum\Enum;
|
||||
|
||||
/**
|
||||
* @method static ProjectStatusEnum FOO()
|
||||
* @method static ProjectStatusEnum BAR()
|
||||
* @method static ProjectStatusEnum BAZ()
|
||||
*/
|
||||
final class ProjectStatusEnum extends Enum
|
||||
{
|
||||
const default = 0;
|
||||
const PUBLISH = 1;
|
||||
const DRAFT = 0;
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Throwable;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* A list of the exception types that are not reported.
|
||||
*
|
||||
* @var array<int, class-string<Throwable>>
|
||||
*/
|
||||
protected $dontReport = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the inputs that are never flashed for validation exceptions.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register the exception handling callbacks for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->reportable(function (Throwable $e) {
|
||||
//
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,690 @@
|
|||
<?php
|
||||
|
||||
|
||||
if (!function_exists('isAttachment')) {
|
||||
/**
|
||||
* Determines if the given image is an attachment.
|
||||
*
|
||||
* @param string $image The path of the image file.
|
||||
* @return void
|
||||
*/
|
||||
function isAttachment($image){
|
||||
$extension = pathinfo($image, PATHINFO_EXTENSION);
|
||||
$imgExtArr = ['jpg', 'jpeg', 'png'];
|
||||
if(in_array($extension, $imgExtArr)){
|
||||
echo 'images';
|
||||
} elseif(in_array($extension, ['xls','xlsx'])) {
|
||||
echo 'excel';
|
||||
} else {
|
||||
echo 'word';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('app_info'))
|
||||
{
|
||||
/**
|
||||
* Retrieves the website configuration for the specified name.
|
||||
*
|
||||
* @param string $name The name of the website.
|
||||
* @throws \Some_Exception_Class Description of the exception that can be thrown.
|
||||
* @return mixed The website configuration.
|
||||
*/
|
||||
function app_info($name)
|
||||
{
|
||||
$websiteConfiguration = \App\Models\Website::where('name', $name)->first()->value;
|
||||
return $websiteConfiguration;
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('insertBobot'))
|
||||
{
|
||||
function insertBobot($a, $b, $c)
|
||||
{
|
||||
$table = 'tbl_analisa_kriteria';
|
||||
$exec = \DB::table($table)->insert([
|
||||
'kriteria_pertama' => $a,
|
||||
'nilai_analisa_kriteria' => $b,
|
||||
'hasil_analisa_kriteria' => 0,
|
||||
'kriteria_kedua' => $c,
|
||||
]);
|
||||
|
||||
if($exec) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('insertBobotKriteria'))
|
||||
{
|
||||
function insertBobotKriteria($a, $b)
|
||||
{
|
||||
$exec = \DB::raw("UPDATE tbl_data_kriteria SET jumlah_kriteria = '$a' WHERE id_kriteria = '$b'");
|
||||
if($exec) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('updateBobotKriteria'))
|
||||
{
|
||||
function updateBobotKriteria($a, $b)
|
||||
{
|
||||
$exec = \DB::raw("UPDATE tbl_data_kriteria SET bobot_kriteria = '$a' WHERE id_kriteria = '$b'");
|
||||
if($exec) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('updateBobot'))
|
||||
{
|
||||
function updateBobot($a, $b, $c)
|
||||
{
|
||||
$exec = \DB::raw("UPDATE tbl_analisa_kriteria SET nilai_analisa_kriteria = '$b' WHERE kriteria_pertama = '$a' and kriteria_kedua = '$c'");
|
||||
if($exec) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!function_exists('insert'))
|
||||
{
|
||||
/**
|
||||
* Inserts data into the database.
|
||||
*
|
||||
* @param string $table The name of the table to insert into.
|
||||
* @param array $data The data to insert.
|
||||
* @throws \Some_Exception_Class Description of the exception that can be thrown.
|
||||
* @return void
|
||||
*/
|
||||
function insert($a, $b, $c, $d)
|
||||
{
|
||||
$table = 'tbl_analisa_alternatif';
|
||||
$exec = \DB::table($table)->insert([
|
||||
'alternatif_pertama' => $a,
|
||||
'nilai_analisa_alternatif' => $b,
|
||||
'alternatif_kedua' => $c,
|
||||
'id_kriteria' => $d,
|
||||
]);
|
||||
|
||||
if($exec) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('insert2'))
|
||||
{
|
||||
function insert2($a,$b,$c,$d){
|
||||
|
||||
$query = "update tbl_analisa_alternatif set hasil_analisa_alternatif = '$a' where alternatif_pertama = '$b' and alternatif_kedua = '$c' and id_kriteria='$d'";
|
||||
$exec = \DB::raw($query);
|
||||
|
||||
if($exec) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('insert4'))
|
||||
{
|
||||
function insert4($a,$b,$c){
|
||||
|
||||
$query = "update tbl_analisa_alternatif set skor_alt_kri='$a' where id_alternatif='$b' and id_kriteria='$c'";
|
||||
$exec = \DB::raw($query);
|
||||
|
||||
if($exec) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('readAll1'))
|
||||
{
|
||||
function readAll1($a, $b, $c){
|
||||
|
||||
$query = "SELECT * FROM tbl_analisa_alternatif where alternatif_pertama = '$a' and alternatif_kedua = '$b' and id_kriteria='$c' LIMIT 0,1";
|
||||
$exec = \DB::table('tbl_analisa_alternatif')->where('alternatif_pertama', $a)->where('alternatif_kedua', $b)->where('id_kriteria', $c)->first();
|
||||
if($exec) {
|
||||
return $exec->nilai_analisa_alternatif;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('readAvg'))
|
||||
{
|
||||
function readAvg($a){
|
||||
|
||||
$exec = \DB::table('tbl_analisa_alternatif')->where('alternatif_pertama', $a)->avg('nilai_analisa_alternatif');
|
||||
if($exec) {
|
||||
return $exec;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('update'))
|
||||
{
|
||||
/**
|
||||
* Updates data in the database.
|
||||
*
|
||||
* @param string $table The name of the table to update.
|
||||
* @param array $data The data to update.
|
||||
* @param string $where The condition to update.
|
||||
* @throws \Some_Exception_Class Description of the exception that can be thrown.
|
||||
* @return void
|
||||
*/
|
||||
function update($a, $b, $c, $d)
|
||||
{
|
||||
$exec = \DB::raw("UPDATE tbl_analisa_alternatif SET nilai_analisa_alternatif = '$b' WHERE alternatif_pertama = '$a' and alternatif_kedua = '$c' and id_kriteria = '$d'");
|
||||
if($exec) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('app_smtp_info'))
|
||||
{
|
||||
/**
|
||||
* Retrieves the website configuration for the specified name.
|
||||
*
|
||||
* @param string $name The name of the website.
|
||||
* @throws \Some_Exception_Class Description of the exception that can be thrown.
|
||||
* @return mixed The website configuration.
|
||||
*/
|
||||
function app_smtp_info()
|
||||
{
|
||||
$mailConfiguration = \App\Models\Mail::find(1)->first();
|
||||
return $mailConfiguration;
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('hasExpired'))
|
||||
{
|
||||
/**
|
||||
* Determines if the given date has expired.
|
||||
*
|
||||
* @param string $date The date to check.
|
||||
* @return bool True if the date has expired, false otherwise.
|
||||
*/
|
||||
function hasExpired($accountCreatedAt)
|
||||
{
|
||||
// Konversi tanggal pembuatan akun menjadi objek DateTime
|
||||
$accountCreatedTime = new DateTime($accountCreatedAt);
|
||||
$currentTime = new DateTime();
|
||||
|
||||
// Hitung selisih waktu antara tanggal pembuatan akun dan waktu saat ini
|
||||
$interval = $accountCreatedTime->diff($currentTime);
|
||||
|
||||
// Periksa jika selisih waktu lebih dari atau sama dengan 60 menit (3600 detik)
|
||||
return $interval->format('%i') >= 60;
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('checkExpired'))
|
||||
{
|
||||
function checkExpired($createdAt, $isExpired)
|
||||
{
|
||||
$givenDate = new DateTime($createdAt);
|
||||
$currentDate = new DateTime();
|
||||
|
||||
// Add 3 days to the current date
|
||||
$currentDate->modify('+3 days');
|
||||
// Compare the given date timestamp with the current date + 3 days timestamp
|
||||
$isExpired = $givenDate > $currentDate;
|
||||
return $isExpired;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an application URL.
|
||||
*
|
||||
* @param string $url The URL to append to the application URL.
|
||||
* @return string The generated application URL.
|
||||
*/
|
||||
if (!function_exists('app_url')) {
|
||||
function app_url($url)
|
||||
{
|
||||
return url('app/' . $url);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('site_url')) {
|
||||
function site_url($type, $url)
|
||||
{
|
||||
switch($type)
|
||||
{
|
||||
case 'user':
|
||||
return url('user/' . $url);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('removeUrlPrefix')) {
|
||||
function removeUrlPrefix($url)
|
||||
{
|
||||
$url = preg_replace('#^https?://#', '', $url);
|
||||
// Remove www. prefix
|
||||
$url = preg_replace('#^www\.#', '', $url);
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('invoiceGenerator')) {
|
||||
function invoiceGenerator()
|
||||
{
|
||||
$characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
||||
$randomString = '';
|
||||
for ($i = 0; $i < 8; $i++) {
|
||||
$randomString .= $characters[rand(0, strlen($characters) - 1)];
|
||||
}
|
||||
// Membuat invoice dengan format INV-{timestamp}-{karakter-acak}
|
||||
$invoice = 'INV-' . time() . '-' . $randomString;
|
||||
return $invoice;
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('virtual_gateway')) {
|
||||
function virtual_gateway($data)
|
||||
{
|
||||
$merchantCode = app_info('duitku_merchant');
|
||||
$apiKey = app_info('duitku_client');
|
||||
|
||||
$paymentAmount = $data['amount'];
|
||||
$merchantOrderId = $data['invoice'];
|
||||
$productDetails = 'Pembayaran Deposit Saldo mengggunakan Duitku';
|
||||
$email = user()->email;
|
||||
$phoneNumber = '';
|
||||
$additionalParam = '';
|
||||
$merchantUserInfo = '';
|
||||
$customerVaName = user()->name;
|
||||
$callbackUrl = site_url('user', 'payment/deposit/callback');
|
||||
$returnUrl = site_url('user', 'payment/deposit/return');
|
||||
$expiryPeriod = 1440;
|
||||
$signature = md5($merchantCode . $merchantOrderId . $paymentAmount . $apiKey);
|
||||
|
||||
// Customer Detail
|
||||
$firstName = 'DEPA';
|
||||
$lastName = 'Auto Deposit';
|
||||
$alamat = "Jl. Jakarta";
|
||||
$city = "Jakarta";
|
||||
$postalCode = "11530";
|
||||
$countryCode = "ID";
|
||||
|
||||
$address = array(
|
||||
'firstName' => $firstName,
|
||||
'lastName' => $lastName,
|
||||
'address' => $alamat,
|
||||
'city' => $city,
|
||||
'postalCode' => $postalCode,
|
||||
'phone' => $phoneNumber,
|
||||
'countryCode' => $countryCode
|
||||
);
|
||||
|
||||
$customerDetail = array(
|
||||
'firstName' => $firstName,
|
||||
'lastName' => $lastName,
|
||||
'email' => $email,
|
||||
'phoneNumber' => $phoneNumber,
|
||||
'billingAddress' => $address,
|
||||
'shippingAddress' => $address
|
||||
);
|
||||
|
||||
$item1 = array(
|
||||
'name' => 'Deposit Saldo POSTAMU',
|
||||
'price' => $data['amount'],
|
||||
'quantity' => 1
|
||||
);
|
||||
|
||||
$itemDetails = array($item1);
|
||||
$params = array(
|
||||
'merchantCode' => $merchantCode,
|
||||
'paymentAmount' => $paymentAmount,
|
||||
'paymentMethod' => $data['method'],
|
||||
'merchantOrderId' => $merchantOrderId,
|
||||
'productDetails' => $productDetails,
|
||||
'additionalParam' => $additionalParam,
|
||||
'merchantUserInfo' => $merchantUserInfo,
|
||||
'customerVaName' => $customerVaName,
|
||||
'email' => $email,
|
||||
'phoneNumber' => $phoneNumber,
|
||||
// 'accountLink' => $accountLink,
|
||||
'itemDetails' => $itemDetails,
|
||||
'customerDetail' => $customerDetail,
|
||||
'callbackUrl' => $callbackUrl,
|
||||
'returnUrl' => $returnUrl,
|
||||
'signature' => $signature,
|
||||
'expiryPeriod' => $expiryPeriod
|
||||
);
|
||||
|
||||
$params_string = json_encode($params);
|
||||
|
||||
if(app_info('duitku_sandbox') == 1) {
|
||||
$url = 'https://sandbox.duitku.com/webapi/api/merchant/v2/inquiry'; // Sandbox
|
||||
} else {
|
||||
$url = 'https://passport.duitku.com/webapi/api/merchant/v2/inquiry'; // Production
|
||||
}
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $params_string);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($params_string))
|
||||
);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
|
||||
//execute post
|
||||
$request = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
if($httpCode == 200) {
|
||||
$result = json_decode($request, true);
|
||||
return [
|
||||
'url' => $result['paymentUrl'],
|
||||
'status' => 'success'
|
||||
];
|
||||
} else {
|
||||
$result = json_decode($request, true);
|
||||
return [
|
||||
'msg' => 'Terjadi kesalahan tidak terduga.',
|
||||
'status' => 'error',
|
||||
'error' => $result
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('isUrlSecure')) {
|
||||
function isUrlSecure($url)
|
||||
{
|
||||
return strpos($url, 'https://') !== false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!function_exists('filterExists')) {
|
||||
function filterExists()
|
||||
{
|
||||
if(!empty(\Illuminate\Support\Facades\Request::input('filterType'))
|
||||
|| !empty(\Illuminate\Support\Facades\Request::input('categoryFilter'))
|
||||
|| !empty(\Illuminate\Support\Facades\Request::input('minimumPrice'))
|
||||
|| !empty(\Illuminate\Support\Facades\Request::input('maximumPrice'))
|
||||
|| !empty(\Illuminate\Support\Facades\Request::input('searchFilter'))) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('date_formatting')) {
|
||||
function date_formatting($date, $format)
|
||||
{
|
||||
switch($format)
|
||||
{
|
||||
case 'd-m-Y':
|
||||
return date('d-m-Y', strtotime($date));
|
||||
break;
|
||||
|
||||
case 'indonesia':
|
||||
$month = array (
|
||||
1 => 'Januari',
|
||||
'Februari',
|
||||
'Maret',
|
||||
'April',
|
||||
'Mei',
|
||||
'Juni',
|
||||
'Juli',
|
||||
'Agustus',
|
||||
'September',
|
||||
'Oktober',
|
||||
'November',
|
||||
'Desember'
|
||||
);
|
||||
$reformat = explode('-', $date);
|
||||
return $reformat[2] . ' ' . $month[ (int)$reformat[1] ] . ' ' . $reformat[0];
|
||||
break;
|
||||
|
||||
case 'timeago':
|
||||
$time_difference = time() - strtotime($date);
|
||||
if( $time_difference < 1 ) { return '1 detik yang lalu'; }
|
||||
$condition = array( 12 * 30 * 24 * 60 * 60 => 'year',
|
||||
30 * 24 * 60 * 60 => 'bulan',
|
||||
24 * 60 * 60 => 'hari',
|
||||
60 * 60 => 'jam',
|
||||
60 => 'menit',
|
||||
1 => 'detik'
|
||||
);
|
||||
|
||||
foreach( $condition as $secs => $str )
|
||||
{
|
||||
$d = $time_difference / $secs;
|
||||
if( $d >= 1 )
|
||||
{
|
||||
$t = round( $d );
|
||||
return $t . ' ' . $str . ( $t > 1 ? '' : '' ) . ' yang lalu';
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('findUser')) {
|
||||
function findUser($id)
|
||||
{
|
||||
return \App\Models\User::find($id)->first();
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('switch_page')) {
|
||||
function switch_page()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('isSeller')) {
|
||||
function isSeller()
|
||||
{
|
||||
$checkUserModel = \App\Models\Seller::where('user_id', \Illuminate\Support\Facades\Auth::user()->id)->count();
|
||||
if($checkUserModel > 0){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('active_page')) {
|
||||
function active_page($activePage)
|
||||
{
|
||||
$currentRoute = \Illuminate\Support\Facades\Route::currentRouteName();
|
||||
if ($currentRoute) {
|
||||
$routeUri = htmlspecialchars($currentRoute);
|
||||
if($routeUri === $activePage) { return 'active'; }
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('routesAll')) {
|
||||
function routesAll()
|
||||
{
|
||||
$routesInAppPrefix = [];
|
||||
foreach (\Illuminate\Support\Facades\Route::getRoutes() as $route) {
|
||||
$uri = $route->uri();
|
||||
|
||||
// Check if the route URI starts with the desired prefix
|
||||
if (strpos($uri, 'app/') === 0) {
|
||||
$routesInAppPrefix[] = $route->action['as'];
|
||||
}
|
||||
}
|
||||
|
||||
$convertIntoJson = json_encode($routesInAppPrefix, true);
|
||||
return json_decode($convertIntoJson, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the currently authenticated user.
|
||||
*
|
||||
* @return User The currently authenticated user.
|
||||
*/
|
||||
if (!function_exists('user')) {
|
||||
function user()
|
||||
{
|
||||
return \Illuminate\Support\Facades\Auth::user();
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('segment')) {
|
||||
/**
|
||||
* Retrieves a segment from the current request.
|
||||
*
|
||||
* @param int $key The key of the segment to retrieve.
|
||||
* @return mixed The value of the segment.
|
||||
*/
|
||||
function segment($key)
|
||||
{
|
||||
return request()->segment($key);
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('enum')) {
|
||||
/**
|
||||
* Retrieves the value of a constant from the GlobalEnum class.
|
||||
*
|
||||
* @param string $args The name of the constant to retrieve.
|
||||
* @return mixed The value of the constant.
|
||||
*/
|
||||
function enum($args)
|
||||
{
|
||||
return constant("\App\Enums\GlobalEnum::$args");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a Gravatar URL for a given email.
|
||||
*
|
||||
* @param string $email The email address to generate the Gravatar URL for.
|
||||
* @throws None
|
||||
* @return string The Gravatar URL.
|
||||
*/
|
||||
if (!function_exists('gravatar_team')) {
|
||||
function gravatar_team($email)
|
||||
{
|
||||
$username = md5($email);
|
||||
return "https://www.gravatar.com/avatar/$username?s=70&d=retro&r=y";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a number into Indonesian Rupiah format.
|
||||
*
|
||||
* @param int $nominal The number to be converted.
|
||||
* @return string The converted number in Indonesian Rupiah format.
|
||||
*/
|
||||
if (!function_exists('rupiah')) {
|
||||
function rupiah($nominal)
|
||||
{
|
||||
return 'Rp. ' . number_format($nominal,0,',','.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A function that changes the given nominal value into a different format.
|
||||
*
|
||||
* @param string $nominal The nominal value to be changed.
|
||||
* @return string The changed nominal value.
|
||||
*/
|
||||
if (!function_exists('rupiah_changer')) {
|
||||
function rupiah_changer($nominal)
|
||||
{
|
||||
if(strlen($nominal) == 4) {
|
||||
return substr($nominal, 0, 1) . 'RB';
|
||||
} elseif(strlen($nominal) == 5) {
|
||||
return substr($nominal, 0, 2) . 'RB';
|
||||
} elseif(strlen($nominal) == 6) {
|
||||
return substr($nominal, 0, 3) . 'RB';
|
||||
} elseif(strlen($nominal) == 7) {
|
||||
return substr($nominal, 0, 1) . 'JT';
|
||||
} elseif(strlen($nominal) == 8) {
|
||||
return substr($nominal, 0, 2) . 'JT';
|
||||
} elseif(strlen($nominal) == 9) {
|
||||
return substr($nominal, 0, 3) . 'JT';
|
||||
} elseif(strlen($nominal) == 10) {
|
||||
return substr($nominal, 0, 1) . 'M';
|
||||
} elseif(strlen($nominal) == 11) {
|
||||
return substr($nominal, 0, 2) . 'M';
|
||||
} elseif(strlen($nominal) == 12) {
|
||||
return substr($nominal, 0, 3) . 'M';
|
||||
} elseif(strlen($nominal) == 13) {
|
||||
return substr($nominal, 0, 1) . 'T';
|
||||
} elseif(strlen($nominal) == 14) {
|
||||
return substr($nominal, 0, 2) . 'T';
|
||||
} elseif(strlen($nominal) == 15) {
|
||||
return substr($nominal, 0, 3) . 'T';
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Formats a phone number.
|
||||
*
|
||||
* @param string $value The phone number to be formatted.
|
||||
* @return string The formatted phone number.
|
||||
*/
|
||||
if (!function_exists('phone_formatter')) {
|
||||
function phone_formatter($value) {
|
||||
// kadang ada penulisan no hp 0811 239 345
|
||||
$nohp = str_replace(" ","",$value);
|
||||
// kadang ada penulisan no hp (0274) 778787
|
||||
$nohp = str_replace("(","",$value);
|
||||
// kadang ada penulisan no hp (0274) 778787
|
||||
$nohp = str_replace(")","",$value);
|
||||
// kadang ada penulisan no hp 0811.239.345
|
||||
$nohp = str_replace(".","",$value);
|
||||
|
||||
// cek apakah no hp mengandung karakter + dan 0-9
|
||||
if(!preg_match('/[^+0-9]/',trim($nohp))){
|
||||
// cek apakah no hp karakter 1-3 adalah +62
|
||||
if(substr(trim($nohp), 0, 3)=='+62'){
|
||||
$hp = trim($nohp);
|
||||
}
|
||||
// cek apakah no hp karakter 1 adalah 0
|
||||
elseif(substr(trim($nohp), 0, 1)=='0'){
|
||||
$hp = '+62'.substr(trim($nohp), 1);
|
||||
}
|
||||
}
|
||||
return $hp;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Retrieves the value of the specified website name from the database.
|
||||
*
|
||||
* @param string $name The name of the website.
|
||||
* @throws Exception If the website does not exist.
|
||||
* @return mixed The value of the website.
|
||||
*/
|
||||
if (!function_exists('frontend_db')) {
|
||||
function frontend_db($name)
|
||||
{
|
||||
return \App\Models\Website::where('name', $name)->first()->value;
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('app_url')) {
|
||||
function app_url($name)
|
||||
{
|
||||
return url('app' . $name);
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('assets_url')) {
|
||||
function assets_url($name)
|
||||
{
|
||||
$image = str_replace('public/', '', $name);
|
||||
return asset('storage/' . $image);
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('frontend')) {
|
||||
function frontend($var)
|
||||
{
|
||||
return asset('frontend/' . $var);
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('pages')) {
|
||||
function pages($var)
|
||||
{
|
||||
return asset('landing/' . $var);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a SweetAlert popup based on the given type and message.
|
||||
*
|
||||
* @param string $type The type of the alert (e.g., 'danger', 'success').
|
||||
* @param string $msg The message to be displayed in the alert.
|
||||
* @return string The generated JavaScript code for the SweetAlert popup.
|
||||
*/
|
||||
if (!function_exists('swal_alert')) {
|
||||
function swal_alert($type, $msg)
|
||||
{
|
||||
switch($type)
|
||||
{
|
||||
case 'error':
|
||||
return "
|
||||
<script>
|
||||
Swal.fire(
|
||||
'Woops..',
|
||||
'$msg',
|
||||
'error'
|
||||
)
|
||||
</script>
|
||||
";
|
||||
break;
|
||||
|
||||
case 'success':
|
||||
return "
|
||||
<script>
|
||||
Swal.fire(
|
||||
'Success',
|
||||
'$msg',
|
||||
'success'
|
||||
)
|
||||
</script>
|
||||
";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the "swal" session value.
|
||||
*
|
||||
* @return mixed The value of the "swal" session.
|
||||
*/
|
||||
if (!function_exists('swal_response')) {
|
||||
function swal_response()
|
||||
{
|
||||
if(session()->has('swal')) {
|
||||
return session('swal');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class MailerHelper
|
||||
{
|
||||
/**
|
||||
* Sends an email to the specified email address.
|
||||
*
|
||||
* @param string $email The email address to send the email to.
|
||||
* @param bool $plain Whether to send the email as plain text or not.
|
||||
* @param string|null $view The view to use for the email content.
|
||||
* @param array $data Additional data to pass to the email view.
|
||||
* @throws \Exception If an error occurs while sending the email.
|
||||
* @return bool Whether the email was sent successfully or not.
|
||||
*/
|
||||
public static function to($recipientEmail, $plain = false, $view = null, $data = [])
|
||||
{
|
||||
$message = $data['message'];
|
||||
$subject = $data['subject'];
|
||||
switch($plain)
|
||||
{
|
||||
case true:
|
||||
try {
|
||||
Mail::raw($message, function ($message) use ($recipientEmail, $subject) {
|
||||
$message->to($recipientEmail)->subject($subject);
|
||||
});
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case false;
|
||||
try {
|
||||
Mail::send($view, ['data' => $data], function ($message) use ($recipientEmail, $subject) {
|
||||
$message->to($recipientEmail)
|
||||
->subject($subject);
|
||||
});
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Enums\GlobalEnum;
|
||||
use DataTables;
|
||||
|
||||
class AdminController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function activity()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use DataTables;
|
||||
use GuzzleHttp\Client;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use App\Models\Alternatif;
|
||||
|
||||
class AlternatifController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
if ($request->ajax()) {
|
||||
$data = Alternatif::select('*');
|
||||
// Convert the Eloquent Collection to a regular PHP array
|
||||
$data->each(function ($item, $key) {
|
||||
$item->rowIndex = $key + 1;
|
||||
});
|
||||
|
||||
return Datatables::of($data)
|
||||
->addIndexColumn()
|
||||
->addColumn('register', function ($row) {
|
||||
return $row->agen->name;
|
||||
})
|
||||
->rawColumns(['register'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'subtitle' => 'Nasabah',
|
||||
'button' => true,
|
||||
'module' => [
|
||||
'url' => route('alternatif.print'),
|
||||
'name' => 'Print Out'
|
||||
]
|
||||
];
|
||||
|
||||
return view('admin.app.content.alternatif.index', compact('data'));
|
||||
}
|
||||
|
||||
public function print()
|
||||
{
|
||||
$nasabah = Alternatif::all();
|
||||
return view('admin.app.content.alternatif.print', compact('nasabah'));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use DataTables;
|
||||
|
||||
use App\Enums\GlobalEnum as Status;
|
||||
use App\Models\User;
|
||||
use App\Models\LogActivites;
|
||||
|
||||
use App\Models\Alternatif;
|
||||
use App\Models\Kriteria;
|
||||
use App\Models\Subkriteria;
|
||||
use App\Models\PengajuanNasabah;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$data = [
|
||||
'subtitle' => 'Halaman Utama',
|
||||
];
|
||||
|
||||
$alternatif = Alternatif::count();
|
||||
$kriteria = Kriteria::count();
|
||||
$subkriteria = Subkriteria::count();
|
||||
$pengajuanDiterima = PengajuanNasabah::where('status', 1)->count();
|
||||
$pengajuanMenunggu = PengajuanNasabah::where('status', 0)->count();
|
||||
$pengajuanDitolak = PengajuanNasabah::where('status', 2)->count();
|
||||
$pengajuanNasabah = PengajuanNasabah::all();
|
||||
$accountOfficer = User::where('level', 2)->count();
|
||||
|
||||
return view('admin.app.dashboard.index', compact('data', 'alternatif', 'kriteria', 'subkriteria', 'pengajuanDiterima', 'pengajuanMenunggu', 'pengajuanDitolak', 'pengajuanNasabah', 'accountOfficer'));
|
||||
}
|
||||
|
||||
public function profile()
|
||||
{
|
||||
$data = [
|
||||
'subtitle' => 'Akun anda',
|
||||
];
|
||||
|
||||
return view('admin.app.users.setting', compact('data'));
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
$id = user()->id;
|
||||
$validator = Validator::make($request->all(), [
|
||||
'name' => 'required',
|
||||
'email' => 'required',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect()->back()->withErrors($validator)->withInput();
|
||||
}
|
||||
|
||||
$input = $request->all();
|
||||
$findUser = User::find($id);
|
||||
|
||||
if($findUser) {
|
||||
// update data
|
||||
$findUser->name = $input['name'];
|
||||
$findUser->email = $input['email'];
|
||||
if(!empty($input['password'])) {
|
||||
$findUser->password = bcrypt($input['password']);
|
||||
}
|
||||
|
||||
// save data
|
||||
$findUser->save();
|
||||
return redirect()->back()->with('success', 'Data berhasil disimpan');
|
||||
} else {
|
||||
return redirect()->back()->with('success', 'Tidak ditemukan data!');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use DataTables;
|
||||
use GuzzleHttp\Client;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class HasilController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$data = [
|
||||
'subtitle' => 'Hasil Perhitungan Nilai',
|
||||
];
|
||||
|
||||
return view('admin.app.content.hasil.index', compact('data'));
|
||||
}
|
||||
|
||||
public function laporan()
|
||||
{
|
||||
$data = [
|
||||
'subtitle' => 'Laporan Data Akhir',
|
||||
];
|
||||
|
||||
return view('admin.app.content.hasil.laporan', compact('data'));
|
||||
}
|
||||
|
||||
public function print(Request $request)
|
||||
{
|
||||
$data = $request->all();
|
||||
if(empty($request->input('kategori')))
|
||||
{
|
||||
return redirect()->back()->with('error', 'Pilih Kategori Terlebih Dahulu');
|
||||
} else {
|
||||
$kategori = $request->input('kategori');
|
||||
switch($kategori) {
|
||||
case 'semua_nasabah':
|
||||
return view('admin.app.content.hasil.data.nasabah');
|
||||
break;
|
||||
case 'nasabah':
|
||||
$nasabah = \App\Models\Alternatif::where('nama_alternatif', 'LIKE', '%' . $request->input('name') . '%')->first();
|
||||
if(!$nasabah) {
|
||||
return redirect()->back()->with('error', 'Nasabah Tidak ditemukan');
|
||||
}
|
||||
|
||||
return view('admin.app.content.hasil.data.single_nasabah', compact('nasabah'));
|
||||
break;
|
||||
case 'ao':
|
||||
$ao = \App\Models\User::where('name', 'LIKE', '%' . $request->input('name') . '%')->first();
|
||||
if(!$ao) {
|
||||
return redirect()->back()->with('error', 'AO Tidak ditemukan');
|
||||
}
|
||||
|
||||
return view('admin.app.content.hasil.data.single_ao', compact('ao'));
|
||||
break;
|
||||
case 'semua_ao':
|
||||
return view('admin.app.content.hasil.data.ao');
|
||||
break;
|
||||
case 'rekomendasi':
|
||||
return view('admin.app.content.hasil.data.rekomendasi');
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,146 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
// other module binding
|
||||
use App\Enums\GlobalEnum as Status;
|
||||
|
||||
// model binding
|
||||
use Modules\User\Entities\OrderModel as Order;
|
||||
use Modules\User\Entities\ReviewModel as Reviews;
|
||||
use Modules\Seller\Entities\SitesModel as Sites;
|
||||
use Modules\Seller\Entities\AccountModel as Account;
|
||||
use App\Models\Content;
|
||||
use App\Models\Pages;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$data = [
|
||||
'subtitle' => 'Platform Jual-Beli Backlink dan Content Writer'
|
||||
];
|
||||
|
||||
// additional binding items
|
||||
$getAllReview = Order::where('is_status', Status::isOrderCompleted)->select('id', 'buy_id', 'sell_id', 'last_buyer_message')->get();
|
||||
$getAllPost = Content::where('is_status', Status::isPostPublished)->select('*')->get();
|
||||
|
||||
return view('landing.index', compact('data', 'getAllReview', 'getAllPost'));
|
||||
}
|
||||
|
||||
public function closeGuide()
|
||||
{
|
||||
if(user()->is_close_guide != null)
|
||||
{
|
||||
$account = new Account();
|
||||
$account->is_close_guide = 1;
|
||||
$account->save();
|
||||
echo 'sudah update';
|
||||
}
|
||||
}
|
||||
|
||||
public function howToSell()
|
||||
{
|
||||
$data = [
|
||||
'subtitle' => 'Jual Backlink dan Layanan Konten'
|
||||
];
|
||||
|
||||
return view('landing.market.sell', compact('data'));
|
||||
}
|
||||
|
||||
public function market()
|
||||
{
|
||||
$data = [
|
||||
'subtitle' => 'Beli Backlink maupun Situs'
|
||||
];
|
||||
|
||||
return view('landing.market.listing', compact('data'));
|
||||
}
|
||||
|
||||
public function productDetail($uuid)
|
||||
{
|
||||
$sites = Sites::find($uuid);
|
||||
|
||||
if($sites) {
|
||||
$data = [
|
||||
'subtitle' => 'Tentang Situs ' . removeUrlPrefix($sites->url)
|
||||
];
|
||||
|
||||
$getAllReviews = Reviews::where('website_id', $sites->id)->where('review', '!=', 'Auto rated by system')->orderBy('created_at', 'desc')->limit(5)->get();
|
||||
|
||||
return view('landing.market.detail', compact('data', 'sites', 'getAllReviews'));
|
||||
} else {
|
||||
return redirect()->route('marketplace')->with('swal', swal_alert('error', 'Tidak ditemukan data produk...'));
|
||||
}
|
||||
}
|
||||
|
||||
public function userDetail($uuid)
|
||||
{
|
||||
$users = Sites::find($uuid);
|
||||
|
||||
if($users) {
|
||||
$data = [
|
||||
'subtitle' => 'Tentang ' . $users->name
|
||||
];
|
||||
|
||||
return view('landing.market.detailUser', compact('data', 'users'));
|
||||
} else {
|
||||
return redirect()->route('marketplace')->with('swal', swal_alert('error', 'Tidak ditemukan data produk...'));
|
||||
}
|
||||
}
|
||||
|
||||
public function pages($slug)
|
||||
{
|
||||
$pages = Pages::where('slug', $slug)->first();
|
||||
|
||||
if($pages) {
|
||||
$data = [
|
||||
'subtitle' => $pages->title
|
||||
];
|
||||
|
||||
return view('landing.pages.detail', compact('data', 'pages'));
|
||||
} else {
|
||||
return redirect()->route('landing')->with('swal', swal_alert('error', 'Tidak ditemukan laman...'));
|
||||
}
|
||||
}
|
||||
|
||||
public function about()
|
||||
{
|
||||
$data = [
|
||||
'subtitle' => 'Tentang Kami'
|
||||
];
|
||||
|
||||
return view('landing.about', compact('data'));
|
||||
}
|
||||
|
||||
public function blog()
|
||||
{
|
||||
$data = [
|
||||
'subtitle' => 'Informasi'
|
||||
];
|
||||
|
||||
return view('landing.blog.index', compact('data'));
|
||||
}
|
||||
|
||||
public function blogDetail($slug)
|
||||
{
|
||||
$blog = Content::where('slug', $slug)->first();
|
||||
|
||||
if($blog) {
|
||||
$data = [
|
||||
'subtitle' => 'Detil Informasi'
|
||||
];
|
||||
|
||||
return view('landing.blog.detail', compact('data', 'blog'));
|
||||
} else {
|
||||
return redirect()->route('landing')->with('swal', swal_alert('error', 'Tidak ditemukan laman...'));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,196 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use DataTables;
|
||||
use GuzzleHttp\Client;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use App\Models\Kriteria;
|
||||
use App\Models\Subkriteria;
|
||||
use App\Models\Nilai;
|
||||
|
||||
class KriteriaController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
if ($request->ajax()) {
|
||||
$data = Kriteria::select('*');
|
||||
// Convert the Eloquent Collection to a regular PHP array
|
||||
$data->each(function ($item, $key) {
|
||||
$item->rowIndex = $key + 1;
|
||||
});
|
||||
|
||||
return Datatables::of($data)
|
||||
->addIndexColumn()
|
||||
->addColumn('title-post', function ($row) {
|
||||
$text = '
|
||||
<p class="mb-0">' . $row->gejala . '</p>
|
||||
';
|
||||
return $text;
|
||||
})
|
||||
->rawColumns(['title-post'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'subtitle' => 'Kriteria',
|
||||
'button' => true,
|
||||
'module' => [
|
||||
'url' => route('kriteria.create'),
|
||||
'name' => 'Tambah Baru'
|
||||
]
|
||||
];
|
||||
|
||||
return view('admin.app.content.kriteria.index', compact('data'));
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$newKodeKriteria = $this->generateKodeKriteria();
|
||||
$data = [
|
||||
'subtitle' => 'Tambah baru',
|
||||
'newKodeKriteria' => $newKodeKriteria,
|
||||
];
|
||||
|
||||
return view('admin.app.content.kriteria.add', compact('data'));
|
||||
}
|
||||
|
||||
// Metode untuk menghasilkan kode kriteria
|
||||
private function generateKodeKriteria()
|
||||
{
|
||||
$lastKriteria = Kriteria::orderBy('id_kriteria', 'desc')->first();
|
||||
$lastNumber = $lastKriteria ? (int)substr($lastKriteria->id_kriteria, 1) : 0;
|
||||
$newNumber = $lastNumber + 1;
|
||||
return 'C' . str_pad($newNumber, 1, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
// 'id_kriteria' => 'required',
|
||||
'nama_kriteria' => 'required',
|
||||
'kategori_kriteria' => 'required',
|
||||
'bobot_kriteria' => 'required',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect()->back()->withInput()->with('error', 'Unexpected error, please try again. code: ' . $validator->errors()->first());
|
||||
}
|
||||
|
||||
// $input = $request->all();
|
||||
// $post = new Kriteria([
|
||||
// 'id_kriteria' => $input['id_kriteria'], // Membersihkan input judul menggunakan Purifier
|
||||
// 'nama_kriteria' => $input['nama_kriteria'], // Membersihkan input deskripsi menggunakan Purifier
|
||||
// 'bobot_kriteria' => $input['bobot_kriteria'], // Membersihkan input deskripsi menggunakan Purifier
|
||||
// 'kriteria_kategori' => $input['kategori_kriteria']
|
||||
$kodeKriteria = $this->generateKodeKriteria();
|
||||
$post = new Kriteria([
|
||||
'id_kriteria' => $kodeKriteria,
|
||||
'nama_kriteria' => $request->input('nama_kriteria'),
|
||||
'bobot_kriteria' => $request->input('bobot_kriteria'),
|
||||
'kriteria_kategori' => $request->input('kriteria_kategori'),
|
||||
]);
|
||||
|
||||
$check = Kriteria::where('id_kriteria', $kodeKriteria)->count();
|
||||
if ($check == 0) {
|
||||
if ($post->save()) {
|
||||
return redirect()->route('kriteria')->with('success', 'You have successfully added data');
|
||||
} else {
|
||||
return redirect()->route('kriteria')->with('error', 'An error occurred in the query');
|
||||
}
|
||||
} else {
|
||||
return redirect()->route('kriteria')->with('error', 'Title already exists');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data = [
|
||||
'subtitle' => 'Edit: ' . Kriteria::where('id_kriteria', $id)->first()->title,
|
||||
];
|
||||
|
||||
$kriteria = Kriteria::FindOrFail($id);
|
||||
$bobot = Nilai::all();
|
||||
|
||||
return view('admin.app.content.kriteria.edit', compact('data', 'kriteria', 'id', 'bobot'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
// Validasi input sebelum memperbarui data
|
||||
$validator = Validator::make($request->all(), [
|
||||
'id_kriteria' => 'required',
|
||||
'nama_kriteria' => 'required',
|
||||
'bobot_kriteria' => 'required',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect()->back()->withInput()->with('error', 'Unexpected error, please try again. code: ' . $validator->errors()->first());
|
||||
}
|
||||
|
||||
// Cari data berdasarkan ID
|
||||
$kriteria = Kriteria::find($id);
|
||||
|
||||
// Jika data ditemukan
|
||||
if ($kriteria) {
|
||||
|
||||
// Update data dengan data baru dari form yang telah dibersihkan
|
||||
$kriteria->id_kriteria = $request->input('id_kriteria');
|
||||
$kriteria->nama_kriteria = $request->input('nama_kriteria');
|
||||
$kriteria->bobot_kriteria = $request->input('bobot_kriteria');
|
||||
// Simpan perubahan pada database
|
||||
$kriteria->save();
|
||||
return redirect()->route('kriteria')->with('success', 'You are successfully added new records');
|
||||
} else {
|
||||
return redirect()->route('kriteria')->with('error', 'Unexpected error');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
// Cari data berdasarkan ID
|
||||
$post = Kriteria::find($id);
|
||||
$subkriteria = Subkriteria::where('kriteria_kode', $post->id_kriteria);
|
||||
// Jika data ditemukan
|
||||
if ($post && $subkriteria) {
|
||||
// Hapus data dari database
|
||||
$post->delete();
|
||||
$subkriteria->delete();
|
||||
return redirect()->route('kriteria')->with('success', 'You are successfully deleted records');
|
||||
} else {
|
||||
return redirect()->route('kriteria')->with('error', 'Data not found');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,267 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
// additional modules
|
||||
use App\Helpers\MailerHelper as Mailers;
|
||||
use App\Enums\GlobalEnum;
|
||||
use App\Models\User;
|
||||
use App\Models\UserManager;
|
||||
use App\Models\LogActivites;
|
||||
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$data = [
|
||||
'title' => 'CMSQ',
|
||||
'subtitle' => 'Login',
|
||||
];
|
||||
|
||||
return view('auth/login', compact('data'));
|
||||
}
|
||||
|
||||
public function proses_login(Request $request)
|
||||
{
|
||||
$credentials = $request->validate([
|
||||
'email' => ['required','email'],
|
||||
'password' => ['required'],
|
||||
]);
|
||||
|
||||
if (Auth::attempt($credentials)) {
|
||||
$user = Auth::user();
|
||||
switch($user->level) {
|
||||
case 1:
|
||||
LogActivites::default([
|
||||
'causedBy' => $user->id,
|
||||
'logType' => GlobalEnum::LogOfLogin,
|
||||
'withContent' => [
|
||||
'status' => 'add',
|
||||
'text' => 'Login as ' . $user->name,
|
||||
'ip_address' => $request->ip(),
|
||||
'user_agent' => $request->userAgent(),
|
||||
'time' => date('Y-m-d H:i:s')
|
||||
]
|
||||
]);
|
||||
return redirect()->intended('app/dashboard');
|
||||
break;
|
||||
case 2:
|
||||
LogActivites::default([
|
||||
'causedBy' => $user->id,
|
||||
'logType' => GlobalEnum::LogOfLogin,
|
||||
'withContent' => [
|
||||
'status' => 'add',
|
||||
'text' => 'Login as ' . $user->name,
|
||||
'ip_address' => $request->ip(),
|
||||
'user_agent' => $request->userAgent(),
|
||||
'time' => date('Y-m-d H:i:s')
|
||||
]
|
||||
]);
|
||||
return redirect()->intended('user');
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
return redirect()->back()->withInput()->with('error', 'Email atau Password salah!');
|
||||
}
|
||||
}
|
||||
|
||||
public function logout(Request $request)
|
||||
{
|
||||
$request->session()->flush();
|
||||
Auth::logout();
|
||||
return redirect('/');
|
||||
}
|
||||
|
||||
public function register()
|
||||
{
|
||||
$data = [
|
||||
'subtitle' => 'Register',
|
||||
];
|
||||
|
||||
return view('auth/register', compact('data'));
|
||||
}
|
||||
|
||||
public function storeRegister(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|string|email|max:255',
|
||||
'password' => 'required|string|min:8',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect()->back()->withErrors($validator)->withInput();
|
||||
}
|
||||
|
||||
$input = $request->all();
|
||||
$userEmailToken = md5(Str::random(25));
|
||||
$user = new User([
|
||||
'name' => $input['name'],
|
||||
'username' => Str::before($input['email'], '@') . rand(100, 999),
|
||||
'email' => $input['email'],
|
||||
'level' => 4,
|
||||
'email_verified_token' => $userEmailToken,
|
||||
'password' => bcrypt($input['password']),
|
||||
'balance' => 0,
|
||||
'phone' => NULL,
|
||||
'income' => 0,
|
||||
'status' => 4
|
||||
]);
|
||||
|
||||
$check = User::where('email', $input['email'])->count();
|
||||
if($check == 0) {
|
||||
$sendEmail = Mailers::to($input['email'], false, 'email.auth.register', [
|
||||
'message' => 'You have been successfully registered! Please check your email to verify your account',
|
||||
'subject' => 'Verify Your Account',
|
||||
'name' => $input['name'],
|
||||
'token' => $userEmailToken
|
||||
]);
|
||||
if($sendEmail) {
|
||||
$user->save();
|
||||
return redirect()->route('login')->with('swal', swal_alert('success', 'Kamu berhasil mendaftar! Silahkan cek email untuk verifikasi akun anda'));
|
||||
} else {
|
||||
return back()->withErrors([
|
||||
'email' => 'Something went wrong!',
|
||||
])->withInput();
|
||||
}
|
||||
} else {
|
||||
return back()->withErrors([
|
||||
'email' => 'Found valid email exists!',
|
||||
])->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
public function verify($token)
|
||||
{
|
||||
$userAccount = User::where('email_verified_token', $token)->first();
|
||||
if($token == null) {
|
||||
return redirect()->route('login')->with('swal', swal_alert('error', 'Token tidak ditemukan!'));
|
||||
} elseif(empty($userAccount) || is_null($userAccount)) {
|
||||
return redirect()->route('login')->with('swal', swal_alert('error', 'Token sudah digunakan!'));
|
||||
} elseif($userAccount->status == 1 || $userAccount->email_verified_at != null) {
|
||||
return redirect()->route('login')->with('swal', swal_alert('error', 'Akun sudah terverifikasi!'));
|
||||
} else {
|
||||
|
||||
// check before update
|
||||
$user = User::find($userAccount->id);
|
||||
$user->email_verified_token = null;
|
||||
$user->email_verified_at = now();
|
||||
$user->status = 1;
|
||||
|
||||
// update
|
||||
$user->save();
|
||||
return redirect()->route('login')->with('swal', swal_alert('success', 'Email telah berhasil diverifikasi, anda dapat menggunakan layanan'));
|
||||
}
|
||||
}
|
||||
|
||||
public function forgot()
|
||||
{
|
||||
$data = [
|
||||
'subtitle' => 'Lupa Kata Sandi',
|
||||
];
|
||||
|
||||
return view('auth/forgot_password', compact('data'));
|
||||
}
|
||||
|
||||
public function forgotPassword(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'email' => 'required|string|email|max:255',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect()->back()->withErrors($validator)->withInput();
|
||||
}
|
||||
|
||||
$input = $request->all();
|
||||
$userEmailToken = md5(Str::random(25));
|
||||
$user = new UserManager([
|
||||
'uuid' => Uuid::uuid4(),
|
||||
'email' => $input['email'],
|
||||
'token' => $userEmailToken,
|
||||
'isUsed' => 0,
|
||||
]);
|
||||
|
||||
$check = User::where('email', $input['email'])->count();
|
||||
$userName = User::where('email', $input['email'])->first()->name;
|
||||
if($check == 1) {
|
||||
$sendEmail = Mailers::to($input['email'], false, 'email.auth.forgot_password', [
|
||||
'message' => 'You have been successfully requested! Please check your email to reset your password',
|
||||
'subject' => 'Forgot Password',
|
||||
'name' => $userName,
|
||||
'token' => $userEmailToken
|
||||
]);
|
||||
if($sendEmail) {
|
||||
$user->save();
|
||||
return redirect()->route('login')->with('success', 'Check your email to reset your password');
|
||||
} else {
|
||||
return back()->with('error', 'Something went wrong!')->withInput();
|
||||
}
|
||||
} else {
|
||||
return back()->with('error', 'Email not found!')->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
public function reset($token)
|
||||
{
|
||||
|
||||
$findTokenByUsed = UserManager::where('token', $token)->first();
|
||||
if($findTokenByUsed->isUsed == 1) {
|
||||
return redirect()->route('login')->with('error', 'Token sudah digunakan!');
|
||||
} elseif(hasExpired($findTokenByUsed->created_at)) {
|
||||
return redirect()->route('login')->with('error', 'Token expired!');
|
||||
}
|
||||
|
||||
$data = [
|
||||
'subtitle' => 'Reset Password',
|
||||
];
|
||||
|
||||
return view('auth/reset_password', compact('data','token'));
|
||||
}
|
||||
|
||||
public function resetPassword(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'password' => 'required|string|min:8',
|
||||
'retype_password' => 'required|string|min:8',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect()->back()->withErrors($validator)->withInput();
|
||||
}
|
||||
|
||||
if($request->password != $request->retype_password) {
|
||||
return redirect()->back()->with('error', 'Password tidak sama!')->withInput();
|
||||
}
|
||||
|
||||
$input = $request->all();
|
||||
$userEmailbyToken = UserManager::where('token', $input['token'])->first();
|
||||
$findUserByEmail = User::where('email', $userEmailbyToken->email)->first();
|
||||
|
||||
// check expired token 60 minutes
|
||||
if(hasExpired($findUserByEmail->created_at)) {
|
||||
return redirect()->route('login')->with('error', 'Token expired!');
|
||||
} else {
|
||||
|
||||
// update password
|
||||
$findUserByEmail->password = bcrypt($input['password']);
|
||||
$findUserByEmail->save();
|
||||
|
||||
// update token
|
||||
$userEmailbyToken->isUsed = 1;
|
||||
$userEmailbyToken->save();
|
||||
|
||||
return redirect()->route('login')->with('success', 'Password has been reset!');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,160 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use App\Models\Pages;
|
||||
use Carbon\Carbon;
|
||||
use DataTables;
|
||||
|
||||
class PageController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
if ($request->ajax()) {
|
||||
$data = Pages::select('*');
|
||||
return Datatables::of($data)
|
||||
->addIndexColumn()
|
||||
->addColumn('title-post', function ($row) {
|
||||
$text = '
|
||||
<p class="mb-0">' . $row->title . '</p>
|
||||
<p class="mb-0 small text-muted">Terakhir diperbarui pada ' . date_formatting(Carbon::parse($row->updated_at, 'Y-m-d'), 'timeago') . '</p>
|
||||
';
|
||||
return $text;
|
||||
})
|
||||
->filter(function ($query) {
|
||||
if (request()->has('search')) {
|
||||
$search = strtolower(request()->input('search.value'));
|
||||
$query->where(function ($query) use ($search) {
|
||||
$query->whereRaw('LOWER(tbl_pages.id) LIKE ?', ["%{$search}%"])
|
||||
->orWhereRaw('LOWER(tbl_pages.title) LIKE ?', ["%{$search}%"]);
|
||||
});
|
||||
}
|
||||
})
|
||||
->rawColumns(['title-post'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'subtitle' => 'Laman',
|
||||
'button' => true,
|
||||
'module' => [
|
||||
'url' => route('page.create'),
|
||||
'name' => 'Create New'
|
||||
]
|
||||
];
|
||||
|
||||
return view('admin.app.pages.index', compact('data'));
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$data = [
|
||||
'subtitle' => 'Tambah baru',
|
||||
];
|
||||
|
||||
return view('admin.app.pages.add', compact('data'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'title' => 'required',
|
||||
'description' => 'required',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect()->back()->with('error', 'Unexpected error, please try again')->withInput();
|
||||
}
|
||||
|
||||
$input = $request->all();
|
||||
$titleSlug = Str::slug($input['title']);
|
||||
|
||||
$post = new Pages([
|
||||
'slug' => $titleSlug,
|
||||
'title' => $input['title'], // Membersihkan input judul menggunakan Purifier
|
||||
'description' => $input['description'], // Membersihkan input deskripsi menggunakan Purifier
|
||||
]);
|
||||
|
||||
$check = Pages::where('title', $input['title'])->count();
|
||||
if ($check == 0) {
|
||||
if ($post->save()) {
|
||||
return redirect()->route('page')->with('success', 'You have successfully added data');
|
||||
} else {
|
||||
return redirect()->route('page')->with('error', 'Unexpected error, please try again');
|
||||
}
|
||||
} else {
|
||||
return redirect()->route('page')->with('error', 'Data already exists');
|
||||
}
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$data = [
|
||||
'subtitle' => Pages::where('slug', $id)->first()->title,
|
||||
'records' => Pages::where('slug', $id)->first()
|
||||
];
|
||||
return view('admin.app.pages.detail', compact('data'));
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$data = [
|
||||
'subtitle' => 'Edit: ' . Pages::where('id', $id)->first()->title,
|
||||
'records' => Pages::where('id', $id)->first(),
|
||||
];
|
||||
$posts = Pages::FindOrFail($id);
|
||||
|
||||
return view('admin.app.pages.edit', compact('data', 'posts', 'id'));
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
// Validasi input sebelum memperbarui data
|
||||
$validator = Validator::make($request->all(), [
|
||||
'title' => 'required',
|
||||
'description' => 'required',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect()->back()->withInput()->with('error', 'Unexpected error, please try again');
|
||||
}
|
||||
|
||||
// Cari data berdasarkan ID
|
||||
$post = Pages::find($id);
|
||||
|
||||
// Jika data ditemukan
|
||||
if ($post) {
|
||||
|
||||
// Update data dengan data baru dari form yang telah dibersihkan
|
||||
$post->title = $request->input('title');
|
||||
$post->slug = Str::slug($request->input('title'));;
|
||||
$post->description = $request->input('description');
|
||||
|
||||
// Simpan perubahan pada database
|
||||
$post->save();
|
||||
return redirect()->route('page')->with('success', 'You are successfully modify data');
|
||||
} else {
|
||||
return redirect()->route('page')->with('error', 'Data not found');
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
// Cari data berdasarkan ID
|
||||
$post = Pages::find($id);
|
||||
// Jika data ditemukan
|
||||
if ($post) {
|
||||
// Hapus data dari database
|
||||
$post->delete();
|
||||
return redirect()->route('page')->with('success', 'You are successfully deleted records');
|
||||
} else {
|
||||
return redirect()->route('page')->with('error', 'Data not found');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use DataTables;
|
||||
use GuzzleHttp\Client;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use App\Models\Alternatif;
|
||||
use App\Models\PengajuanNasabah;
|
||||
use App\Models\Nilai;
|
||||
|
||||
class PengajuanController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
if ($request->ajax()) {
|
||||
$data = PengajuanNasabah::select('*');
|
||||
// Convert the Eloquent Collection to a regular PHP array
|
||||
$data->each(function ($item, $key) {
|
||||
$item->rowIndex = $key + 1;
|
||||
});
|
||||
|
||||
return Datatables::of($data)
|
||||
->addIndexColumn()
|
||||
->addColumn('nasabah', function($row){
|
||||
return $row->nasabah->nama_alternatif;
|
||||
})
|
||||
->addColumn('uplink', function($row){
|
||||
return 'aa';
|
||||
})
|
||||
->addColumn('status_pengajuan', function($row){
|
||||
if ($row->status == 1) {
|
||||
return '<span class="mb-1 badge font-medium badge-success py-2 px-3 fs-7">Diterima</span>';
|
||||
} elseif($row->status == 0) {
|
||||
return '<span class="mb-1 badge font-medium badge-primary py-2 px-3 fs-7">Menunggu Respon</span>';
|
||||
} else {
|
||||
return '<span class="mb-1 badge font-medium badge-danger py-2 px-3 fs-7">Tidak diterima</span>';
|
||||
}
|
||||
})
|
||||
->rawColumns(['nasabah', 'uplink', 'status_pengajuan'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'subtitle' => 'Pengajuan Nasabah'
|
||||
];
|
||||
|
||||
return view('admin.app.content.pengajuan.index', compact('data'));
|
||||
}
|
||||
|
||||
public function accept($id)
|
||||
{
|
||||
$pengajuan = PengajuanNasabah::find($id);
|
||||
if($pengajuan) {
|
||||
$pengajuan->status = 1;
|
||||
$pengajuan->save();
|
||||
// $checkNilai = Nilai::where('alternatif_kode', $pengajuan->id_nasabah);
|
||||
// $checkNilai->delete();
|
||||
// $checkNasabah = Alternatif::where('id_alternatif', $pengajuan->id_nasabah);
|
||||
// $checkNasabah->delete();
|
||||
return redirect()->back()->with('success', 'Pengajuan Berhasil di Setujui');
|
||||
} else {
|
||||
return redirect()->back()->with('error', 'Pengajuan Tidak Ditemukan');
|
||||
}
|
||||
}
|
||||
|
||||
public function decline($id)
|
||||
{
|
||||
$pengajuan = PengajuanNasabah::find($id);
|
||||
if($pengajuan) {
|
||||
$pengajuan->status = 2;
|
||||
$pengajuan->save();
|
||||
return redirect()->back()->with('success', 'Pengajuan Berhasil ditolak');
|
||||
} else {
|
||||
return redirect()->back()->with('error', 'Pengajuan Tidak Ditemukan');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,161 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use DataTables;
|
||||
use GuzzleHttp\Client;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use App\Models\Subkriteria;
|
||||
use App\Models\Kriteria;
|
||||
|
||||
class SubkriteriaController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$data = [
|
||||
'subtitle' => 'Sub Kriteria'
|
||||
];
|
||||
|
||||
return view('admin.app.content.subkriteria.index', compact('data'));
|
||||
}
|
||||
|
||||
public function create($from)
|
||||
{
|
||||
$newKodeKriteria = $this->generateKodeKriteria($from);
|
||||
$data = [
|
||||
'subtitle' => 'Tambah baru',
|
||||
'newKodeKriteria' => $newKodeKriteria,
|
||||
];
|
||||
|
||||
$kriteria = Kriteria::all();
|
||||
return view('admin.app.content.subkriteria.add', compact('data', 'kriteria', 'from'));
|
||||
}
|
||||
|
||||
// Metode untuk menghasilkan kode kriteria
|
||||
private function generateKodeKriteria($id_kriteria)
|
||||
{
|
||||
$lastKriteria = SubKriteria::where('kriteria_kode', $id_kriteria)->count();
|
||||
return $id_kriteria . "-" . str_pad($lastKriteria + 1, 1, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'id_kriteria' => 'required',
|
||||
'bobot_kriteria' => 'required',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect()->back()->withInput()->with('error', 'Unexpected error, please try again. code: ' . $validator->errors()->first());
|
||||
}
|
||||
|
||||
$input = $request->all();
|
||||
|
||||
$post = new Subkriteria([
|
||||
'subkriteria_kode' => $input['id_kriteria'], // Membersihkan input judul menggunakan Purifier
|
||||
'kriteria_kode' => $input['kode_kriteria'], // Membersihkan input deskripsi menggunakan Purifier
|
||||
'subkriteria_bobot' => $input['bobot_kriteria'], // Membersihkan input deskripsi menggunakan Purifier,
|
||||
'keterangan' => $input['keterangan']
|
||||
]);
|
||||
|
||||
$check = Subkriteria::where('subkriteria_kode', $input['id_kriteria'])->count();
|
||||
if ($check == 0) {
|
||||
if ($post->save()) {
|
||||
return redirect()->route('subkriteria')->with('success', 'You have successfully added data');
|
||||
} else {
|
||||
return redirect()->route('subkriteria')->with('error', 'An error occurred in the query');
|
||||
}
|
||||
} else {
|
||||
return redirect()->route('subkriteria')->with('error', 'Title already exists');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($from, $id)
|
||||
{
|
||||
$data = [
|
||||
'subtitle' => 'Edit: ' . Subkriteria::where('subkriteria_kode', $id)->first()->title,
|
||||
];
|
||||
|
||||
$subkriteria = Subkriteria::FindOrFail($id);
|
||||
$kriteria = Kriteria::all();
|
||||
return view('admin.app.content.subkriteria.edit', compact('data', 'kriteria', 'id', 'subkriteria', 'from'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
// Validasi input sebelum memperbarui data
|
||||
$validator = Validator::make($request->all(), [
|
||||
'id_kriteria' => 'required',
|
||||
'bobot_kriteria' => 'required',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect()->back()->withInput()->with('error', 'Unexpected error, please try again. code: ' . $validator->errors()->first());
|
||||
}
|
||||
|
||||
// Cari data berdasarkan ID
|
||||
$kriteria = Subkriteria::find($id);
|
||||
|
||||
// Jika data ditemukan
|
||||
if ($kriteria) {
|
||||
|
||||
// Update data dengan data baru dari form yang telah dibersihkan
|
||||
$kriteria->subkriteria_kode = $request->input('id_kriteria');
|
||||
$kriteria->kriteria_kode = $request->input('kode_kriteria');
|
||||
$kriteria->subkriteria_bobot = $request->input('bobot_kriteria');
|
||||
$kriteria->keterangan = $request->input('keterangan');
|
||||
// Simpan perubahan pada database
|
||||
$kriteria->save();
|
||||
|
||||
return redirect()->route('subkriteria')->with('success', 'You are successfully update records');
|
||||
} else {
|
||||
return redirect()->route('subkriteria')->with('error', 'Unexpected error');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
// Cari data berdasarkan ID
|
||||
$post = Subkriteria::find($id);
|
||||
// Jika data ditemukan
|
||||
if ($post) {
|
||||
// Hapus data dari database
|
||||
$post->delete();
|
||||
return redirect()->route('subkriteria')->with('success', 'You are successfully deleted records');
|
||||
} else {
|
||||
return redirect()->route('subkriteria')->with('error', 'Data not found');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,251 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Roles;
|
||||
|
||||
use Modules\Seller\Entities\AccountModel;
|
||||
use App\Enums\GlobalEnum;
|
||||
use App\Models\LogActivites;
|
||||
use App\Models\Seller;
|
||||
use App\Helpers\MailerHelper as Mailers;
|
||||
|
||||
use DataTables;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class UsersController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
if ($request->ajax()) {
|
||||
$data = User::whereIn('level', [1, 2])->orderBy('created_at', 'desc');
|
||||
|
||||
$search = $request->input('search')['value'];
|
||||
if (!empty($search)) {
|
||||
$data->where('status', '=', $search)
|
||||
->orWhere('name', 'LIKE', "%$search%");
|
||||
}
|
||||
|
||||
$data = $data->get();
|
||||
$data->each(function ($item, $key) {
|
||||
$item->rowIndex = $key + 1;
|
||||
});
|
||||
// print_r($request->input('search')['value']);
|
||||
// die();
|
||||
return Datatables::of($data)
|
||||
->addIndexColumn()
|
||||
->addColumn('title-post', function ($row) {
|
||||
return '
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="symbol symbol-25px symbol-circle">
|
||||
<div class="symbol-label" style="background-image:url(' . gravatar_team($row->email) . ')"></div>
|
||||
</div>
|
||||
<div class="ms-3"><span>' . $row->name . '</span></div>
|
||||
</div>
|
||||
';
|
||||
})
|
||||
->addColumn('action', function ($row) {
|
||||
$view = route('users.show', ['id' => $row->id]);
|
||||
$edit = route('users.edit', ['id' => $row->id]);
|
||||
$delete = route('users.delete', ['id' => $row->id]);
|
||||
return '
|
||||
<a href="' . $view . '" class="btn btn-light btn-sm px-4"><i class="ki-outline ki-eye"></i></a>
|
||||
<a href="' . $edit . '" class="btn btn-light btn-sm px-4"><i class="ki-outline ki-pencil"></i></a>
|
||||
<a data-url="' . $delete . '" href="#" class="btn btn-light btn-sm deleteContent px-4"><i class="ki-outline ki-trash"></i></a>
|
||||
';
|
||||
})
|
||||
->addColumn('status', function ($row) {
|
||||
if ($row->status == GlobalEnum::isActive) {
|
||||
return '<span class="mb-1 badge font-medium badge-success py-2 px-3 fs-7">Active</span>';
|
||||
} elseif ($row->status == GlobalEnum::isInactive) {
|
||||
return '<span class="mb-1 badge font-medium badge-primary py-2 px-3 fs-7">Non Active</span>';
|
||||
} elseif ($row->status == GlobalEnum::isDeactive) {
|
||||
return '<span class="mb-1 badge font-medium badge-danger py-2 px-3 fs-7">Deactivated</span>';
|
||||
} else {
|
||||
return '<span class="mb-1 badge font-medium badge-warning py-2 px-3 fs-7">Not Verified</span>';
|
||||
}
|
||||
})
|
||||
->rawColumns(['title-post', 'action', 'status'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'subtitle' => 'Users',
|
||||
'button' => true,
|
||||
'module' => [
|
||||
'url' => route('users.create'),
|
||||
'name' => 'Create New'
|
||||
]
|
||||
];
|
||||
|
||||
return view('admin.app.users.index', compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function create()
|
||||
{
|
||||
$data = [
|
||||
'subtitle' => 'Create New'
|
||||
];
|
||||
|
||||
$roles = Roles::whereIn('id', [1, 2])->get();
|
||||
return view('admin.app.users.add', compact('data', 'roles'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'name' => 'required',
|
||||
'email' => 'required|email',
|
||||
'status' => 'required',
|
||||
'level' => 'required',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect()->back()->withErrors($validator)->withInput();
|
||||
}
|
||||
|
||||
$input = $request->all();
|
||||
$foto_namaBaru = null;
|
||||
$userEmailToken = md5(Str::random(25));
|
||||
|
||||
$post = new User([
|
||||
'name' => $input['name'],
|
||||
'username' => Str::before($input['email'], '@') . rand(100, 999),
|
||||
'email' => $input['email'],
|
||||
'password' => empty($input['password']) ? bcrypt('default123') : bcrypt($input['password']),
|
||||
'status' => $input['status'],
|
||||
'level' => $input['level'],
|
||||
'thumbnail' => empty($foto_namaBaru) ? '' : $foto_namaBaru,
|
||||
]);
|
||||
|
||||
$check = User::where('email', $input['email'])->count();
|
||||
// $insertLog = LogActivites::default([
|
||||
// 'causedBy' => user()->id,
|
||||
// 'logType' => GlobalEnum::LogOfGeneral,
|
||||
// 'withContent' => [
|
||||
// 'status' => 'add',
|
||||
// 'text' => 'Insert a new user with email ' . $input['email'],
|
||||
// ]
|
||||
// ]);
|
||||
if ($check == 0) {
|
||||
$sendEmail = Mailers::to($input['email'], false, 'email.auth.register', [
|
||||
'message' => 'Anda telah berhasil didaftarkan, silahkan catat akun anda',
|
||||
'subject' => 'Pendaftaran Pengguna',
|
||||
'name' => $input['name'],
|
||||
'email' => $input['email'],
|
||||
'password' => empty($input['password']) ? 'default123' : $input['password'],
|
||||
'token' => $userEmailToken
|
||||
]);
|
||||
|
||||
if ($post->save()) {
|
||||
if ($sendEmail) {
|
||||
return redirect()->route('users')->with('success', 'You have successfully added data');
|
||||
} else {
|
||||
return redirect()->route('users')->with('error', 'An error occurred in the query email');
|
||||
}
|
||||
} else {
|
||||
return redirect()->route('users')->with('error', 'An error occurred in the query');
|
||||
}
|
||||
} else {
|
||||
return redirect()->route('users')->with('error', 'Email already exists');
|
||||
}
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$data = [
|
||||
'subtitle' => User::where('id', $id)->first()->email,
|
||||
'records' => User::where('id', $id)->first(),
|
||||
'logs' => User::where('id', $id)->first()
|
||||
];
|
||||
return view('admin.app.users.detail', compact('data'));
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$data = [
|
||||
'subtitle' => User::where('id', $id)->first()->email,
|
||||
'records' => User::where('id', $id)->first()
|
||||
];
|
||||
|
||||
$roles = Roles::whereIn('id', [1, 2])->get();
|
||||
return view('admin.app.users.edit', compact('data', 'id', 'roles'));
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'name' => 'required',
|
||||
'email' => 'required|email',
|
||||
'level' => 'required',
|
||||
'status' => 'required',
|
||||
'image' => 'image|mimes:jpg,jpeg,png,svg|max:7048',
|
||||
], [
|
||||
'image.mimes' => 'Tipe file yang diunggah harus jpg, jpeg, png, atau svg.',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect()->back()->withErrors($validator)->withInput();
|
||||
}
|
||||
|
||||
// Cari data berdasarkan ID
|
||||
$user = User::find($id);
|
||||
|
||||
// Jika data ditemukan
|
||||
if ($user) {
|
||||
// Jika ada file baru yang diunggah, hapus file thumbnail yang lama
|
||||
if ($request->hasFile('image') && $request->file('image')->isValid()) {
|
||||
if ($user->thumbnail) {
|
||||
Storage::delete($user->thumbnail);
|
||||
}
|
||||
}
|
||||
|
||||
// Update data dengan data baru dari form yang telah dibersihkan
|
||||
$user->name = $request->input('name');
|
||||
$user->email = $request->input('email');
|
||||
!empty($request->input('password')) ? $user->password = bcrypt($request->input('password')) : $user->password;
|
||||
$user->level = $request->input('level');
|
||||
$user->status = $request->input('status');
|
||||
$user->username = Str::before($user->email, '@') . rand(100, 999);
|
||||
|
||||
// Jika ada file baru yang diunggah, simpan file baru di storage
|
||||
if ($request->hasFile('image') && $request->file('image')->isValid()) {
|
||||
$foto_namaBaru = $request->file('image')->store('public/images');
|
||||
$user->thumbnail = $foto_namaBaru;
|
||||
}
|
||||
|
||||
// Simpan perubahan pada database
|
||||
$user->save();
|
||||
return redirect()->route('users')->with('swal', swal_alert('success', 'You are successfully modify data'));
|
||||
} else {
|
||||
return redirect()->route('users')->with('swal', swal_alert('error', 'Unexpected error'));
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$user = User::find($id);
|
||||
// Jika data ditemukan
|
||||
if ($user) {
|
||||
// Cek apakah ada file di kolom "is_thumbnail"
|
||||
if ($user->thumbnail) {
|
||||
// Hapus file thumbnail dari storage
|
||||
Storage::delete($user->thumbnail);
|
||||
}
|
||||
// Hapus data dari database
|
||||
$user->delete();
|
||||
return redirect()->route('users')->with('swal', swal_alert('success', 'You are successfully deleted records'));
|
||||
} else {
|
||||
return redirect()->route('users')->with('swal', swal_alert('error', 'Data not found'));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
{
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* These middleware are run during every request to your application.
|
||||
*
|
||||
* @var array<int, class-string|string>
|
||||
*/
|
||||
protected $middleware = [
|
||||
// \App\Http\Middleware\TrustHosts::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
\Fruitcake\Cors\HandleCors::class,
|
||||
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware groups.
|
||||
*
|
||||
* @var array<string, array<int, class-string|string>>
|
||||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
// \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||
'throttle:api',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware.
|
||||
*
|
||||
* These middleware may be assigned to groups or used individually.
|
||||
*
|
||||
* @var array<string, class-string|string>
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
|
||||
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
'check.status' => \App\Http\Middleware\CheckUserStatus::class,
|
||||
'check.admin' => \App\Http\Middleware\CheckAuthenticatedisAdmin::class,
|
||||
'check.seller' => \App\Http\Middleware\CheckSeller::class,
|
||||
'XssSanitization' => \App\Http\Middleware\XssSanitization::class,
|
||||
'check.auth' => \App\Http\Middleware\isAuth::class
|
||||
];
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Modules\User;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use App\Models\Content;
|
||||
use App\Models\ContentCategories as Category;
|
||||
use App\Enums\GlobalEnum;
|
||||
use WithPagination;
|
||||
|
||||
class Blog extends Component
|
||||
{
|
||||
public $filterType;
|
||||
public $categoryFilter;
|
||||
public $searchFilter = '';
|
||||
|
||||
public $currentPage = 1;
|
||||
public $perPage = 10;
|
||||
|
||||
public function render(Request $request)
|
||||
{
|
||||
$valueCategory = '';
|
||||
|
||||
if(!empty($request->input('categoryFilter')))
|
||||
{
|
||||
$this->categoryFilter = $request->categoryFilter;
|
||||
|
||||
$valueCategory = $request->categoryFilter;
|
||||
}
|
||||
|
||||
$query = Content::where('is_status', 1);
|
||||
|
||||
if (!empty($this->categoryFilter)) {
|
||||
$query->where('is_category', 'like', '%' . $this->categoryFilter . '%');
|
||||
}
|
||||
|
||||
if (!empty($this->searchFilter)) {
|
||||
$query->where('title', 'like', '%' . $this->searchFilter . '%');
|
||||
}
|
||||
|
||||
$sites = $query->paginate($this->perPage)->appends([
|
||||
'categoryFilter' => $this->categoryFilter,
|
||||
]);
|
||||
|
||||
$elements = $sites->links()->elements;
|
||||
$searchCount = $sites->total();
|
||||
$getListCategory = Category::select('*');
|
||||
|
||||
return view('livewire.modules.user.blog',
|
||||
compact('sites', 'elements', 'searchCount', 'getListCategory', 'valueCategory')
|
||||
);
|
||||
}
|
||||
|
||||
public function previousPage()
|
||||
{
|
||||
if ($this->currentPage > 1) {
|
||||
$this->currentPage--;
|
||||
}
|
||||
}
|
||||
|
||||
public function nextPage()
|
||||
{
|
||||
$this->currentPage++;
|
||||
}
|
||||
|
||||
public function goToPage($page)
|
||||
{
|
||||
$url = route('user.sites.view', ['id' => $page]);
|
||||
return redirect()->to($url);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Modules\User;
|
||||
|
||||
use Livewire\Component;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use Modules\Seller\Entities\DomainModel as Domains;
|
||||
use Modules\User\Entities\CartModel as Carts;
|
||||
|
||||
use App\Enums\GlobalEnum;
|
||||
use WithPagination;
|
||||
|
||||
class Domain extends Component
|
||||
{
|
||||
public $searchFilter = '';
|
||||
public $minimumPrice;
|
||||
public $maximumPrice;
|
||||
|
||||
public $currentPage = 1;
|
||||
public $perPage = 10;
|
||||
|
||||
public function render(Request $request)
|
||||
{
|
||||
|
||||
$valueMinimumPrice = '';
|
||||
$valueMaximumPrice = '';
|
||||
|
||||
if(!empty($request->input('minimumPrice')) || !empty($request->input('maximumPrice')))
|
||||
{
|
||||
$this->minimumPrice = $request->minimumPrice;
|
||||
$this->maximumPrice = $request->maximumPrice;
|
||||
|
||||
$valueMinimumPrice = $request->minimumPrice;
|
||||
$valueMaximumPrice = $request->maximumPrice;
|
||||
}
|
||||
|
||||
$query = Domains::where('is_status', GlobalEnum::isSiteActive);
|
||||
|
||||
if (!empty($this->minimumPrice) || !empty($this->maximumPrice)) {
|
||||
$query->whereBetween('is_post_price', [$this->minimumPrice, $this->maximumPrice]);
|
||||
}
|
||||
|
||||
if (!empty($this->searchFilter)) {
|
||||
$check_query = $query->where('url', 'like', '%' . $this->searchFilter . '%')->count();
|
||||
if($check_query == 0) {
|
||||
$query->where('is_url_from_website', 'like', '%' . $this->searchFilter . '%');
|
||||
} else {
|
||||
$query->where('url', 'like', '%' . $this->searchFilter . '%');
|
||||
}
|
||||
}
|
||||
|
||||
$sites = $query->paginate($this->perPage)->appends([
|
||||
'minimumPrice' => $this->minimumPrice,
|
||||
'maximumPrice' => $this->maximumPrice,
|
||||
]);
|
||||
|
||||
$elements = $sites->links()->elements;
|
||||
$searchCount = $sites->total();
|
||||
|
||||
return view('livewire.modules.user.domain',
|
||||
compact('sites', 'elements', 'searchCount', 'valueMinimumPrice', 'valueMaximumPrice')
|
||||
);
|
||||
}
|
||||
|
||||
public function previousPage()
|
||||
{
|
||||
if ($this->currentPage > 1) {
|
||||
$this->currentPage--;
|
||||
}
|
||||
}
|
||||
|
||||
public function nextPage()
|
||||
{
|
||||
$this->currentPage++;
|
||||
}
|
||||
|
||||
public function goToPage($page)
|
||||
{
|
||||
$url = route('user.domain.view', ['id' => $page]);
|
||||
return redirect()->to($url);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Modules\User;
|
||||
|
||||
use Livewire\Component;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use Modules\Seller\Entities\DomainModel as Domains;
|
||||
use Modules\User\Entities\CartModel as Carts;
|
||||
|
||||
use App\Enums\GlobalEnum;
|
||||
use WithPagination;
|
||||
|
||||
class DomainPremium extends Component
|
||||
{
|
||||
public $searchFilter = '';
|
||||
public $minimumPrice;
|
||||
public $maximumPrice;
|
||||
|
||||
public $currentPage = 1;
|
||||
public $perPage = 10;
|
||||
|
||||
public function render(Request $request)
|
||||
{
|
||||
|
||||
$valueMinimumPrice = '';
|
||||
$valueMaximumPrice = '';
|
||||
|
||||
if(!empty($request->input('minimumPrice')) || !empty($request->input('maximumPrice')))
|
||||
{
|
||||
$this->minimumPrice = $request->minimumPrice;
|
||||
$this->maximumPrice = $request->maximumPrice;
|
||||
|
||||
$valueMinimumPrice = $request->minimumPrice;
|
||||
$valueMaximumPrice = $request->maximumPrice;
|
||||
}
|
||||
|
||||
$query = Domains::where('is_status', GlobalEnum::isSiteActive)->where('is_premium', 1);
|
||||
|
||||
if (!empty($this->minimumPrice) || !empty($this->maximumPrice)) {
|
||||
$query->whereBetween('is_post_price', [$this->minimumPrice, $this->maximumPrice]);
|
||||
}
|
||||
|
||||
if (!empty($this->searchFilter)) {
|
||||
$check_query = $query->where('url', 'like', '%' . $this->searchFilter . '%')->count();
|
||||
if($check_query == 0) {
|
||||
$query->where('is_url_from_website', 'like', '%' . $this->searchFilter . '%');
|
||||
} else {
|
||||
$query->where('url', 'like', '%' . $this->searchFilter . '%');
|
||||
}
|
||||
}
|
||||
|
||||
$sites = $query->paginate($this->perPage)->appends([
|
||||
'minimumPrice' => $this->minimumPrice,
|
||||
'maximumPrice' => $this->maximumPrice,
|
||||
]);
|
||||
|
||||
$elements = $sites->links()->elements;
|
||||
$searchCount = $sites->total();
|
||||
|
||||
return view('livewire.modules.user.domain-premium',
|
||||
compact('sites', 'elements', 'searchCount', 'valueMinimumPrice', 'valueMaximumPrice')
|
||||
);
|
||||
}
|
||||
|
||||
public function previousPage()
|
||||
{
|
||||
if ($this->currentPage > 1) {
|
||||
$this->currentPage--;
|
||||
}
|
||||
}
|
||||
|
||||
public function nextPage()
|
||||
{
|
||||
$this->currentPage++;
|
||||
}
|
||||
|
||||
public function goToPage($page)
|
||||
{
|
||||
$url = route('user.domain.view', ['id' => $page]);
|
||||
return redirect()->to($url);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Modules\User;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use Modules\Seller\Entities\SitesModel as Sites;
|
||||
use Modules\Seller\Entities\SitesCategoryModel as SitesCategory;
|
||||
use Modules\User\Entities\CartModel as Carts;
|
||||
use App\Enums\GlobalEnum;
|
||||
use WithPagination;
|
||||
|
||||
class Listing extends Component
|
||||
{
|
||||
public $filterType;
|
||||
public $categoryFilter;
|
||||
public $searchFilter = '';
|
||||
public $minimumPrice;
|
||||
public $maximumPrice;
|
||||
|
||||
public $currentPage = 1;
|
||||
public $perPage = 12;
|
||||
|
||||
public function render(Request $request)
|
||||
{
|
||||
$valueType = '';
|
||||
$valueCategory = '';
|
||||
$valueMinimumPrice = '';
|
||||
$valueMaximumPrice = '';
|
||||
|
||||
if(!empty($request->input('filterType')) || !empty($request->input('categoryFilter')) || !empty($request->input('minimumPrice')) || !empty($request->input('maximumPrice')))
|
||||
{
|
||||
$this->filterType = $request->filterType;
|
||||
$this->categoryFilter = $request->categoryFilter;
|
||||
$this->minimumPrice = $request->minimumPrice;
|
||||
$this->maximumPrice = $request->maximumPrice;
|
||||
|
||||
$valueType = $request->filterType;
|
||||
$valueCategory = $request->categoryFilter;
|
||||
$valueMinimumPrice = $request->minimumPrice;
|
||||
$valueMaximumPrice = $request->maximumPrice;
|
||||
}
|
||||
|
||||
$query = Sites::where('is_status', GlobalEnum::isSiteActive);
|
||||
|
||||
if (!empty($this->filterType)) {
|
||||
$query->where('is_type', $this->filterType);
|
||||
}
|
||||
|
||||
if (!empty($this->categoryFilter)) {
|
||||
$query->where('is_url_category', 'like', '%' . $this->categoryFilter . '%');
|
||||
}
|
||||
|
||||
if (!empty($this->minimumPrice) || !empty($this->maximumPrice)) {
|
||||
$query->whereBetween('is_post_price', [$this->minimumPrice, $this->maximumPrice]);
|
||||
}
|
||||
|
||||
if (!empty($this->searchFilter)) {
|
||||
$query->where('url', 'like', '%' . $this->searchFilter . '%');
|
||||
}
|
||||
|
||||
$sites = $query->paginate($this->perPage)->appends([
|
||||
'filterType' => $this->filterType,
|
||||
'categoryFilter' => $this->categoryFilter,
|
||||
'minimumPrice' => $this->minimumPrice,
|
||||
'maximumPrice' => $this->maximumPrice,
|
||||
]);
|
||||
|
||||
$elements = $sites->links()->elements;
|
||||
$searchCount = $sites->total();
|
||||
$getListCategory = SitesCategory::where('is_status', GlobalEnum::isActive)->get();
|
||||
|
||||
return view('livewire.modules.user.product',
|
||||
compact('sites', 'elements', 'searchCount', 'getListCategory', 'valueType', 'valueCategory', 'valueMinimumPrice', 'valueMaximumPrice')
|
||||
);
|
||||
}
|
||||
|
||||
public function previousPage()
|
||||
{
|
||||
if ($this->currentPage > 1) {
|
||||
$this->currentPage--;
|
||||
}
|
||||
}
|
||||
|
||||
public function nextPage()
|
||||
{
|
||||
$this->currentPage++;
|
||||
}
|
||||
|
||||
public function goToPage($page)
|
||||
{
|
||||
$url = route('user.sites.view', ['id' => $page]);
|
||||
return redirect()->to($url);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Modules\User;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use Modules\Seller\Entities\SitesModel as Sites;
|
||||
use Modules\Seller\Entities\SitesCategoryModel as SitesCategory;
|
||||
use Modules\User\Entities\CartModel as Carts;
|
||||
use App\Enums\GlobalEnum;
|
||||
use WithPagination;
|
||||
|
||||
class Site extends Component
|
||||
{
|
||||
public $filterType;
|
||||
public $categoryFilter;
|
||||
public $searchFilter = '';
|
||||
public $minimumPrice;
|
||||
public $maximumPrice;
|
||||
|
||||
public $currentPage = 1;
|
||||
public $perPage = 10;
|
||||
|
||||
public function render(Request $request)
|
||||
{
|
||||
|
||||
$valueType = '';
|
||||
$valueCategory = '';
|
||||
$valueMinimumPrice = '';
|
||||
$valueMaximumPrice = '';
|
||||
|
||||
if(!empty($request->input('filterType')) || !empty($request->input('categoryFilter')) || !empty($request->input('minimumPrice')) || !empty($request->input('maximumPrice')))
|
||||
{
|
||||
$this->filterType = $request->filterType;
|
||||
$this->categoryFilter = $request->categoryFilter;
|
||||
$this->minimumPrice = $request->minimumPrice;
|
||||
$this->maximumPrice = $request->maximumPrice;
|
||||
|
||||
$valueType = $request->filterType;
|
||||
$valueCategory = $request->categoryFilter;
|
||||
$valueMinimumPrice = $request->minimumPrice;
|
||||
$valueMaximumPrice = $request->maximumPrice;
|
||||
}
|
||||
|
||||
$query = Sites::where('is_status', GlobalEnum::isSiteActive);
|
||||
|
||||
if (!empty($this->filterType)) {
|
||||
$query->where('is_type', $this->filterType);
|
||||
}
|
||||
|
||||
if (!empty($this->categoryFilter)) {
|
||||
$query->where('is_url_category', 'like', '%' . $this->categoryFilter . '%');
|
||||
}
|
||||
|
||||
if (!empty($this->minimumPrice) || !empty($this->maximumPrice)) {
|
||||
$query->whereBetween('is_post_price', [$this->minimumPrice, $this->maximumPrice]);
|
||||
}
|
||||
|
||||
if (!empty($this->searchFilter)) {
|
||||
$query->where('url', 'like', '%' . $this->searchFilter . '%');
|
||||
}
|
||||
|
||||
$sites = $query->paginate($this->perPage)->appends([
|
||||
'filterType' => $this->filterType,
|
||||
'categoryFilter' => $this->categoryFilter,
|
||||
'minimumPrice' => $this->minimumPrice,
|
||||
'maximumPrice' => $this->maximumPrice,
|
||||
]);
|
||||
|
||||
$elements = $sites->links()->elements;
|
||||
$searchCount = $sites->total();
|
||||
$getListCategory = SitesCategory::where('is_status', GlobalEnum::isActive)->get();
|
||||
|
||||
return view('livewire.modules.user.site',
|
||||
compact('sites', 'elements', 'searchCount', 'getListCategory', 'valueType', 'valueCategory', 'valueMinimumPrice', 'valueMaximumPrice')
|
||||
);
|
||||
}
|
||||
|
||||
public function previousPage()
|
||||
{
|
||||
if ($this->currentPage > 1) {
|
||||
$this->currentPage--;
|
||||
}
|
||||
}
|
||||
|
||||
public function nextPage()
|
||||
{
|
||||
$this->currentPage++;
|
||||
}
|
||||
|
||||
public function goToPage($page)
|
||||
{
|
||||
$url = route('user.sites.view', ['id' => $page]);
|
||||
return redirect()->to($url);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Modules\User;
|
||||
|
||||
use Livewire\Component;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use Modules\Seller\Entities\SitesModel as Sites;
|
||||
use Modules\Seller\Entities\SitesCategoryModel as SitesCategory;
|
||||
use Modules\User\Entities\CartModel as Carts;
|
||||
|
||||
use App\Enums\GlobalEnum;
|
||||
use WithPagination;
|
||||
|
||||
class SitePremium extends Component
|
||||
{
|
||||
public $filterType;
|
||||
public $categoryFilter;
|
||||
public $searchFilter = '';
|
||||
public $minimumPrice;
|
||||
public $maximumPrice;
|
||||
|
||||
public $currentPage = 1;
|
||||
public $perPage = 10;
|
||||
|
||||
public function render(Request $request)
|
||||
{
|
||||
|
||||
$valueType = '';
|
||||
$valueCategory = '';
|
||||
$valueMinimumPrice = '';
|
||||
$valueMaximumPrice = '';
|
||||
|
||||
if(!empty($request->input('filterType')) || !empty($request->input('categoryFilter')) || !empty($request->input('minimumPrice')) || !empty($request->input('maximumPrice')))
|
||||
{
|
||||
$this->filterType = $request->filterType;
|
||||
$this->categoryFilter = $request->categoryFilter;
|
||||
$this->minimumPrice = $request->minimumPrice;
|
||||
$this->maximumPrice = $request->maximumPrice;
|
||||
|
||||
$valueType = $request->filterType;
|
||||
$valueCategory = $request->categoryFilter;
|
||||
$valueMinimumPrice = $request->minimumPrice;
|
||||
$valueMaximumPrice = $request->maximumPrice;
|
||||
}
|
||||
|
||||
$query = Sites::where('is_status', GlobalEnum::isSiteActive)->where('is_premium', 1);
|
||||
|
||||
if (!empty($this->filterType)) {
|
||||
$query->where('is_type', $this->filterType);
|
||||
}
|
||||
|
||||
if (!empty($this->categoryFilter)) {
|
||||
$query->where('is_url_category', 'like', '%' . $this->categoryFilter . '%');
|
||||
}
|
||||
|
||||
if (!empty($this->minimumPrice) || !empty($this->maximumPrice)) {
|
||||
$query->whereBetween('is_post_price', [$this->minimumPrice, $this->maximumPrice]);
|
||||
}
|
||||
|
||||
if (!empty($this->searchFilter)) {
|
||||
$query->where('url', 'like', '%' . $this->searchFilter . '%');
|
||||
}
|
||||
|
||||
$sites = $query->paginate($this->perPage)->appends([
|
||||
'filterType' => $this->filterType,
|
||||
'categoryFilter' => $this->categoryFilter,
|
||||
'minimumPrice' => $this->minimumPrice,
|
||||
'maximumPrice' => $this->maximumPrice,
|
||||
]);
|
||||
|
||||
$elements = $sites->links()->elements;
|
||||
$searchCount = $sites->total();
|
||||
$getListCategory = SitesCategory::where('is_status', GlobalEnum::isActive)->get();
|
||||
|
||||
return view('livewire.modules.user.site-premium',
|
||||
compact('sites', 'elements', 'searchCount', 'getListCategory', 'valueType', 'valueCategory', 'valueMinimumPrice', 'valueMaximumPrice')
|
||||
);
|
||||
}
|
||||
|
||||
public function previousPage()
|
||||
{
|
||||
if ($this->currentPage > 1) {
|
||||
$this->currentPage--;
|
||||
}
|
||||
}
|
||||
|
||||
public function nextPage()
|
||||
{
|
||||
$this->currentPage++;
|
||||
}
|
||||
|
||||
public function goToPage($page)
|
||||
{
|
||||
$url = route('user.sites.view', ['id' => $page]);
|
||||
return redirect()->to($url);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||
|
||||
class Authenticate extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the path the user should be redirected to when they are not authenticated.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return string|null
|
||||
*/
|
||||
protected function redirectTo($request)
|
||||
{
|
||||
if (! $request->expectsJson()) {
|
||||
return route('login');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class CheckAuthenticatedisAdmin
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
||||
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
if (Auth::check()) {
|
||||
$user = Auth::user();
|
||||
|
||||
// Check the user's status
|
||||
if ($user->level != 1) {
|
||||
return redirect()->intended('user');
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class checkUserStatus
|
||||
{
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
// Check if the user is authenticated
|
||||
if (Auth::check()) {
|
||||
$user = Auth::user();
|
||||
|
||||
// Check the user's status
|
||||
if ($user->status !== 3) {
|
||||
return back()
|
||||
->with('swal', swal_alert('error', 'Akun anda dinonaktifkan, Mohon Kontak administrator'));
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||
|
||||
class EncryptCookies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
|
||||
|
||||
class PreventRequestsDuringMaintenance extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be reachable while maintenance mode is enabled.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
||||
* @param string|null ...$guards
|
||||
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function handle(Request $request, Closure $next, ...$guards)
|
||||
{
|
||||
$guards = empty($guards) ? [null] : $guards;
|
||||
|
||||
foreach ($guards as $guard) {
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect(RouteServiceProvider::HOME);
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||
|
||||
class TrimStrings extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the attributes that should not be trimmed.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustHosts as Middleware;
|
||||
|
||||
class TrustHosts extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the host patterns that should be trusted.
|
||||
*
|
||||
* @return array<int, string|null>
|
||||
*/
|
||||
public function hosts()
|
||||
{
|
||||
return [
|
||||
$this->allSubdomainsOfApplicationUrl(),
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TrustProxies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The trusted proxies for this application.
|
||||
*
|
||||
* @var array<int, string>|string|null
|
||||
*/
|
||||
protected $proxies;
|
||||
|
||||
/**
|
||||
* The headers that should be used to detect proxies.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $headers =
|
||||
Request::HEADER_X_FORWARDED_FOR |
|
||||
Request::HEADER_X_FORWARDED_HOST |
|
||||
Request::HEADER_X_FORWARDED_PORT |
|
||||
Request::HEADER_X_FORWARDED_PROTO |
|
||||
Request::HEADER_X_FORWARDED_AWS_ELB;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||
|
||||
class VerifyCsrfToken extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be excluded from CSRF verification.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class XssSanitization
|
||||
{
|
||||
/**
|
||||
* Handles the request by modifying the input data and passing it to the next middleware or route handler.
|
||||
*
|
||||
* @param Request $request The request object containing the input data.
|
||||
* @param Closure $next The next middleware or route handler.
|
||||
* @throws Some_Exception_Class [Optional] Description of any exception that may be thrown.
|
||||
* @return mixed The result of the next middleware or route handler.
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
$input = $request->all();
|
||||
array_walk_recursive($input, function(&$input) {
|
||||
$input = strip_tags($input);
|
||||
});
|
||||
|
||||
$request->merge($input);
|
||||
return $next($request);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class isAuth
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
||||
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
$auth = Auth::check();
|
||||
if($auth) {
|
||||
$user = Auth::user();
|
||||
switch($user->level == 1) {
|
||||
case 1:
|
||||
return redirect()->intended('app/dashboard');
|
||||
break;
|
||||
case 2:
|
||||
return redirect()->intended('user');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Alternatif extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'tbl_data_alternatif';
|
||||
protected $primaryKey = 'id_alternatif';
|
||||
protected $fillable = [
|
||||
'id_alternatif',
|
||||
'nama_alternatif',
|
||||
'uplink',
|
||||
'created_at',
|
||||
'updated_at'
|
||||
];
|
||||
|
||||
public $timestamps = false;
|
||||
public $keyType = 'string';
|
||||
|
||||
public function skorPreferensi()
|
||||
{
|
||||
return $this->hasOne(PengajuanNasabah::class, 'id_pengajuan', 'id_alternatif');
|
||||
}
|
||||
|
||||
public function agen()
|
||||
{
|
||||
return $this->hasOne(User::class, 'id', 'uplink');
|
||||
}
|
||||
|
||||
public function nilai()
|
||||
{
|
||||
return $this->hasOne(Nilai::class, 'alternatif_kode', 'id_alternatif');
|
||||
}
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::deleting(function ($alternatif) {
|
||||
// Hapus semua nilai yang memiliki alternatif_kode sama dengan id_alternatif yang akan dihapus
|
||||
$alternatif->nilai()->delete();
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Kriteria extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'tbl_data_kriteria';
|
||||
protected $primaryKey = 'id_kriteria';
|
||||
protected $fillable = [
|
||||
'id_kriteria',
|
||||
'nama_kriteria',
|
||||
'kriteria_kategori',
|
||||
'bobot_kriteria',
|
||||
];
|
||||
|
||||
public $timestamps = false;
|
||||
public $keyType = 'string';
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class LogActivites extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'tbl_log_activity';
|
||||
protected $fillable = ['uid','logType','causedBy','performedOn','withContent','created_at'];
|
||||
public $timestamps = false;
|
||||
|
||||
public static function default($args = [])
|
||||
{
|
||||
self::create([
|
||||
'uid' => Uuid::uuid4()->toString(),
|
||||
'logType' => $args['logType'],
|
||||
'causedBy' => $args['causedBy'],
|
||||
'performedOn' => Carbon::now(),
|
||||
'withContent' => json_encode($args['withContent'], true),
|
||||
]);
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->hasMany(User::class, 'id', 'causedBy');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Nilai extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'tbl_nilai';
|
||||
protected $primaryKey = 'id';
|
||||
protected $fillable = [
|
||||
'alternatif_kode',
|
||||
'kriteria_kode',
|
||||
'nilai_faktor'
|
||||
];
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public function nasabah()
|
||||
{
|
||||
return $this->hasOne(Alternatif::class, 'id_alternatif', 'alternatif_kode');
|
||||
}
|
||||
|
||||
public function kriteria()
|
||||
{
|
||||
return $this->hasOne(Kriteria::class, 'id_kriteria', 'kriteria_kode');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Pages extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'tbl_pages';
|
||||
protected $fillable = [
|
||||
'id', 'slug', 'title', 'description',
|
||||
'created_at', 'updated_at'
|
||||
];
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PengajuanNasabah extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'tbl_data_pengajuan';
|
||||
protected $primaryKey = 'id_pengajuan';
|
||||
protected $fillable = [
|
||||
'id_nasabah',
|
||||
'uplink',
|
||||
'skor',
|
||||
'status',
|
||||
];
|
||||
|
||||
public $keyType = 'string';
|
||||
|
||||
public function nasabah()
|
||||
{
|
||||
return $this->belongsTo(Alternatif::class, 'id_alternatif', 'id_nasabah');
|
||||
}
|
||||
|
||||
public function uplinkUser()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'uplink', 'id');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Ranking extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'tbl_rangking';
|
||||
protected $primaryKey = 'kriteria';
|
||||
protected $fillable = [
|
||||
'kriteria',
|
||||
'skor_bobot',
|
||||
'alternatif'
|
||||
];
|
||||
|
||||
public $timestamps = false;
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\User;
|
||||
|
||||
class Roles extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'tbl_role';
|
||||
protected $fillable = ['id','name'];
|
||||
public $timestamps = false;
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Subkriteria extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'tbl_data_subkriteria';
|
||||
protected $primaryKey = 'subkriteria_kode';
|
||||
protected $fillable = [
|
||||
'subkriteria_kode',
|
||||
'kriteria_kode',
|
||||
'subkriteria_bobot',
|
||||
'keterangan'
|
||||
];
|
||||
|
||||
public $timestamps = false;
|
||||
public $keyType = 'string';
|
||||
|
||||
public function kriteria()
|
||||
{
|
||||
return $this->hasOne(Kriteria::class, 'kriteria_kode', 'id_kriteria');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
use App\Models\Permission;
|
||||
use App\Models\Roles;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasApiTokens, HasFactory, Notifiable;
|
||||
|
||||
protected $table = 'tbl_users';
|
||||
protected $fillable = ['password','username','name','email','email_verified_token','email_verified_at','phone','status','remember_token','thumbnail','level'];
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
public $timestamps = false;
|
||||
|
||||
public function permission()
|
||||
{
|
||||
return $this->hasMany(Permission::class);
|
||||
}
|
||||
|
||||
public function roles()
|
||||
{
|
||||
return $this->hasMany(Roles::class);
|
||||
}
|
||||
|
||||
public function konselor()
|
||||
{
|
||||
return $this->hasMany(Konselor::class);
|
||||
}
|
||||
|
||||
public function siswa()
|
||||
{
|
||||
return $this->hasMany(Siswa::class);
|
||||
}
|
||||
|
||||
public function wali()
|
||||
{
|
||||
return $this->hasMany(Wali::class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UserManager extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'password_resets';
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'email',
|
||||
'token',
|
||||
'created_at',
|
||||
'isUsed'
|
||||
];
|
||||
protected $primaryKey = 'uuid';
|
||||
protected $hidden = ['created_at'];
|
||||
public $timestamps = false;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue