update patch 1
This commit is contained in:
@@ -6,6 +6,7 @@ APP_TIMEZONE=UTC
|
||||
APP_URL=http://localhost
|
||||
APP_VERSION = "1.0.0"
|
||||
APP_COMPANY = "Tunggal Idaman Abadi"
|
||||
APP_NAME = "Xpendify"
|
||||
APP_LOCALE=en
|
||||
APP_FALLBACK_LOCALE=en
|
||||
APP_FAKER_LOCALE=en_US
|
||||
@@ -22,14 +23,15 @@ LOG_STACK=single
|
||||
LOG_DEPRECATIONS_CHANNEL=null
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=sqlite
|
||||
# DB_HOST=127.0.0.1
|
||||
# DB_PORT=3306
|
||||
# DB_DATABASE=laravel
|
||||
# DB_USERNAME=root
|
||||
# DB_PASSWORD=
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=db.upsense.co.id
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=xpendify
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=Hesoyam88
|
||||
DB_TIMEZONE='+07:00'
|
||||
|
||||
SESSION_DRIVER=database
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=120
|
||||
SESSION_ENCRYPT=false
|
||||
SESSION_PATH=/
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* The Artisan commands provided by your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
// $schedule->command('inspire')->hourly();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the commands for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function commands()
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?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
|
||||
*/
|
||||
protected $dontReport = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the inputs that are never flashed for validation exceptions.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* Report or log an exception.
|
||||
*
|
||||
* @param \Throwable $exception
|
||||
* @return void
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function report(Throwable $exception)
|
||||
{
|
||||
parent::report($exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Throwable $exception
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function render($request, Throwable $exception)
|
||||
{
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class AuthenticationHelper
|
||||
{
|
||||
|
||||
|
||||
public static function CurrentLogin()
|
||||
{
|
||||
$auth = Auth::user()->username;
|
||||
return $auth;
|
||||
}
|
||||
|
||||
|
||||
public static function CurrentLoginData()
|
||||
{
|
||||
$auth = Auth::user();
|
||||
return $auth;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use PhpOffice\PhpWord\IOFactory;
|
||||
use PhpOffice\PhpWord\TemplateProcessor;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Dompdf\Dompdf;
|
||||
use Dompdf\Options;
|
||||
|
||||
class DocxHelper
|
||||
{
|
||||
/**
|
||||
* Edit prefix dalam file DOCX dan konversi menjadi PDF.
|
||||
*
|
||||
* @param string $filePath Path file DOCX asli.
|
||||
* @param array $prefixes Array pasangan placeholder dan value untuk mengganti teks dalam DOCX.
|
||||
* @param string $outputPdfPath Path output untuk menyimpan PDF.
|
||||
* Contoh: ['PREFIX_PLACEHOLDER_1' => 'NewPrefix1', ...]
|
||||
* @return string Path dari file PDF yang dihasilkan.
|
||||
*
|
||||
*/
|
||||
public static function parsePrefix($filePath, array $prefixes)
|
||||
{
|
||||
$templateProcessor = new TemplateProcessor($filePath);
|
||||
|
||||
foreach ($prefixes as $placeholder => $value) {
|
||||
if($value[1] == 'TEXT'){
|
||||
$templateProcessor->setValue($placeholder, $value[0]);
|
||||
|
||||
}
|
||||
|
||||
if($value[1] == 'IMAGE'){
|
||||
if (file_exists(storage_path('app/signature/'.$value[0]))) {
|
||||
$templateProcessor->setImageValue(str_replace(['${', '}'], '', $placeholder), array('path' => storage_path('app/signature/'.$value[0]), 'width' => 50, 'height' => 50, 'ratio' => true));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$docx_temp_name = pathinfo($filePath, PATHINFO_FILENAME) . '.docx'; // Nama unik untuk file sementara
|
||||
|
||||
if (!file_exists(storage_path('app/public/uploads/temp_docx'))) {
|
||||
mkdir(storage_path('app/public/uploads/temp_docx'), 0777, true);
|
||||
}
|
||||
|
||||
$editedDocxPath = storage_path('app/public/uploads/temp_docx/' . $docx_temp_name);
|
||||
|
||||
$templateProcessor->saveAs($editedDocxPath);
|
||||
return $editedDocxPath;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Konversi file DOCX yang telah diedit prefix menjadi PDF.
|
||||
*
|
||||
* @param array $prefixes Array pasangan placeholder dan value untuk mengganti teks dalam DOCX.
|
||||
* @param string $docx_path Path file DOCX yang akan diconvert.
|
||||
* @param string $pdf_path Path output untuk menyimpan PDF.
|
||||
* @return string Path file PDF yang dihasilkan.
|
||||
*/
|
||||
public static function ConvertPDFWithPrefix($prefixes,$docx_path,$pdf_path)
|
||||
{
|
||||
$inputFilePath = DocxHelper::parsePrefix($docx_path, $prefixes);
|
||||
$libreOfficePath = env('LIBREOFFICE_PATH');
|
||||
|
||||
$command = '"'.$libreOfficePath.'" --headless --convert-to pdf "'.$inputFilePath.'" --outdir "'.dirname($pdf_path).'"';
|
||||
$output = [];
|
||||
$returnVar = 0;
|
||||
exec($command, $output, $returnVar);
|
||||
|
||||
if ($returnVar !== 0) {
|
||||
dd('failed to convert PDF File. Return Code: '.$returnVar);
|
||||
} else {
|
||||
$pathInfo = pathinfo($inputFilePath);
|
||||
$newExtension = 'pdf';
|
||||
$outputFilePath = dirname($pdf_path) . DIRECTORY_SEPARATOR . $pathInfo['filename'] . '.' . $newExtension;
|
||||
}
|
||||
|
||||
return $outputFilePath;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Inserts a new record into the MS_PREFIX_DOCUMENT table with the provided details.
|
||||
*
|
||||
* @param int $documentId The ID of the document.
|
||||
* @param string $prefixKey The prefix key associated with the document.
|
||||
* @param string $tableName The name of the table where the prefix is applied.
|
||||
* @param string $columnName The name of the column where the prefix is applied.
|
||||
* @param string $createdBy The identifier of the user who created the record.
|
||||
* @param string $updatedBy The identifier of the user who last updated the record.
|
||||
* @return bool Returns true if the record was successfully inserted, false otherwise.
|
||||
*/
|
||||
public static function createPrefixDocument($documentId, $prefixKey, $tableName, $columnName, $createdBy, $updatedBy) {
|
||||
$result = DB::table('MS_PREFIX_DOCUMENT')->insert([
|
||||
'DOCUMENT_ID' => $documentId,
|
||||
'PREFIX_KEY' => $prefixKey,
|
||||
'TABLE_NAME' => $tableName,
|
||||
'COLUMN_NAME' => $columnName,
|
||||
'CREATED_BY' => $createdBy,
|
||||
'UPDATED_BY' => $updatedBy,
|
||||
'CREATED_AT' => now(),
|
||||
'UPDATED_AT' => now()
|
||||
]);
|
||||
return (bool) $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the prefix mappings for a given document ID from the MS_PREFIX_DOCUMENT table.
|
||||
*
|
||||
* This function queries the database to obtain prefix mappings associated with the provided
|
||||
* document ID. It then retrieves the corresponding values from the specified tables and columns
|
||||
* for each mapping. If a value is not found, 'N/A' is used as a default.
|
||||
* buatkan sebuah view yang telah di join table untuk menjalankan fungsi ini.
|
||||
* @param string $documentId The ID of the document for which to retrieve prefix mappings.
|
||||
* @return array An associative array of prefix keys and their corresponding values.
|
||||
*/
|
||||
public static function getDocumentPrefixWithData($documentId,$dataId) {
|
||||
|
||||
$prefixes = [];
|
||||
$mappings = DB::table('MS_PREFIX_DOCUMENT')
|
||||
->where('DOCUMENT_ID', $documentId)
|
||||
->get();
|
||||
foreach ($mappings as $mapping) {
|
||||
$value = DB::table($mapping->table_name)
|
||||
->where('ID', $dataId)
|
||||
->value($mapping->column_name);
|
||||
|
||||
$prefixes[$mapping->prefix_key] = array($value !== null ? $value : '', $mapping->type) ;
|
||||
}
|
||||
|
||||
return $prefixes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
class EncryptHelper
|
||||
{
|
||||
|
||||
public static function encryptLDAP($value)
|
||||
{
|
||||
$key = env('CRYPTO_KEY', ''); // Ambil kunci dari .env atau gunakan default
|
||||
$iv = env('CRYPTO_IV', ''); // Ambil IV dari .env atau gunakan default
|
||||
|
||||
try {
|
||||
$ivDecoded = base64_decode($iv);
|
||||
$cipher = openssl_encrypt($value, 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $ivDecoded);
|
||||
return base64_encode($cipher);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function decryptLDAP($value)
|
||||
{
|
||||
$key = env('CRYPTO_KEY', ''); // Ambil kunci dari .env atau gunakan default
|
||||
$iv = env('CRYPTO_IV', ''); // Ambil IV dari .env atau gunakan default
|
||||
$ivDecoded = base64_decode($iv);
|
||||
|
||||
try {
|
||||
$value = base64_decode($value);
|
||||
$decrypted = openssl_decrypt($value, 'aes-256-cbc', $key, OPENSSL_RAW_DATA, $ivDecoded);
|
||||
return $decrypted;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,326 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class GlobalHelper
|
||||
{
|
||||
/**
|
||||
* Get the client's age from Oracle using FN_GET_AGE function.
|
||||
*
|
||||
* @param string $birthDate Birth date in 'YYYY-MM-DD' format
|
||||
* @param string $loanStartdate Birth date in 'YYYY-MM-DD' format
|
||||
* @return int|null The client's age, or null if no data is found
|
||||
*/
|
||||
public static function getClientAge($birthDate, $loanStartdate)
|
||||
{
|
||||
try {
|
||||
$query = "SELECT ADMIN_AJK.FN_GET_AGE(:birthDate, :loanstartdate) AS age FROM dual";
|
||||
$result = DB::select($query, [
|
||||
'birthDate' => date('Y-m-d', strtotime($birthDate)),
|
||||
'loanstartdate' => date('Y-m-d', strtotime($loanStartdate))
|
||||
]);
|
||||
if (!empty($result) && isset($result[0]->age)) {
|
||||
return (int) $result[0]->age;
|
||||
}
|
||||
|
||||
return null;
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the result of auto underwriting for SPAJK.
|
||||
*
|
||||
* @param string $spajk_id SPAJK ID
|
||||
* @return boolean The result of auto underwriting
|
||||
*/
|
||||
public static function GetCriteriaUnderWriting($spajk_id)
|
||||
{
|
||||
try {
|
||||
$query = "SELECT FN_GET_AUTOUW_SPAJK(:spajk_id) AS RESULT FROM DUAL";
|
||||
$result = DB::select($query, ['spajk_id' => $spajk_id]);
|
||||
if (!empty($result) && isset($result[0]->result)) {
|
||||
if($result[0]->result == 'AUTOUW_CRITERIA_OK') {
|
||||
return TRUE;
|
||||
}else{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate SPAJK number based on partner ID
|
||||
*
|
||||
* @param integer $partner_id Partner ID
|
||||
* @return string|null SPAJK number or null if error occurs
|
||||
*/
|
||||
public static function GenerateSPAJKNo($partner_id)
|
||||
{
|
||||
try {
|
||||
$query = "SELECT FN_GEN_SPAJKNO(:partner_id) AS RESULT FROM DUAL";
|
||||
$result = DB::select($query, ['partner_id' => $partner_id]);
|
||||
if (!empty($result) && isset($result[0]->result)) {
|
||||
return $result[0]->result;
|
||||
}
|
||||
|
||||
return null;
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calculate Net Premium of a policy
|
||||
*
|
||||
* @param array $params Parameters to calculate the net premium
|
||||
* - percentage_fee: The percentage of the fee
|
||||
* - percentage_ppn: The percentage of the ppn
|
||||
* - percentage_pph: The percentage of the pph
|
||||
* - gross_premium: The gross premium
|
||||
* - premi_gross_total: The total gross premium
|
||||
*
|
||||
* @return float The calculated net premium
|
||||
*/
|
||||
public static function calculateNetPremi($params){
|
||||
$percentage_fee = isset($params['percentage_fee']) ? $params['percentage_fee'] : 0;
|
||||
$percentage_ppn = isset($params['percentage_ppn']) ? $params['percentage_ppn'] : 0;
|
||||
$percentage_pph = isset($params['percentage_pph']) ? $params['percentage_pph'] : 0;
|
||||
$UP = isset($params['gross_premium']) ? $params['gross_premium'] : 0;
|
||||
$premi_gross_total = isset($params['premi_gross_total']) ? $params['premi_gross_total'] : 0;
|
||||
|
||||
$fee = round($percentage_fee / 100 * $UP,0);
|
||||
$dpp_include_ppn = 100 / (100 + $percentage_ppn);
|
||||
|
||||
$dpp = round($dpp_include_ppn * $fee,0);
|
||||
$ppn = round($percentage_ppn / 100 * $dpp,0);
|
||||
$pph = round($percentage_pph / 100 * $dpp,0);
|
||||
$premi_net_total = $premi_gross_total - $fee + $ppn + $pph;
|
||||
return $premi_net_total;
|
||||
}
|
||||
|
||||
private static function FaktorPenurunan($B40, $B14, $J5) {
|
||||
$result = round((1 - pow(1 + $B40, -$B14 + $J5)) / (1 - pow(1 + $B40, -$B14)), 3);
|
||||
return $result;
|
||||
}
|
||||
|
||||
// Fungsi untuk menghitung Premi Substandard
|
||||
private static function CalculatePremiSubstandard($EP, $UP, $faktorPenurunan) {
|
||||
$EP_per_month = round($EP / 12, 2);
|
||||
$UP_ceiling = ceil($UP);
|
||||
$premiSubstandard = ($EP_per_month / 1000) * $UP_ceiling * $faktorPenurunan;
|
||||
|
||||
return round($premiSubstandard, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Menghitung premi substandard berdasarkan parameter yang diberikan.
|
||||
*
|
||||
* @param array $params parameter yang diperlukan
|
||||
* - extra_premium: nilai extra premi (EP)
|
||||
* - gross_premium: nilai premi bruto (UP)
|
||||
* - loan_interest: bunga pinjaman per bulan
|
||||
* - loan_coverage_month: masa asuransi dalam bulan
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function calculateExtraPremi($params){
|
||||
$EP = isset($params['extra_premium']) ? $params['extra_premium'] : 0; // Nilai Extra Premi (EP)
|
||||
$UP = isset($params['gross_premium']) ? $params['gross_premium'] : 0;
|
||||
$loan_interest = isset($params['loan_interest']) ? $params['loan_interest'] : 0;
|
||||
$masa_asuransi_bulan = isset($params['loan_coverage_month']) ? $params['loan_coverage_month'] : 0;
|
||||
|
||||
// Menghitung faktor penurunan
|
||||
$iloan = round($loan_interest / 12, 8);
|
||||
$faktor_penurunan = 0;
|
||||
|
||||
for ($i = 0; $i < $masa_asuransi_bulan; $i++) {
|
||||
$faktor_perbulan = self::FaktorPenurunan($iloan, $masa_asuransi_bulan, $i);
|
||||
$faktor_penurunan = $faktor_penurunan + $faktor_perbulan;
|
||||
}
|
||||
|
||||
$result = self::CalculatePremiSubstandard($EP, $UP,round($faktor_penurunan,2));
|
||||
return round($result,0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Calculate the extra mortality based on given parameters.
|
||||
*
|
||||
* @param array $params {
|
||||
* Array containing parameters for calculation.
|
||||
*
|
||||
* @type int 'em' The extra mortality percentage (default 0).
|
||||
* @type int 'gross_premi' The gross premium amount (default 0).
|
||||
* }
|
||||
* @return int The calculated extra mortality value.
|
||||
*/
|
||||
|
||||
public static function calculateExtraMortality($params){
|
||||
$em = isset($params['extra_mortality']) ? $params['extra_mortality'] : 0;
|
||||
$gross_premi = isset($params['gross_premi']) ? $params['gross_premi'] : 0;
|
||||
|
||||
$gross_premi_total = intval($em) / 100 * intval($gross_premi);
|
||||
$gross_premi_total = round(intval($gross_premi_total), 0);
|
||||
$extra_mortality = intval($gross_premi_total) + intval( $gross_premi);
|
||||
|
||||
return $extra_mortality;
|
||||
}
|
||||
|
||||
|
||||
public static function calculateGrossPremi($params)
|
||||
{
|
||||
try {
|
||||
$product_id = isset($params['product_id']) ? $params['product_id'] : 0;
|
||||
$usia_masuk = isset($params['usia_masuk']) ? $params['usia_masuk'] : 0;
|
||||
$loan_start_date = isset($params['loan_start_date']) ? $params['loan_start_date'] : '0000-00-00';
|
||||
$loan_end_date = isset($params['loan_end_date']) ? $params['loan_end_date'] : '0000-00-00';
|
||||
$loan_amount = isset($params['loan_amount']) ? $params['loan_amount'] : 0; //Besar Pinjaman (UP)
|
||||
|
||||
$query = "SELECT PREMIUM_RATE_ID, PREMIUM_RATE_CODE, FORMULA_RATE_ID, FORMULA_RATE_CODE FROM VW_PRODUCT_DETAIL WHERE PRODUCT_ID = :product_id";
|
||||
$product_premi = DB::select($query, ['product_id' => $product_id])[0];
|
||||
|
||||
if (!empty($product_premi)) {
|
||||
$premium_rate_id = $product_premi->premium_rate_id;
|
||||
$formula_rate_code = $product_premi->formula_rate_code;
|
||||
|
||||
switch ($formula_rate_code) {
|
||||
case 'RUP': //ROUNDING UP
|
||||
return self::calculatePremiRoundingUp($loan_start_date, $loan_end_date, $usia_masuk, $loan_amount, $premium_rate_id);
|
||||
case 'PRO': //PRORATE
|
||||
return self::calculatePremiProrate($loan_start_date, $loan_end_date, $usia_masuk, $loan_amount, $premium_rate_id);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function calculatePremiProrate($loan_start_date, $loan_end_date, $usia_masuk, $loan_ammount, $RatePremi)
|
||||
{
|
||||
try {
|
||||
$loan_start_date_obj = \Carbon\Carbon::createFromFormat('d-m-Y', $loan_start_date);
|
||||
$loan_end_date_obj = \Carbon\Carbon::createFromFormat('d-m-Y', $loan_end_date);
|
||||
$difference = $loan_start_date_obj->diff($loan_end_date_obj);
|
||||
$coverage_year = $difference->y;
|
||||
$coverage_day = $difference->d;
|
||||
|
||||
$add_month = ($coverage_day >= 1 && $coverage_day <= 31) ? 1 : 0;
|
||||
$masa_asuransi_month = $loan_start_date_obj->diffInMonths($loan_end_date_obj) + $add_month;
|
||||
$coverage_month_mod = $masa_asuransi_month % 12;
|
||||
|
||||
if ($coverage_year == 0) {
|
||||
throw new \Exception("Loan tidak boleh kurang dari 1 tahun.");
|
||||
}
|
||||
|
||||
$rate_low = DB::table('MS_RATE_PREMI as mrp')
|
||||
->where('mrp.AGE', '=', $usia_masuk)
|
||||
->where('mrp.INSURANCE_PERIODE_YEAR', '=', $coverage_year)
|
||||
->where('mrp.MS_PREMIUM_RATE_ID', '=', $RatePremi)
|
||||
->value('mrp.PREMI_VALUE') ?? 0;
|
||||
|
||||
$rate_high = DB::table('MS_RATE_PREMI as mrp')
|
||||
->where('mrp.AGE', '=', $usia_masuk)
|
||||
->where('mrp.INSURANCE_PERIODE_YEAR', '=', ($coverage_year + 1))
|
||||
->where('mrp.MS_PREMIUM_RATE_ID', '=', $RatePremi)
|
||||
->value('mrp.PREMI_VALUE') ?? 0;
|
||||
|
||||
|
||||
|
||||
if (!isset($rate_low) || !isset($rate_high)) {
|
||||
throw new \Exception("Rate untuk perhitungan Gross Premium tidak tersedia.");
|
||||
}
|
||||
|
||||
$calculate_rate = ($rate_low + $coverage_month_mod / 12 * ($rate_high - $rate_low));
|
||||
$up = ceil($loan_ammount);
|
||||
|
||||
$premi_standard = $calculate_rate / 1000 * $up;
|
||||
$premi = round($premi_standard, 0);
|
||||
|
||||
return $premi;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function calculatePremiRoundingUp($loan_start_date, $loan_end_date, $usia_masuk, $loan_ammount, $RatePremi)
|
||||
{
|
||||
try {
|
||||
$loan_start_date_obj = \Carbon\Carbon::createFromFormat('d-m-Y', $loan_start_date);
|
||||
$loan_end_date_obj = \Carbon\Carbon::createFromFormat('d-m-Y', $loan_end_date);
|
||||
$masa_asuransi = $loan_start_date_obj->diffInMonths($loan_end_date_obj);
|
||||
$round_up = ceil($masa_asuransi / 12);
|
||||
|
||||
$premi_value = DB::table('MS_RATE_PREMI as mrp')
|
||||
->where('mrp.AGE', '=', $usia_masuk)
|
||||
->where('mrp.INSURANCE_PERIODE_YEAR', '=', $round_up)
|
||||
->where('mrp.MS_PREMIUM_RATE_ID', '=', $RatePremi)
|
||||
->value('mrp.PREMI_VALUE');
|
||||
|
||||
$up = ceil($loan_ammount);
|
||||
if (!isset($premi_value)) {
|
||||
throw new \Exception("Rate untuk perhitungan Gross Premium tidak tersedia.");
|
||||
}
|
||||
|
||||
$premi_standard = $premi_value / 1000 * $up;
|
||||
$premi = round($premi_standard, 0);
|
||||
|
||||
return $premi;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function generateCertificateSPAJK($product_id,$partner_id)
|
||||
{
|
||||
$product_prefix = DB::table('PRODUCT as p')
|
||||
->select('mbp.ABBREVIATION as prefx')
|
||||
->join('MS_BASIC_PRODUCT as mbp', 'p.BASIC_PRODUCT', '=', 'mbp.ID')
|
||||
->where('p.ID', '=', $product_id)
|
||||
->first();
|
||||
|
||||
$no_certif = DB::select("SELECT SEQ_NO_CERTIFICATE.NEXTVAL as no_certif FROM dual");
|
||||
$no_certif_value = $no_certif[0]->no_certif;
|
||||
$formatted_no_certif = str_pad($no_certif_value, 5, '0', STR_PAD_LEFT);
|
||||
|
||||
|
||||
$partner = DB::table('MS_PARTNER')
|
||||
->select('abbreviation_name as prefx')
|
||||
->where('code', '=', $partner_id)
|
||||
->first();
|
||||
|
||||
$singkatan_value = $product_prefix ? $product_prefix->prefx : '';
|
||||
$partner_value = $partner ? $partner->prefx : '';
|
||||
|
||||
$awalan = "PK";
|
||||
$certifNo = $awalan . '/' . $singkatan_value . '/' . $partner_value . '-' . $formatted_no_certif;
|
||||
|
||||
return $certifNo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
|
||||
class QueryHelper
|
||||
{
|
||||
/**
|
||||
* Execute a stored procedure with input and output parameters.
|
||||
*
|
||||
* @param string $procedureName The name of the stored procedure.
|
||||
* @param array $inputParams An associative array of input parameters.
|
||||
* @param array $outputParams An associative array of output parameters with PDO types.
|
||||
* @return array An associative array of output parameters with their values.
|
||||
*/
|
||||
public static function returnProcedure($connection, $procedureName, $inputParams = [], $outputParams = [])
|
||||
{
|
||||
$connection = $connection->getPdo();
|
||||
|
||||
$inputPlaceholders = [];
|
||||
$outputPlaceholders = [];
|
||||
$bindings = [];
|
||||
|
||||
foreach ($inputParams as $key => $value) {
|
||||
$inputPlaceholders[] = ":{$key}";
|
||||
$bindings[":{$key}"] = $value;
|
||||
}
|
||||
|
||||
foreach ($outputParams as $key => $type) {
|
||||
$outputPlaceholders[] = ":{$key}";
|
||||
$bindings[":{$key}"] = null;
|
||||
}
|
||||
|
||||
// Build the SQL statement
|
||||
$sql = sprintf(
|
||||
'BEGIN %s(%s, %s); END;',
|
||||
$procedureName,
|
||||
implode(', ', $inputPlaceholders),
|
||||
implode(', ', $outputPlaceholders)
|
||||
);
|
||||
|
||||
// Prepare the callable statement
|
||||
$stmt = $connection->prepare($sql);
|
||||
|
||||
// Bind input parameters
|
||||
foreach ($inputParams as $key => $value) {
|
||||
$stmt->bindValue(":{$key}", $value);
|
||||
}
|
||||
|
||||
// Bind output parameters with specific types
|
||||
foreach ($outputParams as $key => $type) {
|
||||
$stmt->bindParam(":{$key}", $bindings[":{$key}"], $type, 255);
|
||||
}
|
||||
// Execute the procedure
|
||||
$stmt->execute();
|
||||
|
||||
// Fetch the output parameters
|
||||
$outputResults = [];
|
||||
foreach ($outputParams as $key => $type) {
|
||||
$outputResults[$key] = $bindings[":{$key}"];
|
||||
}
|
||||
|
||||
$connection = null;
|
||||
return $outputResults;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function execProcedure($connection, $procedureName, $inputParams = [])
|
||||
{
|
||||
// Get the database connection
|
||||
$connection = $connection->getPdo();
|
||||
|
||||
// Build the parameter placeholders for the stored procedure
|
||||
$placeholders = [];
|
||||
$bindings = [];
|
||||
|
||||
foreach ($inputParams as $key => $value) {
|
||||
$placeholders[] = ":{$key}";
|
||||
$bindings[":{$key}"] = $value;
|
||||
}
|
||||
|
||||
// Build the SQL statement
|
||||
$sql = sprintf(
|
||||
'BEGIN %s(%s); END;',
|
||||
$procedureName,
|
||||
implode(', ', $placeholders)
|
||||
);
|
||||
|
||||
// Prepare the callable statement
|
||||
$stmt = $connection->prepare($sql);
|
||||
|
||||
// Bind input parameters
|
||||
foreach ($inputParams as $key => $value) {
|
||||
$stmt->bindValue(":{$key}", $value);
|
||||
}
|
||||
|
||||
|
||||
// Execute the procedure
|
||||
$stmt->execute();
|
||||
$connection = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
class StrHelper
|
||||
{
|
||||
|
||||
public static function bindWhereClause($requestValue, $queryField)
|
||||
{
|
||||
$sql_query = '';
|
||||
if ($requestValue != null && !empty($requestValue)) {
|
||||
return " AND " . $queryField . " LIKE '%" . $requestValue . "%'";
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
public static function bindWhereDateClause($requestValue, $queryField)
|
||||
{
|
||||
$sql_query = '';
|
||||
if ($requestValue != null && !empty($requestValue)) {
|
||||
if ($queryField == 'loan_start_date') {
|
||||
return " AND vw.loan_start_date >= TO_DATE('" . $requestValue . "', 'YYYY-MM-DD')";
|
||||
}
|
||||
|
||||
if ($queryField == 'loan_end_date') {
|
||||
return " AND vw.loan_end_date <= TO_DATE('" . $requestValue . "', 'YYYY-MM-DD')";
|
||||
}
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Agent;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
|
||||
class AgentController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$query = DB::table('ADMIN_SKT.TM_AGEN AS A')
|
||||
->leftJoin('ADMIN_SKT.D_KTR AS K', 'A.KTR_ADMINISTRASI', '=', 'K.KDKTR')
|
||||
->leftJoin('ADMIN_SKT.RF_JABATAN_AGEN AS J', 'A.KD_JABATAN_AGEN', '=', 'J.KD_JABATAN')
|
||||
->select(
|
||||
'A.NO_AGEN',
|
||||
'A.NAMA',
|
||||
'J.SINGKATAN_JABATAN',
|
||||
'K.KDKTR',
|
||||
'K.NMKTR',
|
||||
DB::raw("TO_CHAR(A.TGL_LISENSI_AKHIR, 'DD-MM-YYYY') AS TGL_LISENSI_AKHIR")
|
||||
);
|
||||
|
||||
// Filter based on search input
|
||||
if ($request->filled('no_agen')) {
|
||||
$query->where('A.NO_AGEN', 'like', '%' . $request->input('no_agen') . '%');
|
||||
}
|
||||
if ($request->filled('nama')) {
|
||||
$query->where(DB::raw('LOWER(A.NAMA)'), 'like', '%' . strtolower($request->input('nama')) . '%');
|
||||
}
|
||||
if ($request->filled('title')) {
|
||||
$query->where(DB::raw('LOWER(J.SINGKATAN_JABATAN)'), 'like', '%' . strtolower($request->input('title')) . '%');
|
||||
}
|
||||
if ($request->filled('kpa_code')) {
|
||||
$query->where('K.KDKTR', 'like', '%' . $request->input('kpa_code') . '%');
|
||||
}
|
||||
if ($request->filled('kpa_name')) {
|
||||
$query->where('K.NMKTR', 'like', '%' . $request->input('kpa_name') . '%');
|
||||
}
|
||||
|
||||
// Add condition for TGL_LISENSI_AKHIR
|
||||
$query->where('A.TGL_LISENSI_AKHIR', '>=', DB::raw('SYSDATE'));
|
||||
|
||||
// Sort and get results
|
||||
$query->orderBy('A.NO_AGEN', 'asc');
|
||||
|
||||
$results = $query->get();
|
||||
return DataTables::of($results)->make(true); // Get the final results
|
||||
|
||||
// Uncomment the line below to return results in JSON format if needed
|
||||
// return response()->json($results);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Foundation\Auth\ConfirmsPasswords;
|
||||
|
||||
class ConfirmPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Confirm Password Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password confirmations and
|
||||
| uses a simple trait to include the behavior. You're free to explore
|
||||
| this trait and override any functions that require customization.
|
||||
|
|
||||
*/
|
||||
|
||||
use ConfirmsPasswords;
|
||||
|
||||
/**
|
||||
* Where to redirect users when the intended url fails.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = RouteServiceProvider::HOME;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
|
||||
class ForgotPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset emails and
|
||||
| includes a trait which assists in sending these notifications from
|
||||
| your application to your users. Feel free to explore this trait.
|
||||
|
|
||||
*/
|
||||
|
||||
use SendsPasswordResetEmails;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Login Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles authenticating users for the application and
|
||||
| redirecting them to your home screen. The controller uses a trait
|
||||
| to conveniently provide its functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = RouteServiceProvider::HOME;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest')->except('logout');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use App\User;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles the registration of new users as well as their
|
||||
| validation and creation. By default this controller uses a trait to
|
||||
| provide this functionality without requiring any additional code.
|
||||
|
|
||||
*/
|
||||
|
||||
use RegistersUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after registration.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = RouteServiceProvider::HOME;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
protected function validator(array $data)
|
||||
{
|
||||
return Validator::make($data, [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \App\User
|
||||
*/
|
||||
protected function create(array $data)
|
||||
{
|
||||
return User::create([
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'password' => Hash::make($data['password']),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset requests
|
||||
| and uses a simple trait to include this behavior. You're free to
|
||||
| explore this trait and override any methods you wish to tweak.
|
||||
|
|
||||
*/
|
||||
|
||||
use ResetsPasswords;
|
||||
|
||||
/**
|
||||
* Where to redirect users after resetting their password.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = RouteServiceProvider::HOME;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Foundation\Auth\VerifiesEmails;
|
||||
|
||||
class VerificationController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Email Verification Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling email verification for any
|
||||
| user that recently registered with the application. Emails may also
|
||||
| be re-sent if the user didn't receive the original email message.
|
||||
|
|
||||
*/
|
||||
|
||||
use VerifiesEmails;
|
||||
|
||||
/**
|
||||
* Where to redirect users after verification.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = RouteServiceProvider::HOME;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->middleware('signed')->only('verify');
|
||||
$this->middleware('throttle:6,1')->only('verify', 'resend');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Backend;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\AdminRequest;
|
||||
use App\Models\Admin;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class AdminsController extends Controller
|
||||
{
|
||||
|
||||
public function index(): Renderable
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['admin.view']);
|
||||
|
||||
$pageInfo = [
|
||||
'title' => 'User Access List',
|
||||
'sub_title' => 'List User Access System',
|
||||
'path' => url()->current()
|
||||
];
|
||||
|
||||
return view('backend.pages.admins.index', [
|
||||
'admins' => Admin::all(),
|
||||
'pageInfo' => $pageInfo
|
||||
]);
|
||||
}
|
||||
|
||||
public function create(): Renderable
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['admin.create']);
|
||||
|
||||
$pageInfo = [
|
||||
'title' => 'Create User Access',
|
||||
'sub_title' => 'Create new User',
|
||||
'path' => url()->current()
|
||||
];
|
||||
|
||||
return view('backend.pages.admins.create', [
|
||||
'roles' => Role::all(),
|
||||
'pageInfo' => $pageInfo
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(AdminRequest $request): RedirectResponse
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['admin.create']);
|
||||
|
||||
$admin = new Admin();
|
||||
$admin->name = $request->name;
|
||||
$admin->password = Hash::make($request->password);
|
||||
$admin->username = $request->username;
|
||||
$admin->email = $request->email;
|
||||
$admin->save();
|
||||
|
||||
if ($request->roles) {
|
||||
$admin->assignRole($request->roles);
|
||||
}
|
||||
|
||||
session()->flash('success', __('Admin has been created.'));
|
||||
return redirect()->route('admin.admins.index');
|
||||
}
|
||||
|
||||
public function edit(int $id): Renderable
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['admin.edit']);
|
||||
|
||||
$pageInfo = [
|
||||
'title' => 'Edit User Access',
|
||||
'sub_title' => 'Update User Access data',
|
||||
'path' => url()->current()
|
||||
];
|
||||
|
||||
|
||||
$admin = Admin::findOrFail($id);
|
||||
return view('backend.pages.admins.edit', [
|
||||
'admin' => $admin,
|
||||
'roles' => Role::all(),
|
||||
'pageInfo' => $pageInfo
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(AdminRequest $request, int $id): RedirectResponse
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['admin.edit']);
|
||||
|
||||
$admin = Admin::findOrFail($id);
|
||||
$admin->name = $request->name;
|
||||
$admin->email = $request->email;
|
||||
$admin->username = $request->username;
|
||||
|
||||
if ($request->password) {
|
||||
$admin->password = Hash::make($request->password);
|
||||
}
|
||||
$admin->save();
|
||||
$admin->roles()->detach();
|
||||
if ($request->roles) {
|
||||
$admin->assignRole($request->roles);
|
||||
}
|
||||
|
||||
session()->flash('success', 'Admin has been updated.');
|
||||
return back();
|
||||
}
|
||||
|
||||
public function destroy(int $id): RedirectResponse
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['admin.delete']);
|
||||
|
||||
$admin = Admin::findOrFail($id);
|
||||
$admin->delete();
|
||||
session()->flash('success', 'Admin has been deleted.');
|
||||
return back();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Backend\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Foundation\Auth\ConfirmsPasswords;
|
||||
|
||||
class ConfirmPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Confirm Password Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password confirmations and
|
||||
| uses a simple trait to include the behavior. You're free to explore
|
||||
| this trait and override any functions that require customization.
|
||||
|
|
||||
*/
|
||||
|
||||
use ConfirmsPasswords;
|
||||
|
||||
/**
|
||||
* Where to redirect users when the intended url fails.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = RouteServiceProvider::HOME;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Backend\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
|
||||
class ForgotPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset emails and
|
||||
| includes a trait which assists in sending these notifications from
|
||||
| your application to your users. Feel free to explore this trait.
|
||||
|
|
||||
*/
|
||||
|
||||
use SendsPasswordResetEmails;
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Backend\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Exception;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Login Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles authenticating users for the application and
|
||||
| redirecting them to your home screen. The controller uses a trait
|
||||
| to conveniently provide its functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo;
|
||||
|
||||
/**
|
||||
* show login form for admin guard
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function showLoginForm()
|
||||
{
|
||||
return view('backend.auth.login');
|
||||
}
|
||||
|
||||
|
||||
protected function redirectTo()
|
||||
{
|
||||
if (Auth::guard('admin')->check()) {
|
||||
// Redirect admins to their dashboard
|
||||
return RouteServiceProvider::ADMIN_DASHBOARD;
|
||||
}
|
||||
|
||||
if (Auth::guard('web')->check()) {
|
||||
// Redirect users to the home page
|
||||
return redirect()->route('trx_order_elevation.index');
|
||||
}
|
||||
|
||||
// Default redirection (optional)
|
||||
return '/login';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* login admin
|
||||
*
|
||||
* @param Request $request
|
||||
* @return void
|
||||
*/
|
||||
public function login(Request $request)
|
||||
{
|
||||
// Validate Login Data
|
||||
$request->validate([
|
||||
'email' => 'required|max:50',
|
||||
'password' => 'required',
|
||||
]);
|
||||
|
||||
// Attempt to login
|
||||
if (Auth::guard('admin')->attempt(['email' => $request->email, 'password' => $request->password], $request->remember)) {
|
||||
session()->flash('success', 'Successully Logged in !');
|
||||
Session::put('current_guard', 'admin');
|
||||
return redirect()->route('admin.dashboard');
|
||||
} else if (Auth::guard('admin')->attempt(['username' => $request->email, 'password' => $request->password], $request->remember)) {
|
||||
session()->flash('success', 'Successully Logged in !');
|
||||
Session::put('current_guard', 'admin');
|
||||
return redirect()->route('admin.dashboard');
|
||||
|
||||
}else if (Auth::guard('web')->attempt(['username' => $request->email, 'password' => $request->password], $request->remember)) {
|
||||
session()->flash('success', 'Successully Logged in !');
|
||||
Session::put('current_guard', 'web');
|
||||
return redirect()->route('admin.dashboard');
|
||||
}else if (Auth::guard('web')->attempt(['email' => $request->email, 'password' => $request->password], $request->remember)) {
|
||||
session()->flash('success', 'Successully Logged in !');
|
||||
Session::put('current_guard', 'web');
|
||||
return redirect()->route('admin.dashboard');
|
||||
}
|
||||
// error
|
||||
session()->flash('error', 'Invalid email and password..');
|
||||
return back();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* logout admin guard
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function logout()
|
||||
{
|
||||
try{
|
||||
Auth::guard('admin')->logout();
|
||||
return redirect()->route('admin.login');
|
||||
|
||||
}catch (Exception $e) {
|
||||
Auth::guard('web')->logout();
|
||||
return redirect()->route('admin.login');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Backend\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset requests
|
||||
| and uses a simple trait to include this behavior. You're free to
|
||||
| explore this trait and override any methods you wish to tweak.
|
||||
|
|
||||
*/
|
||||
|
||||
use ResetsPasswords;
|
||||
|
||||
/**
|
||||
* Where to redirect users after resetting their password.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = RouteServiceProvider::HOME;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Backend;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Admin;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
|
||||
return view(
|
||||
'backend.pages.dashboard.index',
|
||||
[
|
||||
'total_admins' => Admin::count(),
|
||||
'total_roles' => Role::count(),
|
||||
'total_permissions' => Permission::count(),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Backend;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class MenuRoleController extends Controller
|
||||
{
|
||||
public function index($roleId)
|
||||
{
|
||||
// Ambil semua data dari tabel menus
|
||||
$menus = DB::table('menus')
|
||||
->orderBy('parent_id', 'ASC')
|
||||
->orderBy('order', 'ASC')
|
||||
->get();
|
||||
|
||||
$savedMenuIds = DB::table('role_menu')
|
||||
->where('role_id', $roleId)
|
||||
->pluck('menu_id')
|
||||
->toArray();
|
||||
|
||||
|
||||
// Jika $savedMenuIds null, set ke array kosong
|
||||
if (is_null($savedMenuIds)) {
|
||||
$savedMenuIds = [];
|
||||
}
|
||||
|
||||
// Membentuk struktur tree
|
||||
$menuTree = $this->buildTree($menus, $savedMenuIds);
|
||||
|
||||
$pageInfo = [
|
||||
'title' => 'Assign Role Menu',
|
||||
'sub_title' => 'Assign Role in Menu',
|
||||
'path' => url()->current()
|
||||
];
|
||||
|
||||
return view('backend.pages.menurole.index', [
|
||||
'menuTree' => $menuTree,
|
||||
'pageInfo' => $pageInfo,
|
||||
'role_id' => $roleId
|
||||
]);
|
||||
}
|
||||
|
||||
private function buildTree($menus, $savedMenuIds, $parentId = 0)
|
||||
{
|
||||
$tree = [];
|
||||
foreach ($menus as $menu) {
|
||||
if ($menu->parent_id == $parentId) {
|
||||
$children = $this->buildTree($menus, $savedMenuIds, $menu->id);
|
||||
|
||||
$node = [
|
||||
'id' => $menu->id,
|
||||
'text' => $menu->title,
|
||||
'attributes' => ['url' => $menu->url],
|
||||
'checked' => in_array($menu->id, $savedMenuIds)
|
||||
];
|
||||
|
||||
if ($children) {
|
||||
$node['children'] = $children;
|
||||
}
|
||||
|
||||
$tree[] = $node;
|
||||
}
|
||||
}
|
||||
return $tree;
|
||||
}
|
||||
|
||||
public function saveMenu(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'menu_ids' => 'required',
|
||||
'role_id' => 'required|integer'
|
||||
]);
|
||||
$selectedMenuIds = json_decode($request->input('menu_ids', '[]'));
|
||||
$roleId = $request->input('role_id');
|
||||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
DB::table('role_menu')->where('role_id', $roleId)->delete();
|
||||
$dataToInsert = [];
|
||||
foreach ($selectedMenuIds as $menuId) {
|
||||
$results = DB::select('SELECT parent_id FROM menus WHERE id = ?', [$menuId]);
|
||||
if($results[0]->parent_id){ //jika memiliki parent_id, insert juga
|
||||
$dataToInsert[] = [
|
||||
'menu_id' => $results[0]->parent_id,
|
||||
'role_id' => $roleId
|
||||
];
|
||||
}
|
||||
$dataToInsert[] = [
|
||||
'menu_id' => $menuId,
|
||||
'role_id' => $roleId
|
||||
];
|
||||
}
|
||||
|
||||
$dataToInsert = array_unique(array_map('serialize', $dataToInsert));
|
||||
$dataToInsert = array_map('unserialize', $dataToInsert);
|
||||
|
||||
DB::table('role_menu')->insert($dataToInsert);
|
||||
DB::commit();
|
||||
return response()->json(['success' => true], 200);
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
return response()->json(['success' => false, 'error' => $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Backend;
|
||||
|
||||
use App\User;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\RoleRequest;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
|
||||
class RolesController extends Controller
|
||||
{
|
||||
public function index(): Renderable
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['role.view']);
|
||||
$pageInfo = [
|
||||
'title' => 'List Roles',
|
||||
'sub_title' => 'List All User Roles',
|
||||
'path' => url()->current()
|
||||
];
|
||||
return view('backend.pages.roles.index', [
|
||||
'roles' => Role::all(), 'pageInfo' => $pageInfo
|
||||
]);
|
||||
}
|
||||
|
||||
public function create(): Renderable
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['role.create']);
|
||||
|
||||
$pageInfo = [
|
||||
'title' => 'Create Roles',
|
||||
'sub_title' => 'Create User Roles',
|
||||
'path' => url()->current()
|
||||
];
|
||||
|
||||
return view('backend.pages.roles.create', [
|
||||
'all_permissions' => Permission::all(),
|
||||
'permission_groups' => User::getpermissionGroups(),
|
||||
'pageInfo' => $pageInfo
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(RoleRequest $request): RedirectResponse
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['role.create']);
|
||||
|
||||
// Process Data.
|
||||
$role = Role::create(['name' => $request->name, 'guard_name' => 'admin']);
|
||||
|
||||
// $role = DB::table('roles')->where('name', $request->name)->first();
|
||||
$permissions = $request->input('permissions');
|
||||
|
||||
if (!empty($permissions)) {
|
||||
$role->syncPermissions($permissions);
|
||||
}
|
||||
|
||||
session()->flash('success', 'Role has been created.');
|
||||
return redirect()->route('admin.roles.index');
|
||||
}
|
||||
|
||||
public function edit(int $id): Renderable|RedirectResponse
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['role.edit']);
|
||||
|
||||
$role = Role::findById($id, 'admin');
|
||||
if (!$role) {
|
||||
session()->flash('error', 'Role not found.');
|
||||
return back();
|
||||
}
|
||||
|
||||
$pageInfo = [
|
||||
'title' => 'Create Roles',
|
||||
'sub_title' => 'Create User Roles',
|
||||
'path' => url()->current()
|
||||
];
|
||||
|
||||
return view('backend.pages.roles.edit', [
|
||||
'role' => $role,
|
||||
'all_permissions' => Permission::all(),
|
||||
'permission_groups' => User::getpermissionGroups(),
|
||||
'pageInfo' => $pageInfo
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(RoleRequest $request, int $id): RedirectResponse
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['role.edit']);
|
||||
|
||||
$role = Role::findById($id, 'admin');
|
||||
if (!$role) {
|
||||
session()->flash('error', 'Role not found.');
|
||||
return back();
|
||||
}
|
||||
|
||||
$permissions = $request->input('permissions');
|
||||
if (!empty($permissions)) {
|
||||
$role->name = $request->name;
|
||||
$role->save();
|
||||
$role->syncPermissions($permissions);
|
||||
}
|
||||
|
||||
session()->flash('success', 'Role has been updated.');
|
||||
return back();
|
||||
}
|
||||
|
||||
public function destroy(int $id): RedirectResponse
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['role.delete']);
|
||||
|
||||
$role = Role::findById($id, 'admin');
|
||||
if (!$role) {
|
||||
session()->flash('error', 'Role not found.');
|
||||
return back();
|
||||
}
|
||||
|
||||
$role->delete();
|
||||
session()->flash('success', 'Role has been deleted.');
|
||||
return redirect()->route('admin.roles.index');
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,16 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
abstract class Controller
|
||||
use App\Traits\AuthorizationChecker;
|
||||
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, AuthorizationChecker;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,700 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class GenerateDataMasterController extends Controller
|
||||
{
|
||||
public function GetMsBasicProduct()
|
||||
{
|
||||
$data = DB::table('MS_BASIC_PRODUCT')
|
||||
->select('ID', 'DESCRIPTION')
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->id,
|
||||
'text' => $item->description,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
public function GetMsSpajkStatus()
|
||||
{
|
||||
$data = DB::table('SPAJK_STATUS')
|
||||
->select('ID', 'DESCRIPTION')
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->id,
|
||||
'text' => $item->description,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
public function GetMsMarketingType()
|
||||
{
|
||||
$data = DB::table('MS_MARKETING_TYPE')
|
||||
->select('ID', 'DESCRIPTION')
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->id,
|
||||
'text' => $item->description,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
public function GetMsDeliveryStatus()
|
||||
{
|
||||
$data = DB::table('MS_DELIVERY_STATUS')
|
||||
->select('ID', 'DESCRIPTION')
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->id,
|
||||
'text' => $item->description,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
public function GetMsPartner()
|
||||
{
|
||||
$data = DB::table('MS_PARTNER')
|
||||
->select('ID', 'DESCRIPTION')
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->id,
|
||||
'text' => $item->description,
|
||||
];
|
||||
});
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
public function GetMsPartnerRegion($id)
|
||||
{
|
||||
|
||||
$data = DB::table('MS_PARTNER_REGION')
|
||||
->select('ID', 'DESCRIPTION')
|
||||
->where('PARTNER_CODE', $id)
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->id,
|
||||
'text' => $item->description,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
public function GetMsPaymentMethod()
|
||||
{
|
||||
$data = DB::table('MS_PAYMENT_METHOD')
|
||||
->select('ID', 'DESCRIPTION')
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->id,
|
||||
'text' => $item->description,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
public function GetMsCountry()
|
||||
{
|
||||
$data = DB::table('MS_COUNTRY')
|
||||
->select('ID', 'COUNTRY_NAME', 'COUNTRY_CODE')
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->id,
|
||||
'text' => $item->country_name,
|
||||
'code' => $item->country_code
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
|
||||
public function GetMsNationality()
|
||||
{
|
||||
$data = DB::table('MS_NATIONALITY')
|
||||
->select('ID', 'DESCRIPTION')
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->id,
|
||||
'text' => $item->description,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function GetMsProvince()
|
||||
{
|
||||
$data = DB::table('MS_PROVINCE')
|
||||
->select('ID', 'DESCRIPTION','CODE')
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->code,
|
||||
'text' => $item->code.' - '.$item->description,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
|
||||
public function GetMsCity($provinceId)
|
||||
{
|
||||
$data = DB::table('MS_CITY')
|
||||
->select('ID', 'NAME','CODE')
|
||||
->where('PROVINCE_CODE', $provinceId)
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->code,
|
||||
'text' => $item->code.' - '.$item->name,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function GetMsDistrict($cityId)
|
||||
{
|
||||
$data = DB::table('MS_DISTRICT')
|
||||
->select('ID', 'NAME','CODE')
|
||||
->where('CITY_CODE', $cityId)
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->code,
|
||||
'text' => $item->code.' - '.$item->name,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
|
||||
public function GetMsSubDistrict($districtId)
|
||||
{
|
||||
$data = DB::table('MS_SUB_DISTRICT')
|
||||
->select('ID', 'NAME','CODE')
|
||||
->where('DISTRICT_CODE', $districtId)
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->code,
|
||||
'text' => $item->code.' - '.$item->name,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
|
||||
public function GetMsJobType()
|
||||
{
|
||||
$data = DB::table('MS_JOB_TYPE')
|
||||
->select('ID', 'DESCRIPTION')
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->id,
|
||||
'text' => $item->description,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
public function GetMsPartnerBranch($id)
|
||||
{
|
||||
$data = DB::table('MS_PARTNER_BRANCH')
|
||||
->select('ID', 'DESCRIPTION')
|
||||
->where('PARTNER_REGION_CODE', $id)
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->id,
|
||||
'text' => $item->description,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
public function GetMsPartnerUnit($id)
|
||||
{
|
||||
$data = DB::table('MS_PARTNER_UNIT')
|
||||
->select('ID', 'DESCRIPTION')
|
||||
->where('PARTNER_BRANCH_CODE', $id)
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->id,
|
||||
'text' => $item->description,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
public function GetMsIdentityType()
|
||||
{
|
||||
$data = DB::table('MS_IDENTITY_TYPE')
|
||||
->select('ID', 'DESCRIPTION')
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->id,
|
||||
'text' => $item->description,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
public function GetMsChannel($code)
|
||||
{
|
||||
$data = DB::table('MS_CHANNEL')
|
||||
->select('ID', 'DESCRIPTION')
|
||||
->where('MARKETING_TYPE', $code)
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => trim($item->id),
|
||||
'text' => $item->description,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
public function GetMsChannelList()
|
||||
{
|
||||
$data = DB::table('MS_CHANNEL')
|
||||
->select('ID', 'DESCRIPTION')
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => trim($item->id),
|
||||
'text' => $item->description,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
public function GetMsDistribution()
|
||||
{
|
||||
$data = DB::table('MS_DISTRIBUTION_CHANNEL')
|
||||
->select('ID', 'DESCRIPTION')
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->id,
|
||||
'text' => $item->description,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
public function GetProduct()
|
||||
{
|
||||
$data = DB::table('PRODUCT')
|
||||
->select('ID', 'DESCRIPTION')
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->id,
|
||||
'text' => $item->description,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
public function GetProductCategory()
|
||||
{
|
||||
$data = DB::table('MS_PRODUCT_CATEGORY')
|
||||
->select('ID', 'DESCRIPTION')
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => trim($item->id),
|
||||
'text' => $item->description,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
public function GetOptions()
|
||||
{
|
||||
$roundingType = DB::table('MS_OPTIONS')
|
||||
->select('CODE', 'DESCRIPTION')
|
||||
->get();
|
||||
|
||||
$dropdownList = $roundingType->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->code,
|
||||
'text' => $item->description,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
public function GetRoundingType()
|
||||
{
|
||||
$roundingType = DB::table('MS_ROUNDING_TYPE')
|
||||
->select('ID', 'DESCRIPTION')
|
||||
->get();
|
||||
|
||||
$dropdownList = $roundingType->map(function ($item) {
|
||||
return [
|
||||
'value' => trim($item->id),
|
||||
'text' => $item->description,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
public function GetBank()
|
||||
{
|
||||
$roundingType = DB::table('MS_BANK')
|
||||
->select('ID', 'DESCRIPTION')
|
||||
->orderBy('DESCRIPTION', 'asc')
|
||||
->get();
|
||||
|
||||
$dropdownList = $roundingType->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->id,
|
||||
'text' => $item->description,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
public function GetMsSpajkdocument()
|
||||
{
|
||||
$roundingType = DB::table('MS_DOCUMENT_SPAJK')
|
||||
->select('ID', 'DESCRIPTION')
|
||||
->get();
|
||||
|
||||
$dropdownList = $roundingType->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->id,
|
||||
'text' => $item->description,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
|
||||
public function GetDocumentFormat()
|
||||
{
|
||||
$roundingType = DB::table('MS_DOCUMENT_FORMAT')
|
||||
->select('ID', 'DESCRIPTION')
|
||||
->get();
|
||||
|
||||
$dropdownList = $roundingType->map(function ($item) {
|
||||
return [
|
||||
'value' => trim($item->id),
|
||||
'text' => $item->description,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
public function GetMsDocumentSendTo()
|
||||
{
|
||||
$products = DB::table('MS_DOCUMENT_SENDTO')
|
||||
->select('ID', 'DESCRIPTION')
|
||||
->get();
|
||||
|
||||
$dropdownList = $products->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->id,
|
||||
'text' => $item->description,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
public function GetMsAutoUwStatus()
|
||||
{
|
||||
$products = DB::table('MS_AUTOUW_STATUS')
|
||||
->select('ID', 'DESCRIPTION')
|
||||
->get();
|
||||
|
||||
$dropdownList = $products->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->id,
|
||||
'text' => $item->description,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
public function GetSpajkStatus()
|
||||
{
|
||||
$products = DB::table('SPAJK_STATUS')
|
||||
->select('ID', 'DESCRIPTION')
|
||||
->whereIn('code', ['SWA', 'UPE', 'UPO', 'UDE', 'UAP'])
|
||||
->get();
|
||||
|
||||
$dropdownList = $products->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->id,
|
||||
'text' => $item->description,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
public function GetMsPolicyByPartner($id)
|
||||
{
|
||||
$products = DB::table('POLICY')
|
||||
->select('ID', 'POLICY_NO', 'PARTNER_CODE')
|
||||
->where('PARTNER_CODE', $id)
|
||||
->get();
|
||||
|
||||
$dropdownList = $products->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->id,
|
||||
'text' => $item->policy_no,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
public function GetMsPolicyProduct($id)
|
||||
{
|
||||
$products = DB::table('POLICY_PRODUCT')
|
||||
->join('PRODUCT', 'POLICY_PRODUCT.PRODUCT_ID', '=', 'PRODUCT.ID')
|
||||
->join('MS_MARKETING_TYPE', 'PRODUCT.MARKETING_TYPE', '=', 'MS_MARKETING_TYPE.ID')
|
||||
->join('MS_CHANNEL', 'PRODUCT.CHANNEL_CODE', '=', 'MS_CHANNEL.ID')
|
||||
->select('POLICY_PRODUCT.POLICY_ID AS POLICY_ID', 'MS_MARKETING_TYPE.DESCRIPTION AS MARKETING', 'MS_CHANNEL.DESCRIPTION AS CHANNEL', 'MS_MARKETING_TYPE.ID AS MARKETING_ID', 'MS_CHANNEL.ID AS CHANNEL_ID')
|
||||
->where('POLICY_PRODUCT.POLICY_ID', $id)
|
||||
->get();
|
||||
|
||||
$dropdownList = $products->map(function ($item) {
|
||||
return $item;
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
|
||||
public function getAllMsCity()
|
||||
{
|
||||
$data = DB::table('MS_CITY')
|
||||
->select('ID', 'NAME','CODE')
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->code,
|
||||
'text' => $item->code.' - '.$item->name,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
public function getAllMsDistrict()
|
||||
{
|
||||
$data = DB::table('MS_DISTRICT')
|
||||
->select('ID', 'NAME','CODE')
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->code,
|
||||
'text' => $item->code.' - '.$item->name,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
|
||||
public function getAllMsSubDistrict()
|
||||
{
|
||||
$data = DB::table('MS_SUB_DISTRICT')
|
||||
->select('ID', 'NAME','CODE')
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->code,
|
||||
'text' => $item->code.' - '.$item->name,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
public function GetMsGender()
|
||||
{
|
||||
$data = DB::table('MS_GENDER')
|
||||
->select('ID', 'CODE','DESCRIPTION')
|
||||
->orderBy('DESCRIPTION', 'ASC')
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->code,
|
||||
'text' => $item->description,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
public function GetMsLoanType()
|
||||
{
|
||||
$data = DB::table('MS_LOAN_TYPE')
|
||||
->select('ID', 'CODE','DESCRIPTION')
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->id,
|
||||
'text' => $item->description,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
public function GetMsPendingUWType()
|
||||
{
|
||||
$data = DB::table('MS_PENDING_UW')
|
||||
->select('ID','CODE', 'NAME')
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->id,
|
||||
'text' => $item->code.' - '.$item->name,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
public function GetMsMedicalType()
|
||||
{
|
||||
$data = DB::table('MS_MEDICAL_TYPE')
|
||||
->select('ID','CODE', 'DESCRIPTION')
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->id,
|
||||
'text' => $item->description,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
|
||||
public function GetMsEM()
|
||||
{
|
||||
$data = DB::table('MS_EXTRA_MORTALITY')
|
||||
->select('ID','CODE', 'DESCRIPTION')
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->id,
|
||||
'text' => $item->description,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
public function GetMsClIcd()
|
||||
{
|
||||
$data = DB::table('MS_CL_ICD')
|
||||
->select('ID', 'ICD_CODE','ICD_SHORT_DESC')
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->id,
|
||||
'text' => $item->icd_code.' - '.$item->icd_short_desc,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
public function GetMsDecision()
|
||||
{
|
||||
$data = DB::table('MS_UW_DECISION')
|
||||
->select('ID', 'CODE','DESCRIPTION')
|
||||
->get();
|
||||
|
||||
$dropdownList = $data->map(function ($item) {
|
||||
return [
|
||||
'value' => $item->code,
|
||||
'text' => $item->description
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($dropdownList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
public function redirectAdmin()
|
||||
{
|
||||
return redirect()->route('admin.dashboard');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Support\Renderable
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('home');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?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
|
||||
*/
|
||||
protected $middleware = [
|
||||
// \App\Http\Middleware\TrustHosts::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
\App\Http\Middleware\CheckForMaintenanceMode::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
|
||||
*/
|
||||
protected $middlewareGroups = [
|
||||
|
||||
'web' => [
|
||||
\App\Http\Middleware\LogLoginMiddleware::class,
|
||||
\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' => [
|
||||
'throttle:60,1',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware.
|
||||
*
|
||||
* These middleware may be assigned to groups or used individually.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'cache.css' => \App\Http\Middleware\CacheCssMiddleware::class,
|
||||
'menu' => \App\Http\Middleware\MenuMiddleware::class,
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::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,
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
|
||||
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 (Auth::guard('admin')) {
|
||||
if (!$request->expectsJson()) {
|
||||
return route('admin.login');
|
||||
}
|
||||
} else {
|
||||
if (!$request->expectsJson()) {
|
||||
return route('login');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CacheCssMiddleware
|
||||
{
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
$response = $next($request);
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
|
||||
|
||||
class CheckForMaintenanceMode extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be reachable while maintenance mode is enabled.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
@@ -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
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Models\LoginLog;
|
||||
|
||||
class LogLoginMiddleware
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
if (Auth::check()) {
|
||||
$user = Auth::user();
|
||||
|
||||
// Cek apakah sudah ada log login terbaru (opsional)
|
||||
$latestLog = LoginLog::where('user_id', $user->id)
|
||||
->latest()
|
||||
->first();
|
||||
|
||||
if (!$latestLog || $latestLog->created_at->diffInMinutes(now()) > 5) { // Interval waktu opsional
|
||||
LoginLog::create([
|
||||
'user_id' => $user->id,
|
||||
'ip_address' => $request->ip(),
|
||||
'user_agent' => $request->userAgent(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Spatie\Menu\Laravel\Facades\Menu;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
|
||||
class MenuMiddleware
|
||||
{
|
||||
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$menu = Menu::new()
|
||||
->addClass('nav nav-pills nav-sidebar flex-column nav-flat')
|
||||
->setWrapperTag('ul')
|
||||
->setAttributes([
|
||||
'data-widget' => 'treeview',
|
||||
'role' => 'menu',
|
||||
'data-accordion' => 'false'
|
||||
]);
|
||||
|
||||
$menu->html('<li class="nav-item">
|
||||
<a href="'.url('/').'" class="nav-link">
|
||||
<i class="nav-icon mdi mdi-home"></i>
|
||||
<p>Halaman Utama </p>
|
||||
</a>
|
||||
</li>');
|
||||
|
||||
// Ambil data menu utama
|
||||
$user = Auth::guard('admin')->user();
|
||||
$role = $user->roles->first();
|
||||
$currentRoleId = $role ? $role->id : null;
|
||||
|
||||
$menus = DB::select("
|
||||
SELECT m.*, rm.menu_id AS assigned_menu_id
|
||||
FROM menus m
|
||||
LEFT JOIN role_menu rm
|
||||
ON m.id = rm.menu_id
|
||||
WHERE m.parent_id IS NULL AND rm.role_id = '".$currentRoleId."'
|
||||
ORDER BY m.id
|
||||
");
|
||||
|
||||
|
||||
|
||||
foreach ($menus as $item) {
|
||||
// Ambil submenu jika ada
|
||||
$children = DB::select("
|
||||
SELECT m.*, rm.menu_id AS assigned_menu_id
|
||||
FROM menus m
|
||||
LEFT JOIN role_menu rm
|
||||
ON m.id = rm.menu_id
|
||||
WHERE m.parent_id = '".$item->id."' AND rm.role_id = '".$currentRoleId."'
|
||||
ORDER BY m.id
|
||||
");
|
||||
|
||||
|
||||
|
||||
if (isset($children)) {
|
||||
// Menu dengan child
|
||||
$submenu = Menu::new()->addClass('nav nav-treeview');
|
||||
|
||||
foreach ($children as $child) {
|
||||
|
||||
$submenu->html(
|
||||
'<li class="nav-item">' .
|
||||
'<a href="' . url($child->url) . '" class="nav-link">' .
|
||||
'<i class="' . $child->icon . ' nav-icon"></i>' .
|
||||
'<p>' . $child->title . '</p>' .
|
||||
'</a>' .
|
||||
'</li>'
|
||||
);
|
||||
}
|
||||
$menu->html(
|
||||
'<li class="nav-item">' .
|
||||
'<a href="#" class="nav-link">' .
|
||||
'<i class="nav-icon ' . $item->icon . '"></i>' .
|
||||
'<p>' . $item->title . '<i class="fas fa-angle-left right"></i></p>' .
|
||||
'</a>' .
|
||||
$submenu->render() .
|
||||
'</li>'
|
||||
);
|
||||
} else {
|
||||
// Menu tanpa child
|
||||
$menu->html(
|
||||
'<li class="nav-item">' .
|
||||
'<a href="' . url($item->url) . '" class="nav-link">' .
|
||||
'<i class="nav-icon ' . $item->icon . '"></i>' .
|
||||
'<p>' . $item->title . '</p>' .
|
||||
'</a>' .
|
||||
'</li>'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
view()->share('menu', $menu->render());
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string|null $guard
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next, $guard = null)
|
||||
{
|
||||
if(Auth::guard('admin')->check()){
|
||||
return redirect(RouteServiceProvider::ADMIN_DASHBOARD);
|
||||
}
|
||||
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect(RouteServiceProvider::HOME);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?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
|
||||
*/
|
||||
protected $except = [
|
||||
'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
|
||||
*/
|
||||
public function hosts()
|
||||
{
|
||||
return [
|
||||
$this->allSubdomainsOfApplicationUrl(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?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|string
|
||||
*/
|
||||
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
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class AdminRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$adminId = $this->route('admin');
|
||||
|
||||
return [
|
||||
'name' => 'required|max:50',
|
||||
'email' => 'required|max:100|email|unique:admins,email,' . $adminId,
|
||||
'username' => 'required|max:100|unique:admins,username,' . $adminId,
|
||||
'password' => $adminId ? 'nullable|confirmed' : 'confirmed',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class RoleRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$roleId = $this->route('role');
|
||||
|
||||
return [
|
||||
'name' => 'required|max:100|unique:roles,name,' . $roleId,
|
||||
'permissions' => 'required|array|min:1',
|
||||
'permissions.*' => 'string|exists:permissions,name',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
use Illuminate\Auth\Events\Login;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use App\Models\LoginLog;
|
||||
|
||||
class LogLoginActivity
|
||||
{
|
||||
/**
|
||||
* Create the event listener.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*/
|
||||
public function handle(Login $event): void
|
||||
{
|
||||
// Ambil data user yang login
|
||||
$user = $event->user;
|
||||
|
||||
// Simpan log login
|
||||
LoginLog::create([
|
||||
'user_id' => $user->id,
|
||||
'ip_address' => request()->ip(),
|
||||
'user_agent' => request()->userAgent(),
|
||||
'status' => 'login',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
use Illuminate\Auth\Events\Logout;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use App\Models\LoginLog;
|
||||
|
||||
class LogLogoutActivity
|
||||
{
|
||||
/**
|
||||
* Create the event listener.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*/
|
||||
public function handle(Logout $event): void
|
||||
{
|
||||
// Ambil data user yang logout
|
||||
$user = $event->user;
|
||||
|
||||
// Simpan log logout
|
||||
LoginLog::create([
|
||||
'user_id' => $user->id,
|
||||
'ip_address' => request()->ip(),
|
||||
'user_agent' => request()->userAgent(),
|
||||
'status' => 'logout', // Kolom tambahan untuk menandakan logout
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
|
||||
class Admin extends Authenticatable
|
||||
{
|
||||
use Notifiable, HasRoles;
|
||||
|
||||
/**
|
||||
* Set the default guard for this model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $guard_name = 'admin';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name', 'email', 'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password', 'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
|
||||
public static function getpermissionGroups()
|
||||
{
|
||||
$permission_groups = DB::table('permissions')
|
||||
->select('group_name as name')
|
||||
->groupBy('group_name')
|
||||
->get();
|
||||
return $permission_groups;
|
||||
}
|
||||
|
||||
public static function getpermissionsByGroupName($group_name)
|
||||
{
|
||||
$permissions = DB::table('permissions')
|
||||
->select('name', 'id')
|
||||
->where('group_name', $group_name)
|
||||
->get();
|
||||
return $permissions;
|
||||
}
|
||||
|
||||
public static function roleHasPermissions($role, $permissions)
|
||||
{
|
||||
$hasPermission = true;
|
||||
foreach ($permissions as $permission) {
|
||||
if (!$role->hasPermissionTo($permission->name)) {
|
||||
$hasPermission = false;
|
||||
return $hasPermission;
|
||||
}
|
||||
}
|
||||
return $hasPermission;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class LoginLog extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'ip_address',
|
||||
'user_agent',
|
||||
'status'
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Menu extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['title', 'url', 'icon', 'parent_id', 'order'];
|
||||
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo(Menu::class, 'parent_id');
|
||||
}
|
||||
|
||||
public function children()
|
||||
{
|
||||
return $this->hasMany(Menu::class, 'parent_id')->orderBy('order');
|
||||
}
|
||||
}
|
||||
@@ -2,23 +2,33 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register(): void
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot(): void
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
if (env('REDIRECT_HTTPS')) {
|
||||
URL::forceScheme('https');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The policy mappings for the application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $policies = [
|
||||
// 'App\Model' => 'App\Policies\ModelPolicy',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any authentication / authorization services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->registerPolicies();
|
||||
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class BroadcastServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
Broadcast::routes();
|
||||
|
||||
require base_path('routes/channels.php');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The event listener mappings for the application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $listen = [
|
||||
Registered::class => [
|
||||
SendEmailVerificationNotification::class,
|
||||
],
|
||||
\Illuminate\Auth\Events\Login::class => [
|
||||
\App\Listeners\LogLoginActivity::class,
|
||||
],
|
||||
\Illuminate\Auth\Events\Logout::class => [
|
||||
\App\Listeners\LogLogoutActivity::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any events for your application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* This namespace is applied to your controller routes.
|
||||
*
|
||||
* In addition, it is set as the URL generator's root namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $namespace = 'App\Http\Controllers';
|
||||
|
||||
/**
|
||||
* The path to the "home" route for your application.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const HOME = '/home';
|
||||
|
||||
|
||||
/**
|
||||
* The path to the "admin" route for your application.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const ADMIN_DASHBOARD = '/admin';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, etc.
|
||||
*
|
||||
* @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->namespace)
|
||||
->group(base_path('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->namespace)
|
||||
->group(base_path('routes/api.php'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
|
||||
trait AuthorizationChecker
|
||||
{
|
||||
/**
|
||||
* Check if the user is authorized to perform the action.
|
||||
*
|
||||
* @param Authenticatable $user
|
||||
* @param array|string $permissions
|
||||
* @return void
|
||||
*/
|
||||
public function checkAuthorization($user, $permissions): void
|
||||
{
|
||||
if (is_null($user) || !$user->can($permissions)) {
|
||||
abort(403, 'Sorry !! You are unauthorized to perform this action.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use Notifiable, HasRoles;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name', 'email', 'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password', 'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
|
||||
public static function getpermissionGroups()
|
||||
{
|
||||
$permission_groups = DB::table('permissions')
|
||||
->select('group_name as name')
|
||||
->groupBy('group_name')
|
||||
->get();
|
||||
return $permission_groups;
|
||||
}
|
||||
|
||||
public static function getpermissionsByGroupName($group_name)
|
||||
{
|
||||
$permissions = DB::table('permissions')
|
||||
->select('name', 'id')
|
||||
->where('group_name', $group_name)
|
||||
->get();
|
||||
return $permissions;
|
||||
}
|
||||
|
||||
public static function roleHasPermissions($role, $permissions)
|
||||
{
|
||||
$hasPermission = true;
|
||||
foreach ($permissions as $permission) {
|
||||
if (!$role->hasPermissionTo($permission->name)) {
|
||||
$hasPermission = false;
|
||||
return $hasPermission;
|
||||
}
|
||||
}
|
||||
return $hasPermission;
|
||||
}
|
||||
}
|
||||
+52
-15
@@ -1,18 +1,55 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Foundation\Configuration\Exceptions;
|
||||
use Illuminate\Foundation\Configuration\Middleware;
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Create The Application
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The first thing we will do is create a new Laravel application instance
|
||||
| which serves as the "glue" for all the components of Laravel, and is
|
||||
| the IoC container for the system binding all of the various parts.
|
||||
|
|
||||
*/
|
||||
|
||||
return Application::configure(basePath: dirname(__DIR__))
|
||||
->withRouting(
|
||||
web: __DIR__.'/../routes/web.php',
|
||||
commands: __DIR__.'/../routes/console.php',
|
||||
health: '/up',
|
||||
)
|
||||
->withMiddleware(function (Middleware $middleware) {
|
||||
//
|
||||
})
|
||||
->withExceptions(function (Exceptions $exceptions) {
|
||||
//
|
||||
})->create();
|
||||
$app = new Illuminate\Foundation\Application(
|
||||
$_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
|
||||
);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Bind Important Interfaces
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Next, we need to bind some important interfaces into the container so
|
||||
| we will be able to resolve them when needed. The kernels serve the
|
||||
| incoming requests to this application from both the web and CLI.
|
||||
|
|
||||
*/
|
||||
|
||||
$app->singleton(
|
||||
Illuminate\Contracts\Http\Kernel::class,
|
||||
App\Http\Kernel::class
|
||||
);
|
||||
|
||||
$app->singleton(
|
||||
Illuminate\Contracts\Console\Kernel::class,
|
||||
App\Console\Kernel::class
|
||||
);
|
||||
|
||||
$app->singleton(
|
||||
Illuminate\Contracts\Debug\ExceptionHandler::class,
|
||||
App\Exceptions\Handler::class
|
||||
);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Return The Application
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This script returns the application instance. The instance is given to
|
||||
| the calling script so we can separate the building of the instances
|
||||
| from the actual running of the application and sending responses.
|
||||
|
|
||||
*/
|
||||
|
||||
return $app;
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
App\Providers\AppServiceProvider::class,
|
||||
];
|
||||
+17
-6
@@ -7,9 +7,18 @@
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^8.2",
|
||||
"jeroennoten/laravel-adminlte": "^3.14",
|
||||
"barryvdh/laravel-dompdf": "^3.0",
|
||||
"guzzlehttp/guzzle": "^7.9",
|
||||
"intervention/image": "^3.9",
|
||||
"laravel/framework": "^11.31",
|
||||
"laravel/tinker": "^2.9"
|
||||
"laravel/tinker": "^2.9",
|
||||
"laravel/ui": "^4.6",
|
||||
"laravolt/avatar": "^6.0",
|
||||
"phpoffice/phpspreadsheet": "^3.5",
|
||||
"spatie/laravel-html": "^3.11",
|
||||
"spatie/laravel-menu": "^4.2",
|
||||
"spatie/laravel-permission": "^6.10",
|
||||
"yajra/laravel-datatables-oracle": "11.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1.23",
|
||||
@@ -22,10 +31,12 @@
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "app/",
|
||||
"Database\\Factories\\": "database/factories/",
|
||||
"Database\\Seeders\\": "database/seeders/"
|
||||
}
|
||||
"App\\": "app/"
|
||||
},
|
||||
"classmap": [
|
||||
"database/seeds",
|
||||
"database/factories"
|
||||
]
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
|
||||
Generated
+1563
-212
File diff suppressed because it is too large
Load Diff
+17
-17
@@ -14,7 +14,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'title' => 'Xpendify',
|
||||
'title' => 'AdminLTE 3',
|
||||
'title_prefix' => '',
|
||||
'title_postfix' => '',
|
||||
|
||||
@@ -31,7 +31,7 @@ return [
|
||||
*/
|
||||
|
||||
'use_ico_only' => false,
|
||||
'use_full_favicon' => true,
|
||||
'use_full_favicon' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -63,12 +63,12 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'logo' => '<b>TIA</b> Xpendify',
|
||||
'logo_img' => 'vendor/adminlte/dist/img/logo.png',
|
||||
'logo_img_class' => 'brand-image',
|
||||
'logo' => '<b>Admin</b>LTE',
|
||||
'logo_img' => 'vendor/adminlte/dist/img/AdminLTELogo.png',
|
||||
'logo_img_class' => 'brand-image img-circle elevation-3',
|
||||
'logo_img_xl' => null,
|
||||
'logo_img_xl_class' => 'brand-image-xs',
|
||||
'logo_img_alt' => 'App Logo',
|
||||
'logo_img_alt' => 'Admin Logo',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -86,11 +86,11 @@ return [
|
||||
'auth_logo' => [
|
||||
'enabled' => false,
|
||||
'img' => [
|
||||
'path' => 'vendor/adminlte/dist/img/logo.png',
|
||||
'path' => 'vendor/adminlte/dist/img/AdminLTELogo.png',
|
||||
'alt' => 'Auth Logo',
|
||||
'class' => '',
|
||||
'width' => 80,
|
||||
'height' => 80,
|
||||
'width' => 50,
|
||||
'height' => 50,
|
||||
],
|
||||
],
|
||||
|
||||
@@ -113,11 +113,11 @@ return [
|
||||
'enabled' => true,
|
||||
'mode' => 'fullscreen',
|
||||
'img' => [
|
||||
'path' => 'vendor/adminlte/dist/img/logo-preloader.png',
|
||||
'alt' => 'Preloader Image',
|
||||
'path' => 'vendor/adminlte/dist/img/AdminLTELogo.png',
|
||||
'alt' => 'AdminLTE Preloader Image',
|
||||
'effect' => 'animation__shake',
|
||||
'width' => 80,
|
||||
'height' => 80,
|
||||
'width' => 60,
|
||||
'height' => 60,
|
||||
],
|
||||
],
|
||||
|
||||
@@ -172,7 +172,7 @@ return [
|
||||
*/
|
||||
|
||||
'classes_auth_card' => 'card-outline card-primary',
|
||||
'classes_auth_header' => 'bg-gradient-primary',
|
||||
'classes_auth_header' => '',
|
||||
'classes_auth_body' => '',
|
||||
'classes_auth_footer' => '',
|
||||
'classes_auth_icon' => '',
|
||||
@@ -191,12 +191,12 @@ return [
|
||||
*/
|
||||
|
||||
'classes_body' => '',
|
||||
'classes_brand' => 'brand-link bg-navy',
|
||||
'classes_brand' => '',
|
||||
'classes_brand_text' => '',
|
||||
'classes_content_wrapper' => '',
|
||||
'classes_content_header' => '',
|
||||
'classes_content' => '',
|
||||
'classes_sidebar' => 'main-sidebar elevation-4 sidebar-light-navy',
|
||||
'classes_sidebar' => 'sidebar-dark-primary elevation-4',
|
||||
'classes_sidebar_nav' => '',
|
||||
'classes_topnav' => 'navbar-white navbar-light',
|
||||
'classes_topnav_nav' => 'navbar-expand',
|
||||
@@ -418,7 +418,7 @@ return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Plugins Initialization
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here we can modify the plugins used inside the admin panel.
|
||||
|
||||
+110
@@ -7,6 +7,7 @@ return [
|
||||
'name' => env('APP_NAME', 'Laravel'),
|
||||
'version' => env('APP_VERSION', '1.0.0'),
|
||||
'company_name' => env('APP_COMPANY', '1.0.0'),
|
||||
'app_name' => env('APP_NAME', 'Our Apps'),
|
||||
'env' => env('APP_ENV', 'production'),
|
||||
|
||||
/*
|
||||
@@ -104,4 +105,113 @@ return [
|
||||
'store' => env('APP_MAINTENANCE_STORE', 'database'),
|
||||
],
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Autoloaded Service Providers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The service providers listed here will be automatically loaded on the
|
||||
| request to your application. Feel free to add your own services to
|
||||
| this array to grant expanded functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
'providers' => [
|
||||
|
||||
/*
|
||||
* Laravel Framework Service Providers...
|
||||
*/
|
||||
Yajra\DataTables\DataTablesServiceProvider::class,
|
||||
Illuminate\Auth\AuthServiceProvider::class,
|
||||
Illuminate\Broadcasting\BroadcastServiceProvider::class,
|
||||
Illuminate\Bus\BusServiceProvider::class,
|
||||
Illuminate\Cache\CacheServiceProvider::class,
|
||||
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
|
||||
Illuminate\Cookie\CookieServiceProvider::class,
|
||||
Illuminate\Database\DatabaseServiceProvider::class,
|
||||
Illuminate\Encryption\EncryptionServiceProvider::class,
|
||||
Illuminate\Filesystem\FilesystemServiceProvider::class,
|
||||
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
|
||||
Illuminate\Hashing\HashServiceProvider::class,
|
||||
Illuminate\Mail\MailServiceProvider::class,
|
||||
Illuminate\Notifications\NotificationServiceProvider::class,
|
||||
Illuminate\Pagination\PaginationServiceProvider::class,
|
||||
Illuminate\Pipeline\PipelineServiceProvider::class,
|
||||
Illuminate\Queue\QueueServiceProvider::class,
|
||||
Illuminate\Redis\RedisServiceProvider::class,
|
||||
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
|
||||
Illuminate\Session\SessionServiceProvider::class,
|
||||
Illuminate\Translation\TranslationServiceProvider::class,
|
||||
Illuminate\Validation\ValidationServiceProvider::class,
|
||||
Illuminate\View\ViewServiceProvider::class,
|
||||
|
||||
/*
|
||||
* Package Service Providers...
|
||||
*/
|
||||
Spatie\Permission\PermissionServiceProvider::class,
|
||||
|
||||
/*
|
||||
* Application Service Providers...
|
||||
*/
|
||||
App\Providers\AppServiceProvider::class,
|
||||
App\Providers\AuthServiceProvider::class,
|
||||
// App\Providers\BroadcastServiceProvider::class,
|
||||
App\Providers\EventServiceProvider::class,
|
||||
App\Providers\RouteServiceProvider::class,
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Class Aliases
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This array of class aliases will be registered when this application
|
||||
| is started. However, feel free to register as many as you wish as
|
||||
| the aliases are "lazy" loaded so they don't hinder performance.
|
||||
|
|
||||
*/
|
||||
|
||||
'aliases' => [
|
||||
|
||||
'App' => Illuminate\Support\Facades\App::class,
|
||||
'Arr' => Illuminate\Support\Arr::class,
|
||||
'Artisan' => Illuminate\Support\Facades\Artisan::class,
|
||||
'Auth' => Illuminate\Support\Facades\Auth::class,
|
||||
'Blade' => Illuminate\Support\Facades\Blade::class,
|
||||
'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
|
||||
'Bus' => Illuminate\Support\Facades\Bus::class,
|
||||
'Cache' => Illuminate\Support\Facades\Cache::class,
|
||||
'Config' => Illuminate\Support\Facades\Config::class,
|
||||
'Cookie' => Illuminate\Support\Facades\Cookie::class,
|
||||
'Crypt' => Illuminate\Support\Facades\Crypt::class,
|
||||
'DB' => Illuminate\Support\Facades\DB::class,
|
||||
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
|
||||
'Event' => Illuminate\Support\Facades\Event::class,
|
||||
'File' => Illuminate\Support\Facades\File::class,
|
||||
'Gate' => Illuminate\Support\Facades\Gate::class,
|
||||
'Hash' => Illuminate\Support\Facades\Hash::class,
|
||||
'Http' => Illuminate\Support\Facades\Http::class,
|
||||
'Lang' => Illuminate\Support\Facades\Lang::class,
|
||||
'Log' => Illuminate\Support\Facades\Log::class,
|
||||
'Mail' => Illuminate\Support\Facades\Mail::class,
|
||||
'Notification' => Illuminate\Support\Facades\Notification::class,
|
||||
'Password' => Illuminate\Support\Facades\Password::class,
|
||||
'Queue' => Illuminate\Support\Facades\Queue::class,
|
||||
'Redirect' => Illuminate\Support\Facades\Redirect::class,
|
||||
'Redis' => Illuminate\Support\Facades\Redis::class,
|
||||
'Request' => Illuminate\Support\Facades\Request::class,
|
||||
'Response' => Illuminate\Support\Facades\Response::class,
|
||||
'Route' => Illuminate\Support\Facades\Route::class,
|
||||
'Schema' => Illuminate\Support\Facades\Schema::class,
|
||||
'Session' => Illuminate\Support\Facades\Session::class,
|
||||
'Storage' => Illuminate\Support\Facades\Storage::class,
|
||||
'Str' => Illuminate\Support\Str::class,
|
||||
'URL' => Illuminate\Support\Facades\URL::class,
|
||||
'Validator' => Illuminate\Support\Facades\Validator::class,
|
||||
'View' => Illuminate\Support\Facades\View::class,
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
+46
-27
@@ -7,15 +7,15 @@ return [
|
||||
| Authentication Defaults
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option defines the default authentication "guard" and password
|
||||
| reset "broker" for your application. You may change these values
|
||||
| This option controls the default authentication "guard" and password
|
||||
| reset options for your application. You may change these defaults
|
||||
| as required, but they're a perfect start for most applications.
|
||||
|
|
||||
*/
|
||||
|
||||
'defaults' => [
|
||||
'guard' => env('AUTH_GUARD', 'web'),
|
||||
'passwords' => env('AUTH_PASSWORD_BROKER', 'users'),
|
||||
'guard' => 'web',
|
||||
'passwords' => 'users',
|
||||
],
|
||||
|
||||
/*
|
||||
@@ -25,13 +25,13 @@ return [
|
||||
|
|
||||
| Next, you may define every authentication guard for your application.
|
||||
| Of course, a great default configuration has been defined for you
|
||||
| which utilizes session storage plus the Eloquent user provider.
|
||||
| here which uses session storage and the Eloquent user provider.
|
||||
|
|
||||
| All authentication guards have a user provider, which defines how the
|
||||
| All authentication drivers have a user provider. This defines how the
|
||||
| users are actually retrieved out of your database or other storage
|
||||
| system used by the application. Typically, Eloquent is utilized.
|
||||
| mechanisms used by this application to persist your user's data.
|
||||
|
|
||||
| Supported: "session"
|
||||
| Supported: "session", "token"
|
||||
|
|
||||
*/
|
||||
|
||||
@@ -40,6 +40,23 @@ return [
|
||||
'driver' => 'session',
|
||||
'provider' => 'users',
|
||||
],
|
||||
|
||||
'api' => [
|
||||
'driver' => 'token',
|
||||
'provider' => 'users',
|
||||
'hash' => false,
|
||||
],
|
||||
|
||||
'admin' => [
|
||||
'driver' => 'session',
|
||||
'provider' => 'admins',
|
||||
],
|
||||
|
||||
'admin_api' => [
|
||||
'driver' => 'token',
|
||||
'provider' => 'admins',
|
||||
'hash' => false,
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
@@ -47,12 +64,12 @@ return [
|
||||
| User Providers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| All authentication guards have a user provider, which defines how the
|
||||
| All authentication drivers have a user provider. This defines how the
|
||||
| users are actually retrieved out of your database or other storage
|
||||
| system used by the application. Typically, Eloquent is utilized.
|
||||
| mechanisms used by this application to persist your user's data.
|
||||
|
|
||||
| If you have multiple user tables or models you may configure multiple
|
||||
| providers to represent the model / table. These providers may then
|
||||
| sources which represent each model / table. These sources may then
|
||||
| be assigned to any extra authentication guards you have defined.
|
||||
|
|
||||
| Supported: "database", "eloquent"
|
||||
@@ -62,13 +79,13 @@ return [
|
||||
'providers' => [
|
||||
'users' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => env('AUTH_MODEL', App\Models\User::class),
|
||||
'model' => App\Models\User::class,
|
||||
],
|
||||
|
||||
// 'users' => [
|
||||
// 'driver' => 'database',
|
||||
// 'table' => 'users',
|
||||
// ],
|
||||
'admins' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => App\Models\Admin::class,
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
@@ -76,24 +93,26 @@ return [
|
||||
| Resetting Passwords
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These configuration options specify the behavior of Laravel's password
|
||||
| reset functionality, including the table utilized for token storage
|
||||
| and the user provider that is invoked to actually retrieve users.
|
||||
| You may specify multiple password reset configurations if you have more
|
||||
| than one user table or model in the application and you want to have
|
||||
| separate password reset settings based on the specific user types.
|
||||
|
|
||||
| The expiry time is the number of minutes that each reset token will be
|
||||
| The expire time is the number of minutes that the reset token should be
|
||||
| considered valid. This security feature keeps tokens short-lived so
|
||||
| they have less time to be guessed. You may change this as needed.
|
||||
|
|
||||
| The throttle setting is the number of seconds a user must wait before
|
||||
| generating more password reset tokens. This prevents the user from
|
||||
| quickly generating a very large amount of password reset tokens.
|
||||
|
|
||||
*/
|
||||
|
||||
'passwords' => [
|
||||
'users' => [
|
||||
'provider' => 'users',
|
||||
'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
|
||||
'table' => 'password_resets',
|
||||
'expire' => 60,
|
||||
'throttle' => 60,
|
||||
],
|
||||
'admins' => [
|
||||
'provider' => 'admins',
|
||||
'table' => 'password_resets',
|
||||
'expire' => 60,
|
||||
'throttle' => 60,
|
||||
],
|
||||
@@ -105,11 +124,11 @@ return [
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define the amount of seconds before a password confirmation
|
||||
| window expires and users are asked to re-enter their password via the
|
||||
| times out and the user is prompted to re-enter their password via the
|
||||
| confirmation screen. By default, the timeout lasts for three hours.
|
||||
|
|
||||
*/
|
||||
|
||||
'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800),
|
||||
'password_timeout' => 10800,
|
||||
|
||||
];
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Broadcaster
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default broadcaster that will be used by the
|
||||
| framework when an event needs to be broadcast. You may set this to
|
||||
| any of the connections defined in the "connections" array below.
|
||||
|
|
||||
| Supported: "pusher", "redis", "log", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('BROADCAST_DRIVER', 'null'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Broadcast Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define all of the broadcast connections that will be used
|
||||
| to broadcast events to other systems or over websockets. Samples of
|
||||
| each available type of connection are provided inside this array.
|
||||
|
|
||||
*/
|
||||
|
||||
'connections' => [
|
||||
|
||||
'pusher' => [
|
||||
'driver' => 'pusher',
|
||||
'key' => env('PUSHER_APP_KEY'),
|
||||
'secret' => env('PUSHER_APP_SECRET'),
|
||||
'app_id' => env('PUSHER_APP_ID'),
|
||||
'options' => [
|
||||
'cluster' => env('PUSHER_APP_CLUSTER'),
|
||||
'useTLS' => true,
|
||||
],
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => 'default',
|
||||
],
|
||||
|
||||
'log' => [
|
||||
'driver' => 'log',
|
||||
],
|
||||
|
||||
'null' => [
|
||||
'driver' => 'null',
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
+18
-22
@@ -9,13 +9,16 @@ return [
|
||||
| Default Cache Store
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default cache store that will be used by the
|
||||
| framework. This connection is utilized if another isn't explicitly
|
||||
| specified when running a cache operation inside the application.
|
||||
| This option controls the default cache connection that gets used while
|
||||
| using this caching library. This connection is used when another is
|
||||
| not explicitly specified when executing a given caching function.
|
||||
|
|
||||
| Supported: "apc", "array", "database", "file",
|
||||
| "memcached", "redis", "dynamodb"
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('CACHE_STORE', 'database'),
|
||||
'default' => env('CACHE_DRIVER', 'file'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -26,13 +29,14 @@ return [
|
||||
| well as their drivers. You may even define multiple stores for the
|
||||
| same cache driver to group types of items stored in your caches.
|
||||
|
|
||||
| Supported drivers: "array", "database", "file", "memcached",
|
||||
| "redis", "dynamodb", "octane", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'stores' => [
|
||||
|
||||
'apc' => [
|
||||
'driver' => 'apc',
|
||||
],
|
||||
|
||||
'array' => [
|
||||
'driver' => 'array',
|
||||
'serialize' => false,
|
||||
@@ -40,16 +44,13 @@ return [
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'connection' => env('DB_CACHE_CONNECTION'),
|
||||
'table' => env('DB_CACHE_TABLE', 'cache'),
|
||||
'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'),
|
||||
'lock_table' => env('DB_CACHE_LOCK_TABLE'),
|
||||
'table' => 'cache',
|
||||
'connection' => null,
|
||||
],
|
||||
|
||||
'file' => [
|
||||
'driver' => 'file',
|
||||
'path' => storage_path('framework/cache/data'),
|
||||
'lock_path' => storage_path('framework/cache/data'),
|
||||
],
|
||||
|
||||
'memcached' => [
|
||||
@@ -73,8 +74,7 @@ return [
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => env('REDIS_CACHE_CONNECTION', 'cache'),
|
||||
'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'),
|
||||
'connection' => 'cache',
|
||||
],
|
||||
|
||||
'dynamodb' => [
|
||||
@@ -86,10 +86,6 @@ return [
|
||||
'endpoint' => env('DYNAMODB_ENDPOINT'),
|
||||
],
|
||||
|
||||
'octane' => [
|
||||
'driver' => 'octane',
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
@@ -97,12 +93,12 @@ return [
|
||||
| Cache Key Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When utilizing the APC, database, memcached, Redis, and DynamoDB cache
|
||||
| stores, there might be other applications using the same cache. For
|
||||
| that reason, you may prefix every cache key to avoid collisions.
|
||||
| When utilizing a RAM based store such as APC or Memcached, there might
|
||||
| be other applications utilizing the same cache. So, we'll specify a
|
||||
| value to get prefixed to all our keys so we can avoid collisions.
|
||||
|
|
||||
*/
|
||||
|
||||
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'),
|
||||
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'),
|
||||
|
||||
];
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cross-Origin Resource Sharing (CORS) Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure your settings for cross-origin resource sharing
|
||||
| or "CORS". This determines what cross-origin operations may execute
|
||||
| in web browsers. You are free to adjust these settings as needed.
|
||||
|
|
||||
| To learn more: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
|
||||
|
|
||||
*/
|
||||
|
||||
'paths' => ['api/*'],
|
||||
|
||||
'allowed_methods' => ['*'],
|
||||
|
||||
'allowed_origins' => ['*'],
|
||||
|
||||
'allowed_origins_patterns' => [],
|
||||
|
||||
'allowed_headers' => ['*'],
|
||||
|
||||
'exposed_headers' => [],
|
||||
|
||||
'max_age' => 0,
|
||||
|
||||
'supports_credentials' => false,
|
||||
|
||||
];
|
||||
+1
-1
@@ -16,7 +16,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('DB_CONNECTION', 'sqlite'),
|
||||
'default' => env('DB_CONNECTION', 'mariadb'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
/*
|
||||
* DataTables search options.
|
||||
*/
|
||||
'search' => [
|
||||
/*
|
||||
* Smart search will enclose search keyword with wildcard string "%keyword%".
|
||||
* SQL: column LIKE "%keyword%"
|
||||
*/
|
||||
'smart' => true,
|
||||
|
||||
/*
|
||||
* Multi-term search will explode search keyword using spaces resulting into multiple term search.
|
||||
*/
|
||||
'multi_term' => true,
|
||||
|
||||
/*
|
||||
* Case insensitive will search the keyword in lower case format.
|
||||
* SQL: LOWER(column) LIKE LOWER(keyword)
|
||||
*/
|
||||
'case_insensitive' => true,
|
||||
|
||||
/*
|
||||
* Wild card will add "%" in between every characters of the keyword.
|
||||
* SQL: column LIKE "%k%e%y%w%o%r%d%"
|
||||
*/
|
||||
'use_wildcards' => false,
|
||||
|
||||
/*
|
||||
* Perform a search which starts with the given keyword.
|
||||
* SQL: column LIKE "keyword%"
|
||||
*/
|
||||
'starts_with' => false,
|
||||
],
|
||||
|
||||
/*
|
||||
* DataTables internal index id response column name.
|
||||
*/
|
||||
'index_column' => 'DT_RowIndex',
|
||||
|
||||
/*
|
||||
* List of available builders for DataTables.
|
||||
* This is where you can register your custom dataTables builder.
|
||||
*/
|
||||
'engines' => [
|
||||
'eloquent' => Yajra\DataTables\EloquentDataTable::class,
|
||||
'query' => Yajra\DataTables\QueryDataTable::class,
|
||||
'collection' => Yajra\DataTables\CollectionDataTable::class,
|
||||
'resource' => Yajra\DataTables\ApiResourceDataTable::class,
|
||||
],
|
||||
|
||||
/*
|
||||
* DataTables accepted builder to engine mapping.
|
||||
* This is where you can override which engine a builder should use
|
||||
* Note, only change this if you know what you are doing!
|
||||
*/
|
||||
'builders' => [
|
||||
//Illuminate\Database\Eloquent\Relations\Relation::class => 'eloquent',
|
||||
//Illuminate\Database\Eloquent\Builder::class => 'eloquent',
|
||||
//Illuminate\Database\Query\Builder::class => 'query',
|
||||
//Illuminate\Support\Collection::class => 'collection',
|
||||
],
|
||||
|
||||
/*
|
||||
* Nulls last sql pattern for PostgreSQL & Oracle.
|
||||
* For MySQL, use 'CASE WHEN :column IS NULL THEN 1 ELSE 0 END, :column :direction'
|
||||
*/
|
||||
'nulls_last_sql' => ':column :direction NULLS LAST',
|
||||
|
||||
/*
|
||||
* User friendly message to be displayed on user if error occurs.
|
||||
* Possible values:
|
||||
* null - The exception message will be used on error response.
|
||||
* 'throw' - Throws a \Yajra\DataTables\Exceptions\Exception. Use your custom error handler if needed.
|
||||
* 'custom message' - Any friendly message to be displayed to the user. You can also use translation key.
|
||||
*/
|
||||
'error' => env('DATATABLES_ERROR', null),
|
||||
|
||||
/*
|
||||
* Default columns definition of dataTable utility functions.
|
||||
*/
|
||||
'columns' => [
|
||||
/*
|
||||
* List of columns hidden/removed on json response.
|
||||
*/
|
||||
'excess' => ['rn', 'row_num'],
|
||||
|
||||
/*
|
||||
* List of columns to be escaped. If set to *, all columns are escape.
|
||||
* Note: You can set the value to empty array to disable XSS protection.
|
||||
*/
|
||||
'escape' => '*',
|
||||
|
||||
/*
|
||||
* List of columns that are allowed to display html content.
|
||||
* Note: Adding columns to list will make us available to XSS attacks.
|
||||
*/
|
||||
'raw' => ['action'],
|
||||
|
||||
/*
|
||||
* List of columns are forbidden from being searched/sorted.
|
||||
*/
|
||||
'blacklist' => ['password', 'remember_token'],
|
||||
|
||||
/*
|
||||
* List of columns that are only allowed fo search/sort.
|
||||
* If set to *, all columns are allowed.
|
||||
*/
|
||||
'whitelist' => '*',
|
||||
],
|
||||
|
||||
/*
|
||||
* JsonResponse header and options config.
|
||||
*/
|
||||
'json' => [
|
||||
'header' => [],
|
||||
'options' => 0,
|
||||
],
|
||||
|
||||
/*
|
||||
* Default condition to determine if a parameter is a callback or not.
|
||||
* Callbacks needs to start by those terms, or they will be cast to string.
|
||||
*/
|
||||
'callback' => ['$', '$.', 'function'],
|
||||
];
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Hash Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default hash driver that will be used to hash
|
||||
| passwords for your application. By default, the bcrypt algorithm is
|
||||
| used; however, you remain free to modify this option if you wish.
|
||||
|
|
||||
| Supported: "bcrypt", "argon", "argon2id"
|
||||
|
|
||||
*/
|
||||
|
||||
'driver' => 'bcrypt',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Bcrypt Options
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the configuration options that should be used when
|
||||
| passwords are hashed using the Bcrypt algorithm. This will allow you
|
||||
| to control the amount of time it takes to hash the given password.
|
||||
|
|
||||
*/
|
||||
|
||||
'bcrypt' => [
|
||||
'rounds' => env('BCRYPT_ROUNDS', 10),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Argon Options
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the configuration options that should be used when
|
||||
| passwords are hashed using the Argon algorithm. These will allow you
|
||||
| to control the amount of time it takes to hash the given password.
|
||||
|
|
||||
*/
|
||||
|
||||
'argon' => [
|
||||
'memory' => 1024,
|
||||
'threads' => 2,
|
||||
'time' => 2,
|
||||
],
|
||||
|
||||
];
|
||||
+35
-51
@@ -9,16 +9,16 @@ return [
|
||||
| Default Session Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option determines the default session driver that is utilized for
|
||||
| incoming requests. Laravel supports a variety of storage options to
|
||||
| persist session data. Database storage is a great default choice.
|
||||
| This option controls the default session "driver" that will be used on
|
||||
| requests. By default, we will use the lightweight native driver but
|
||||
| you may specify any of the other wonderful drivers provided here.
|
||||
|
|
||||
| Supported: "file", "cookie", "database", "apc",
|
||||
| "memcached", "redis", "dynamodb", "array"
|
||||
|
|
||||
*/
|
||||
|
||||
'driver' => env('SESSION_DRIVER', 'database'),
|
||||
'driver' => env('SESSION_DRIVER', 'file'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -27,14 +27,13 @@ return [
|
||||
|
|
||||
| Here you may specify the number of minutes that you wish the session
|
||||
| to be allowed to remain idle before it expires. If you want them
|
||||
| to expire immediately when the browser is closed then you may
|
||||
| indicate that via the expire_on_close configuration option.
|
||||
| to immediately expire on the browser closing, set that option.
|
||||
|
|
||||
*/
|
||||
|
||||
'lifetime' => env('SESSION_LIFETIME', 120),
|
||||
|
||||
'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false),
|
||||
'expire_on_close' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -42,21 +41,21 @@ return [
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option allows you to easily specify that all of your session data
|
||||
| should be encrypted before it's stored. All encryption is performed
|
||||
| automatically by Laravel and you may use the session like normal.
|
||||
| should be encrypted before it is stored. All encryption will be run
|
||||
| automatically by Laravel and you can use the Session like normal.
|
||||
|
|
||||
*/
|
||||
|
||||
'encrypt' => env('SESSION_ENCRYPT', false),
|
||||
'encrypt' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session File Location
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When utilizing the "file" session driver, the session files are placed
|
||||
| on disk. The default storage location is defined here; however, you
|
||||
| are free to provide another location where they should be stored.
|
||||
| When using the native session driver, we need a location where session
|
||||
| files may be stored. A default has been set for you but a different
|
||||
| location may be specified. This is only needed for file sessions.
|
||||
|
|
||||
*/
|
||||
|
||||
@@ -73,35 +72,35 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'connection' => env('SESSION_CONNECTION'),
|
||||
'connection' => env('SESSION_CONNECTION', null),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Database Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the "database" session driver, you may specify the table to
|
||||
| be used to store sessions. Of course, a sensible default is defined
|
||||
| for you; however, you're welcome to change this to another table.
|
||||
| When using the "database" session driver, you may specify the table we
|
||||
| should use to manage the sessions. Of course, a sensible default is
|
||||
| provided for you; however, you are free to change this as needed.
|
||||
|
|
||||
*/
|
||||
|
||||
'table' => env('SESSION_TABLE', 'sessions'),
|
||||
'table' => 'sessions',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cache Store
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using one of the framework's cache driven session backends, you may
|
||||
| define the cache store which should be used to store the session data
|
||||
| between requests. This must match one of your defined cache stores.
|
||||
| While using one of the framework's cache driven session backends you may
|
||||
| list a cache store that should be used for these sessions. This value
|
||||
| must match with one of the application's configured cache "stores".
|
||||
|
|
||||
| Affects: "apc", "dynamodb", "memcached", "redis"
|
||||
|
|
||||
*/
|
||||
|
||||
'store' => env('SESSION_STORE'),
|
||||
'store' => env('SESSION_STORE', null),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -121,9 +120,9 @@ return [
|
||||
| Session Cookie Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may change the name of the session cookie that is created by
|
||||
| the framework. Typically, you should not need to change this value
|
||||
| since doing so does not grant a meaningful security improvement.
|
||||
| Here you may change the name of the cookie used to identify a session
|
||||
| instance by ID. The name specified here will get used every time a
|
||||
| new session cookie is created by the framework for every driver.
|
||||
|
|
||||
*/
|
||||
|
||||
@@ -139,24 +138,24 @@ return [
|
||||
|
|
||||
| The session cookie path determines the path for which the cookie will
|
||||
| be regarded as available. Typically, this will be the root path of
|
||||
| your application, but you're free to change this when necessary.
|
||||
| your application but you are free to change this when necessary.
|
||||
|
|
||||
*/
|
||||
|
||||
'path' => env('SESSION_PATH', '/'),
|
||||
'path' => '/',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Domain
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value determines the domain and subdomains the session cookie is
|
||||
| available to. By default, the cookie will be available to the root
|
||||
| domain and all subdomains. Typically, this shouldn't be changed.
|
||||
| Here you may change the domain of the cookie used to identify a session
|
||||
| in your application. This will determine which domains the cookie is
|
||||
| available to in your application. A sensible default has been set.
|
||||
|
|
||||
*/
|
||||
|
||||
'domain' => env('SESSION_DOMAIN'),
|
||||
'domain' => env('SESSION_DOMAIN', null),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -165,7 +164,7 @@ return [
|
||||
|
|
||||
| By setting this option to true, session cookies will only be sent back
|
||||
| to the server if the browser has a HTTPS connection. This will keep
|
||||
| the cookie from being sent to you when it can't be done securely.
|
||||
| the cookie from being sent to you if it can not be done securely.
|
||||
|
|
||||
*/
|
||||
|
||||
@@ -178,11 +177,11 @@ return [
|
||||
|
|
||||
| Setting this value to true will prevent JavaScript from accessing the
|
||||
| value of the cookie and the cookie will only be accessible through
|
||||
| the HTTP protocol. It's unlikely you should disable this option.
|
||||
| the HTTP protocol. You are free to modify this option if needed.
|
||||
|
|
||||
*/
|
||||
|
||||
'http_only' => env('SESSION_HTTP_ONLY', true),
|
||||
'http_only' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -191,27 +190,12 @@ return [
|
||||
|
|
||||
| This option determines how your cookies behave when cross-site requests
|
||||
| take place, and can be used to mitigate CSRF attacks. By default, we
|
||||
| will set this value to "lax" to permit secure cross-site requests.
|
||||
|
|
||||
| See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value
|
||||
| will set this value to "lax" since this is a secure default value.
|
||||
|
|
||||
| Supported: "lax", "strict", "none", null
|
||||
|
|
||||
*/
|
||||
|
||||
'same_site' => env('SESSION_SAME_SITE', 'lax'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Partitioned Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Setting this value to true will tie the cookie to the top-level site for
|
||||
| a cross-site context. Partitioned cookies are accepted by the browser
|
||||
| when flagged "secure" and the Same-Site attribute is set to "none".
|
||||
|
|
||||
*/
|
||||
|
||||
'partitioned' => env('SESSION_PARTITIONED_COOKIE', false),
|
||||
'same_site' => 'lax',
|
||||
|
||||
];
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| View Storage Paths
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Most templating systems load templates from disk. Here you may specify
|
||||
| an array of paths that should be checked for your views. Of course
|
||||
| the usual Laravel view path has already been registered for you.
|
||||
|
|
||||
*/
|
||||
|
||||
'paths' => [
|
||||
resource_path('views'),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Compiled View Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option determines where all the compiled Blade templates will be
|
||||
| stored for your application. Typically, this is within the storage
|
||||
| directory. However, as usual, you are free to change this value.
|
||||
|
|
||||
*/
|
||||
|
||||
'compiled' => env(
|
||||
'VIEW_COMPILED_PATH',
|
||||
realpath(storage_path('framework/views'))
|
||||
),
|
||||
|
||||
];
|
||||
+2
-1
@@ -1 +1,2 @@
|
||||
*.sqlite*
|
||||
*.sqlite
|
||||
*.sqlite-journal
|
||||
|
||||
@@ -1,44 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use App\User;
|
||||
use Faker\Generator as Faker;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
|
||||
*/
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The current password being used by the factory.
|
||||
*/
|
||||
protected static ?string $password;
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Model Factories
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This directory should contain each of the model factory definitions for
|
||||
| your application. Factories provide a convenient way to generate new
|
||||
| model instances for testing / seeding your application's database.
|
||||
|
|
||||
*/
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$factory->define(User::class, function (Faker $faker) {
|
||||
return [
|
||||
'name' => fake()->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'name' => $faker->name,
|
||||
'email' => $faker->unique()->safeEmail,
|
||||
'email_verified_at' => now(),
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*/
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||
$table->string('email')->primary();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->foreignId('user_id')->nullable()->index();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->longText('payload');
|
||||
$table->integer('last_activity')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
Schema::dropIfExists('password_reset_tokens');
|
||||
Schema::dropIfExists('sessions');
|
||||
}
|
||||
};
|
||||
@@ -1,57 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedTinyInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
});
|
||||
|
||||
Schema::create('job_batches', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->string('name');
|
||||
$table->integer('total_jobs');
|
||||
$table->integer('pending_jobs');
|
||||
$table->integer('failed_jobs');
|
||||
$table->longText('failed_job_ids');
|
||||
$table->mediumText('options')->nullable();
|
||||
$table->integer('cancelled_at')->nullable();
|
||||
$table->integer('created_at');
|
||||
$table->integer('finished_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('uuid')->unique();
|
||||
$table->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('jobs');
|
||||
Schema::dropIfExists('job_batches');
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateUsersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->string('username')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreatePasswordResetsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('password_resets', function (Blueprint $table) {
|
||||
$table->string('email')->index();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('password_resets');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateFailedJobsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreatePermissionTables extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$tableNames = config('permission.table_names');
|
||||
$columnNames = config('permission.column_names');
|
||||
|
||||
if (empty($tableNames)) {
|
||||
throw new \Exception('Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||
}
|
||||
|
||||
Schema::create($tableNames['permissions'], function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('name');
|
||||
$table->string('guard_name');
|
||||
$table->string('group_name')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create($tableNames['roles'], function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('name');
|
||||
$table->string('guard_name');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames) {
|
||||
$table->unsignedBigInteger('permission_id');
|
||||
|
||||
$table->string('model_type');
|
||||
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
||||
$table->index([$columnNames['model_morph_key'], 'model_type'], 'mhp_model_type_index');
|
||||
|
||||
$table->foreign('permission_id')
|
||||
->references('id')
|
||||
->on($tableNames['permissions'])
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->primary(
|
||||
['permission_id', $columnNames['model_morph_key'], 'model_type'],
|
||||
'mhp_pmt_primary'
|
||||
);
|
||||
});
|
||||
|
||||
Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames) {
|
||||
$table->unsignedBigInteger('role_id');
|
||||
|
||||
$table->string('model_type');
|
||||
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
||||
$table->index([$columnNames['model_morph_key'], 'model_type'], 'mhr_model_type_index');
|
||||
|
||||
$table->foreign('role_id')
|
||||
->references('id')
|
||||
->on($tableNames['roles'])
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->primary(
|
||||
['role_id', $columnNames['model_morph_key'], 'model_type'],
|
||||
'mhr_rmt_primary'
|
||||
);
|
||||
});
|
||||
|
||||
Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames) {
|
||||
$table->unsignedBigInteger('permission_id');
|
||||
$table->unsignedBigInteger('role_id');
|
||||
|
||||
$table->foreign('permission_id')
|
||||
->references('id')
|
||||
->on($tableNames['permissions'])
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->foreign('role_id')
|
||||
->references('id')
|
||||
->on($tableNames['roles'])
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->primary(['permission_id', 'role_id'], 'rhp_role_id_primary');
|
||||
});
|
||||
|
||||
app('cache')
|
||||
->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
|
||||
->forget(config('permission.cache.key'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$tableNames = config('permission.table_names');
|
||||
|
||||
if (empty($tableNames)) {
|
||||
throw new \Exception('Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.');
|
||||
}
|
||||
|
||||
Schema::drop($tableNames['role_has_permissions']);
|
||||
Schema::drop($tableNames['model_has_roles']);
|
||||
Schema::drop($tableNames['model_has_permissions']);
|
||||
Schema::drop($tableNames['roles']);
|
||||
Schema::drop($tableNames['permissions']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateAdminsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('admins', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->string('username')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('admins');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('menus', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('title');
|
||||
$table->string('url')->nullable();
|
||||
$table->string('icon')->nullable();
|
||||
$table->unsignedBigInteger('parent_id')->nullable();
|
||||
$table->integer('order')->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('menus');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('role_menu', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('role_id')->constrained('roles')->onDelete('cascade');
|
||||
$table->foreignId('menu_id')->constrained('menus')->onDelete('cascade');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('role_menu');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('menu', function (Blueprint $table) {
|
||||
$table->bigInteger('id', false, true)->primary();
|
||||
$table->string('title', 255);
|
||||
$table->string('url', 255);
|
||||
$table->string('icon', 255)->nullable();
|
||||
$table->bigInteger('parent_id')->nullable();
|
||||
$table->integer('order', false, true)->default(0);
|
||||
$table->timestamp('created_at', 6)->nullable();
|
||||
$table->timestamp('updated_at', 6)->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('menu');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('login_logs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('user_id');
|
||||
$table->string('ip_address', 20)->nullable();
|
||||
$table->string('user_agent')->nullable();
|
||||
$table->string('status', 10)->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
// Foreign key
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('login_logs');
|
||||
}
|
||||
};
|
||||
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Seed the application's database.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// User::factory(10)->create();
|
||||
|
||||
User::factory()->create([
|
||||
'name' => 'Test User',
|
||||
'email' => 'test@example.com',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Admin;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class AdminSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$admin = Admin::where('username', 'superadmin')->first();
|
||||
|
||||
if (is_null($admin)) {
|
||||
$admin = new Admin();
|
||||
$admin->name = "Super Admin";
|
||||
$admin->email = "superadmin@email.com";
|
||||
$admin->username = "superadmin";
|
||||
$admin->password = Hash::make('12345678');
|
||||
$admin->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Seed the application's database.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$this->call(UserSeeder::class);
|
||||
$this->call(AdminSeeder::class);
|
||||
$this->call(RolePermissionSeeder::class);
|
||||
$this->call(MenusTableSeeder::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class MenusTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
DB::table('menus')->insert([
|
||||
[
|
||||
'id' => 61,
|
||||
'title' => 'Role Manager',
|
||||
'url' => '/admin/roles',
|
||||
'icon' => 'mdi mdi-account-key-outline',
|
||||
'parent_id' => 62,
|
||||
'order' => 1,
|
||||
'created_at' => Carbon::now(),
|
||||
'updated_at' => Carbon::now(),
|
||||
],
|
||||
[
|
||||
'id' => 62,
|
||||
'title' => 'System Administrator',
|
||||
'url' => '#',
|
||||
'icon' => 'mdi mdi-cog-outline',
|
||||
'parent_id' => null,
|
||||
'order' => 99,
|
||||
'created_at' => Carbon::now(),
|
||||
'updated_at' => Carbon::now(),
|
||||
],
|
||||
[
|
||||
'id' => 63,
|
||||
'title' => 'Users List Accounts',
|
||||
'url' => '/admin/admins',
|
||||
'icon' => 'mdi mdi-account-group',
|
||||
'parent_id' => 62,
|
||||
'order' => 0,
|
||||
'created_at' => Carbon::now(),
|
||||
'updated_at' => Carbon::now(),
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Admin;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
|
||||
/**
|
||||
* Class RolePermissionSeeder.
|
||||
*
|
||||
* @see https://spatie.be/docs/laravel-permission/v5/basic-usage/multiple-guards
|
||||
*
|
||||
* @package App\Database\Seeds
|
||||
*/
|
||||
class RolePermissionSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
|
||||
/**
|
||||
* Enable these options if you need same role and other permission for User Model
|
||||
* Else, please follow the below steps for admin guard
|
||||
*/
|
||||
|
||||
// Create Roles and Permissions
|
||||
// $roleSuperAdmin = Role::create(['name' => 'superadmin']);
|
||||
// $roleAdmin = Role::create(['name' => 'admin']);
|
||||
// $roleEditor = Role::create(['name' => 'editor']);
|
||||
// $roleUser = Role::create(['name' => 'user']);
|
||||
|
||||
|
||||
// Permission List as array
|
||||
$permissions = [
|
||||
|
||||
[
|
||||
'group_name' => 'dashboard',
|
||||
'permissions' => [
|
||||
'dashboard.view',
|
||||
'dashboard.edit',
|
||||
]
|
||||
],
|
||||
[
|
||||
'group_name' => 'admin',
|
||||
'permissions' => [
|
||||
// admin Permissions
|
||||
'admin.create',
|
||||
'admin.view',
|
||||
'admin.edit',
|
||||
'admin.delete',
|
||||
'admin.approve',
|
||||
]
|
||||
],
|
||||
[
|
||||
'group_name' => 'role',
|
||||
'permissions' => [
|
||||
// role Permissions
|
||||
'role.create',
|
||||
'role.view',
|
||||
'role.edit',
|
||||
'role.delete',
|
||||
'role.approve',
|
||||
]
|
||||
],
|
||||
[
|
||||
'group_name' => 'profile',
|
||||
'permissions' => [
|
||||
// profile Permissions
|
||||
'profile.view',
|
||||
'profile.edit',
|
||||
'profile.delete',
|
||||
'profile.update',
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
// Do same for the admin guard for tutorial purposes.
|
||||
$admin = Admin::where('username', 'superadmin')->first();
|
||||
$roleSuperAdmin = $this->maybeCreateSuperAdminRole($admin);
|
||||
|
||||
// Create and Assign Permissions
|
||||
for ($i = 0; $i < count($permissions); $i++) {
|
||||
$permissionGroup = $permissions[$i]['group_name'];
|
||||
for ($j = 0; $j < count($permissions[$i]['permissions']); $j++) {
|
||||
$permissionExist = Permission::where('name', $permissions[$i]['permissions'][$j])->first();
|
||||
if (is_null($permissionExist)) {
|
||||
$permission = Permission::create(
|
||||
[
|
||||
'name' => $permissions[$i]['permissions'][$j],
|
||||
'group_name' => $permissionGroup,
|
||||
'guard_name' => 'admin'
|
||||
]
|
||||
);
|
||||
$roleSuperAdmin->givePermissionTo($permission);
|
||||
$permission->assignRole($roleSuperAdmin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Assign super admin role permission to superadmin user
|
||||
if ($admin) {
|
||||
$admin->assignRole($roleSuperAdmin);
|
||||
}
|
||||
}
|
||||
|
||||
private function maybeCreateSuperAdminRole($admin): Role
|
||||
{
|
||||
if (is_null($admin)) {
|
||||
$roleSuperAdmin = Role::create(['name' => 'superadmin', 'guard_name' => 'admin']);
|
||||
} else {
|
||||
$roleSuperAdmin = Role::where('name', 'superadmin')->where('guard_name', 'admin')->first();
|
||||
}
|
||||
|
||||
if (is_null($roleSuperAdmin)) {
|
||||
$roleSuperAdmin = Role::create(['name' => 'superadmin', 'guard_name' => 'admin']);
|
||||
}
|
||||
|
||||
return $roleSuperAdmin;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use App\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class UserSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$user = User::where('email', 'user1@gmail.com')->first();
|
||||
if (is_null($user)) {
|
||||
$user = new User();
|
||||
$user->name = "User 1";
|
||||
$user->username = "user1";
|
||||
$user->email = "user1@gmail.com";
|
||||
$user->password = Hash::make('12345678');
|
||||
$user->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,420 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 5.0.2
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: 127.0.0.1
|
||||
-- Generation Time: Sep 25, 2020 at 10:21 PM
|
||||
-- Server version: 10.4.13-MariaDB
|
||||
-- PHP Version: 7.4.7
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
START TRANSACTION;
|
||||
SET time_zone = "+00:00";
|
||||
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8mb4 */;
|
||||
|
||||
--
|
||||
-- Database: `laravel_role`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `admins`
|
||||
--
|
||||
|
||||
CREATE TABLE `admins` (
|
||||
`id` bigint(20) UNSIGNED NOT NULL,
|
||||
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`username` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`email_verified_at` timestamp NULL DEFAULT NULL,
|
||||
`password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `admins`
|
||||
--
|
||||
|
||||
INSERT INTO `admins` (`id`, `name`, `email`, `username`, `email_verified_at`, `password`, `remember_token`, `created_at`, `updated_at`) VALUES
|
||||
(1, 'Super Admin', 'superadmin@example.com', 'superadmin', NULL, '$2y$10$04D4VxiS5fbr8ll6towqjeTK21rP8MHxERjgpTeES5rdLD0c9bIsi', NULL, '2020-09-11 22:33:43', '2020-09-11 22:33:43'),
|
||||
(2, 'Admin', 'admin@gmail.com', 'admin', NULL, '$2y$10$.7HeNIXmdognq7i3eQ8YzOg/EXqzrJsSB0BqfXQBa8iB86JClmCs2', NULL, '2020-09-20 10:35:35', '2020-09-20 10:35:35'),
|
||||
(3, 'Client', 'client@example.com', 'client', NULL, '$2y$10$Nf4rahrK4DohTyAPdJWGeuEHddulfF0D3bANvI9mLNT7svLT88Pge', NULL, '2020-09-20 10:45:00', '2020-09-20 10:45:00'),
|
||||
(4, 'Test Admin', 'test@gmail.com', 'test', NULL, '$2y$10$i8mt.IzUxq9mq/3euOJ8E.CF7gprJCVNyV.mR8Vdn2LQgcLo/8kCi', NULL, '2020-09-25 13:18:32', '2020-09-25 13:18:32');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `failed_jobs`
|
||||
--
|
||||
|
||||
CREATE TABLE `failed_jobs` (
|
||||
`id` bigint(20) UNSIGNED NOT NULL,
|
||||
`connection` text COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`queue` text COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`payload` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`exception` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`failed_at` timestamp NOT NULL DEFAULT current_timestamp()
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `migrations`
|
||||
--
|
||||
|
||||
CREATE TABLE `migrations` (
|
||||
`id` int(10) UNSIGNED NOT NULL,
|
||||
`migration` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`batch` int(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `migrations`
|
||||
--
|
||||
|
||||
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES
|
||||
(29, '2014_10_12_000000_create_users_table', 1),
|
||||
(30, '2014_10_12_100000_create_password_resets_table', 1),
|
||||
(31, '2019_08_19_000000_create_failed_jobs_table', 1),
|
||||
(32, '2020_07_24_184706_create_permission_tables', 1),
|
||||
(33, '2020_09_12_043205_create_admins_table', 2);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `model_has_permissions`
|
||||
--
|
||||
|
||||
CREATE TABLE `model_has_permissions` (
|
||||
`permission_id` bigint(20) UNSIGNED NOT NULL,
|
||||
`model_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`model_id` bigint(20) UNSIGNED NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `model_has_roles`
|
||||
--
|
||||
|
||||
CREATE TABLE `model_has_roles` (
|
||||
`role_id` bigint(20) UNSIGNED NOT NULL,
|
||||
`model_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`model_id` bigint(20) UNSIGNED NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `model_has_roles`
|
||||
--
|
||||
|
||||
INSERT INTO `model_has_roles` (`role_id`, `model_type`, `model_id`) VALUES
|
||||
(1, 'App\\Models\\Admin', 1),
|
||||
(1, 'App\\User', 1),
|
||||
(1, 'App\\User', 3),
|
||||
(6, 'App\\Models\\Admin', 2),
|
||||
(6, 'App\\User', 3),
|
||||
(7, 'App\\Models\\Admin', 3),
|
||||
(8, 'App\\Models\\Admin', 4);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `password_resets`
|
||||
--
|
||||
|
||||
CREATE TABLE `password_resets` (
|
||||
`email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`token` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `permissions`
|
||||
--
|
||||
|
||||
CREATE TABLE `permissions` (
|
||||
`id` bigint(20) UNSIGNED NOT NULL,
|
||||
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`guard_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`group_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `permissions`
|
||||
--
|
||||
|
||||
INSERT INTO `permissions` (`id`, `name`, `guard_name`, `group_name`, `created_at`, `updated_at`) VALUES
|
||||
(1, 'dashboard.view', 'admin', 'dashboard', '2020-07-25 10:43:33', '2020-07-25 10:43:33'),
|
||||
(2, 'dashboard.edit', 'admin', 'dashboard', '2020-07-25 10:43:33', '2020-07-25 10:43:33'),
|
||||
(3, 'blog.create', 'admin', 'blog', '2020-07-25 10:43:33', '2020-07-25 10:43:33'),
|
||||
(4, 'blog.view', 'admin', 'blog', '2020-07-25 10:43:33', '2020-07-25 10:43:33'),
|
||||
(5, 'blog.edit', 'admin', 'blog', '2020-07-25 10:43:33', '2020-07-25 10:43:33'),
|
||||
(6, 'blog.delete', 'admin', 'blog', '2020-07-25 10:43:33', '2020-07-25 10:43:33'),
|
||||
(7, 'blog.approve', 'admin', 'blog', '2020-07-25 10:43:33', '2020-07-25 10:43:33'),
|
||||
(8, 'admin.create', 'admin', 'admin', '2020-07-25 10:43:33', '2020-07-25 10:43:33'),
|
||||
(9, 'admin.view', 'admin', 'admin', '2020-07-25 10:43:33', '2020-07-25 10:43:33'),
|
||||
(10, 'admin.edit', 'admin', 'admin', '2020-07-25 10:43:33', '2020-07-25 10:43:33'),
|
||||
(11, 'admin.delete', 'admin', 'admin', '2020-07-25 10:43:33', '2020-07-25 10:43:33'),
|
||||
(12, 'admin.approve', 'admin', 'admin', '2020-07-25 10:43:33', '2020-07-25 10:43:33'),
|
||||
(13, 'role.create', 'admin', 'role', '2020-07-25 10:43:33', '2020-07-25 10:43:33'),
|
||||
(14, 'role.view', 'admin', 'role', '2020-07-25 10:43:33', '2020-07-25 10:43:33'),
|
||||
(15, 'role.edit', 'admin', 'role', '2020-07-25 10:43:33', '2020-07-25 10:43:33'),
|
||||
(16, 'role.delete', 'admin', 'role', '2020-07-25 10:43:33', '2020-07-25 10:43:33'),
|
||||
(17, 'role.approve', 'admin', 'role', '2020-07-25 10:43:33', '2020-07-25 10:43:33'),
|
||||
(18, 'profile.view', 'admin', 'profile', '2020-07-25 10:43:33', '2020-07-25 10:43:33'),
|
||||
(19, 'profile.edit', 'admin', 'profile', '2020-07-25 10:43:33', '2020-07-25 10:43:33');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `roles`
|
||||
--
|
||||
|
||||
CREATE TABLE `roles` (
|
||||
`id` bigint(20) UNSIGNED NOT NULL,
|
||||
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`guard_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `roles`
|
||||
--
|
||||
|
||||
INSERT INTO `roles` (`id`, `name`, `guard_name`, `created_at`, `updated_at`) VALUES
|
||||
(1, 'superadmin', 'admin', '2020-07-25 10:43:33', '2020-07-25 10:43:33'),
|
||||
(6, 'Admin', 'admin', '2020-08-13 09:44:25', '2020-08-14 02:10:53'),
|
||||
(7, 'Client', 'admin', '2020-09-20 10:44:27', '2020-09-20 10:44:27'),
|
||||
(8, 'Test Role', 'admin', '2020-09-25 13:17:53', '2020-09-25 13:17:53');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `role_has_permissions`
|
||||
--
|
||||
|
||||
CREATE TABLE `role_has_permissions` (
|
||||
`permission_id` bigint(20) UNSIGNED NOT NULL,
|
||||
`role_id` bigint(20) UNSIGNED NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `role_has_permissions`
|
||||
--
|
||||
|
||||
INSERT INTO `role_has_permissions` (`permission_id`, `role_id`) VALUES
|
||||
(1, 1),
|
||||
(1, 6),
|
||||
(1, 7),
|
||||
(1, 8),
|
||||
(2, 1),
|
||||
(2, 6),
|
||||
(2, 8),
|
||||
(3, 1),
|
||||
(3, 6),
|
||||
(4, 1),
|
||||
(4, 6),
|
||||
(4, 7),
|
||||
(5, 1),
|
||||
(5, 6),
|
||||
(6, 1),
|
||||
(6, 6),
|
||||
(7, 1),
|
||||
(7, 6),
|
||||
(8, 1),
|
||||
(8, 8),
|
||||
(9, 1),
|
||||
(9, 6),
|
||||
(9, 8),
|
||||
(10, 1),
|
||||
(10, 8),
|
||||
(11, 1),
|
||||
(11, 8),
|
||||
(12, 1),
|
||||
(12, 8),
|
||||
(13, 1),
|
||||
(13, 6),
|
||||
(14, 1),
|
||||
(14, 6),
|
||||
(14, 7),
|
||||
(15, 1),
|
||||
(16, 1),
|
||||
(17, 1),
|
||||
(18, 1),
|
||||
(19, 1);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `users`
|
||||
--
|
||||
|
||||
CREATE TABLE `users` (
|
||||
`id` bigint(20) UNSIGNED NOT NULL,
|
||||
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`email_verified_at` timestamp NULL DEFAULT NULL,
|
||||
`password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `users`
|
||||
--
|
||||
|
||||
INSERT INTO `users` (`id`, `name`, `email`, `email_verified_at`, `password`, `remember_token`, `created_at`, `updated_at`) VALUES
|
||||
(1, 'Maniruzzaman Akash', 'manirujjamanakash@gmail.com', NULL, '$2y$10$/WuShlzx6A2xlSdg521Uj./pHpEGB04rB/toeltFTQQnFsR6MY/eG', NULL, '2020-07-25 10:43:33', '2020-07-25 10:43:33'),
|
||||
(3, 'test2', 'admin@akijfood.com', NULL, '$2y$10$/4YK7i2fVqdTfm0WAJM3lOnApbJx4w9vxUBZyjN3HqBTnV0zmcwO.', NULL, '2020-08-14 02:28:22', '2020-08-14 03:07:31');
|
||||
|
||||
--
|
||||
-- Indexes for dumped tables
|
||||
--
|
||||
|
||||
--
|
||||
-- Indexes for table `admins`
|
||||
--
|
||||
ALTER TABLE `admins`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD UNIQUE KEY `admins_email_unique` (`email`),
|
||||
ADD UNIQUE KEY `admins_username_unique` (`username`);
|
||||
|
||||
--
|
||||
-- Indexes for table `failed_jobs`
|
||||
--
|
||||
ALTER TABLE `failed_jobs`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Indexes for table `migrations`
|
||||
--
|
||||
ALTER TABLE `migrations`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Indexes for table `model_has_permissions`
|
||||
--
|
||||
ALTER TABLE `model_has_permissions`
|
||||
ADD PRIMARY KEY (`permission_id`,`model_id`,`model_type`),
|
||||
ADD KEY `model_has_permissions_model_id_model_type_index` (`model_id`,`model_type`);
|
||||
|
||||
--
|
||||
-- Indexes for table `model_has_roles`
|
||||
--
|
||||
ALTER TABLE `model_has_roles`
|
||||
ADD PRIMARY KEY (`role_id`,`model_id`,`model_type`),
|
||||
ADD KEY `model_has_roles_model_id_model_type_index` (`model_id`,`model_type`);
|
||||
|
||||
--
|
||||
-- Indexes for table `password_resets`
|
||||
--
|
||||
ALTER TABLE `password_resets`
|
||||
ADD KEY `password_resets_email_index` (`email`);
|
||||
|
||||
--
|
||||
-- Indexes for table `permissions`
|
||||
--
|
||||
ALTER TABLE `permissions`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Indexes for table `roles`
|
||||
--
|
||||
ALTER TABLE `roles`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Indexes for table `role_has_permissions`
|
||||
--
|
||||
ALTER TABLE `role_has_permissions`
|
||||
ADD PRIMARY KEY (`permission_id`,`role_id`),
|
||||
ADD KEY `role_has_permissions_role_id_foreign` (`role_id`);
|
||||
|
||||
--
|
||||
-- Indexes for table `users`
|
||||
--
|
||||
ALTER TABLE `users`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD UNIQUE KEY `users_email_unique` (`email`);
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for dumped tables
|
||||
--
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `admins`
|
||||
--
|
||||
ALTER TABLE `admins`
|
||||
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `failed_jobs`
|
||||
--
|
||||
ALTER TABLE `failed_jobs`
|
||||
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `migrations`
|
||||
--
|
||||
ALTER TABLE `migrations`
|
||||
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=34;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `permissions`
|
||||
--
|
||||
ALTER TABLE `permissions`
|
||||
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=20;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `roles`
|
||||
--
|
||||
ALTER TABLE `roles`
|
||||
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `users`
|
||||
--
|
||||
ALTER TABLE `users`
|
||||
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
|
||||
|
||||
--
|
||||
-- Constraints for dumped tables
|
||||
--
|
||||
|
||||
--
|
||||
-- Constraints for table `model_has_permissions`
|
||||
--
|
||||
ALTER TABLE `model_has_permissions`
|
||||
ADD CONSTRAINT `model_has_permissions_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE;
|
||||
|
||||
--
|
||||
-- Constraints for table `model_has_roles`
|
||||
--
|
||||
ALTER TABLE `model_has_roles`
|
||||
ADD CONSTRAINT `model_has_roles_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE;
|
||||
|
||||
--
|
||||
-- Constraints for table `role_has_permissions`
|
||||
--
|
||||
ALTER TABLE `role_has_permissions`
|
||||
ADD CONSTRAINT `role_has_permissions_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE,
|
||||
ADD CONSTRAINT `role_has_permissions_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE;
|
||||
COMMIT;
|
||||
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
@@ -4,7 +4,6 @@
|
||||
</IfModule>
|
||||
|
||||
RewriteEngine On
|
||||
|
||||
# Handle Authorization Header
|
||||
RewriteCond %{HTTP:Authorization} .
|
||||
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
||||
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
|
||||
|
||||
.select2-container--default .select2-selection--single .select2-selection__rendered {
|
||||
color: #495057; /* Mengubah warna teks */
|
||||
line-height: 36px; /* Menyesuaikan ketinggian teks */
|
||||
}
|
||||
|
||||
.select2-container--default .select2-selection--multiple {
|
||||
background-color: white; /* Mengubah warna background untuk multiple select */
|
||||
border: 1px solid #ced4da; /* Mengubah warna border */
|
||||
border-radius: 0.375rem; /* Membuatnya lebih sesuai dengan Bootstrap */
|
||||
}
|
||||
|
||||
.select2-container--default .select2-selection--multiple .select2-selection__choice {
|
||||
background-color: #154978; /* Mengubah warna pilihan yang dipilih */
|
||||
color: white; /* Mengubah warna teks di pilihan yang dipilih */
|
||||
border: 1px solid black; /* Warna border untuk pilihan yang dipilih */
|
||||
border-radius: 0.2rem;
|
||||
}
|
||||
.select2-container--default .select2-selection--single {
|
||||
background-color: white;
|
||||
border: 1px solid #ced4da; /* Mengubah warna border */
|
||||
border-radius: 0.375rem; /* Membuatnya lebih sesuai dengan Bootstrap */
|
||||
height: 38px; /* Menyesuaikan tinggi */
|
||||
}
|
||||
|
||||
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
|
||||
color: white;
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
font-weight: bold;
|
||||
margin-right: 2px;
|
||||
}
|
||||
Vendored
+312
@@ -0,0 +1,312 @@
|
||||
/**
|
||||
* Fungsi untuk merender Dropdown dinamis
|
||||
*
|
||||
* @param {string} dropdownSelector - Selector untuk Dropdown
|
||||
* @param {string} apiUrl - URL untuk endpoint API
|
||||
* @param {value} selectedValue - Value untuk Selected
|
||||
*/
|
||||
function DropdownDefaultAll(dropdownSelector, apiUrl, selectedValue = null) {
|
||||
var $dropdown = $(dropdownSelector);
|
||||
$dropdown.prop("disabled", true);
|
||||
$dropdown.empty(); // Menghapus semua opsi
|
||||
$dropdown.append('<option value="" selected disabled>Loading...</option>');
|
||||
|
||||
$.ajax({
|
||||
url: apiUrl, // URL untuk rute API yang diberikan sebagai parameter
|
||||
type: "GET", // Jenis permintaan
|
||||
success: function (data) {
|
||||
// Clear existing options
|
||||
$dropdown.empty();
|
||||
$dropdown.append('<option value=""> - All - </option>');
|
||||
|
||||
// Mengisi dropdown dengan data dari API
|
||||
if (data.length == 0) {
|
||||
$dropdown.empty();
|
||||
$dropdown.append(
|
||||
'<option value=""> - No data -</option>'
|
||||
);
|
||||
} else {
|
||||
$.each(data, function (index, item) {
|
||||
$dropdown.append(
|
||||
'<option value="' +
|
||||
item.value +
|
||||
'">' +
|
||||
item.text +
|
||||
"</option>"
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// Menetapkan nilai yang dipilih jika ada dan tidak null
|
||||
if (selectedValue !== null) {
|
||||
$dropdown.val(selectedValue);
|
||||
}
|
||||
|
||||
$dropdown.prop("disabled", false);
|
||||
},
|
||||
error: function (xhr) {
|
||||
// Tangani kesalahan
|
||||
$dropdown.prop("disabled", false);
|
||||
$dropdown.empty();
|
||||
$dropdown.append(
|
||||
'<option value="" selected disabled>Unable fetch data.</option>'
|
||||
);
|
||||
console.error("Error fetching data from API:", xhr.responseText);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Fungsi untuk merender Dropdown dinamis
|
||||
*
|
||||
* @param {string} dropdownSelector - Selector untuk Dropdown
|
||||
* @param {string} apiUrl - URL untuk endpoint API
|
||||
* @param {value} selectedValue - Value untuk Selected
|
||||
*/
|
||||
function DropdownRequire(dropdownSelector, apiUrl, selectedValue = null) {
|
||||
var $dropdown = $(dropdownSelector);
|
||||
$dropdown.prop("disabled", true);
|
||||
$dropdown.empty(); // Menghapus semua opsi
|
||||
$dropdown.append('<option value="" selected disabled>Loading...</option>');
|
||||
|
||||
$.ajax({
|
||||
async: true,
|
||||
url: apiUrl, // URL untuk rute API yang diberikan sebagai parameter
|
||||
type: "GET", // Jenis permintaan
|
||||
success: function (data) {
|
||||
// Clear existing options
|
||||
$dropdown.empty();
|
||||
$dropdown.append('<option value=""> - Select Data - </option>');
|
||||
|
||||
// Mengisi dropdown dengan data dari API
|
||||
if (data.length == 0) {
|
||||
$dropdown.empty();
|
||||
$dropdown.append(
|
||||
'<option value=""> - No data -</option>'
|
||||
);
|
||||
} else {
|
||||
$.each(data, function (index, item) {
|
||||
$dropdown.append(
|
||||
'<option value="' +
|
||||
item.value +
|
||||
'">' +
|
||||
item.text +
|
||||
"</option>"
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
if (selectedValue !== null) {
|
||||
$dropdown.val(selectedValue);
|
||||
}
|
||||
$dropdown.prop("disabled", false);
|
||||
},
|
||||
error: function (xhr) {
|
||||
// Tangani kesalahan
|
||||
$dropdown.prop("disabled", false);
|
||||
$dropdown.empty();
|
||||
$dropdown.append(
|
||||
'<option value="" selected disabled>Unable fetch data.</option>'
|
||||
);
|
||||
console.error("Error fetching data from API:", xhr.responseText);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function DropdownSelect2(dropdownSelector, apiUrl, placeholder = 'Select options', selectedValues = null) {
|
||||
var $dropdown = $(dropdownSelector);
|
||||
$dropdown.select2({
|
||||
placeholder: placeholder,
|
||||
allowClear: true,
|
||||
multiple: true, // Menambahkan fitur multiple select
|
||||
ajax: {
|
||||
url: apiUrl, // URL API untuk mengambil data
|
||||
dataType: 'json',
|
||||
delay: 250, // Menambahkan delay untuk mengurangi beban server
|
||||
processResults: function (data) {
|
||||
return {
|
||||
results: data.map(function(item) {
|
||||
return {
|
||||
id: item.value, // ID atau value dari opsi dropdown
|
||||
text: item.text // Text atau label dari opsi dropdown
|
||||
};
|
||||
})
|
||||
};
|
||||
},
|
||||
cache: true
|
||||
}
|
||||
});
|
||||
|
||||
// Jika ada nilai yang sudah terpilih, set value tersebut
|
||||
if (selectedValues !== null && selectedValues.length > 0) {
|
||||
selectedValues.forEach(function(value) {
|
||||
var newOption = new Option(value.text, value.id, true, true);
|
||||
$dropdown.append(newOption).trigger('change');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Initialize DataTable with dynamic settings and custom search.
|
||||
* @param {string} tableSelector - Selector for the DataTable element.
|
||||
* @param {string} urlAjax - URL for fetching data from the server.
|
||||
* @param {Array} columns - Columns configuration for DataTable.
|
||||
* @param {Object} options - Additional DataTable options.
|
||||
* @param {Object} searchParams - Custom search parameters with values.
|
||||
*/
|
||||
|
||||
var tableInstance = null;
|
||||
|
||||
function initDataTable(
|
||||
tableSelector,
|
||||
urlAjax,
|
||||
columns,
|
||||
options = {},
|
||||
customSearchForm = {}
|
||||
) {
|
||||
if ($.fn.DataTable.isDataTable(tableSelector)) {
|
||||
$(tableSelector).DataTable().destroy(); // Hapus instance DataTables sebelumnya
|
||||
$(tableSelector).empty(); // Kosongkan tabel untuk inisialisasi ulang
|
||||
}
|
||||
try {
|
||||
tableInstance = $(tableSelector).DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: {
|
||||
url: urlAjax,
|
||||
type: "GET",
|
||||
headers: {
|
||||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr(
|
||||
"content"
|
||||
),
|
||||
},
|
||||
data: function (d) {
|
||||
// Menambahkan parameter dari objek customSearchForm ke dalam request DataTables
|
||||
$.each(customSearchForm, function (key, value) {
|
||||
if (value !== "") {
|
||||
d[key] = value; // Hanya tambahkan jika ada nilainya
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
columns: columns,
|
||||
...options,
|
||||
});
|
||||
} catch (e) {
|
||||
console.log("Error occurred: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
function initSelect2EmailField(elementId, jsonData, selectedValue) {
|
||||
// Periksa jika jsonData kosong
|
||||
var dataval = [];
|
||||
|
||||
if (!jsonData || jsonData.length === 0) {
|
||||
console.error("JSON data is empty.");
|
||||
return;
|
||||
}
|
||||
dataval = JSON.parse(jsonData);
|
||||
let selectOptions = dataval.map(function (d) {
|
||||
return { id: d, text: d };
|
||||
});
|
||||
|
||||
// Menginisialisasi Select2 pada elemen yang diberikan
|
||||
$(elementId).select2({
|
||||
placeholder: "Select Email",
|
||||
theme: "bootstrap4",
|
||||
data: selectOptions,
|
||||
});
|
||||
|
||||
// Menampilkan nilai yang sudah dipilih di awal
|
||||
$(elementId).val(selectedValue).trigger("change");
|
||||
}
|
||||
|
||||
function initializeDropzoneUploader(element, url) {
|
||||
var dz = new Dropzone(element, {
|
||||
url: url, // URL untuk upload file
|
||||
maxFilesize: 10, // Ukuran maksimal file (MB)
|
||||
acceptedFiles: "", // Tipe file yang diizinkan
|
||||
addRemoveLinks: true, // Tampilkan tombol hapus
|
||||
dictRemoveFile: "Hapus",
|
||||
parallelUploads: 5, // Unggah paralel untuk 5 file sekaligus
|
||||
autoProcessQueue: false, // Proses otomatis saat file dipilih
|
||||
|
||||
// Fungsi callback untuk hasil sukses
|
||||
success: function (file, response) {
|
||||
console.log("File uploaded successfully", response);
|
||||
},
|
||||
|
||||
// Fungsi callback untuk menangani error
|
||||
error: function (file, response) {
|
||||
console.log("Failed to upload file", response);
|
||||
},
|
||||
});
|
||||
dz.autoDiscover = false;
|
||||
}
|
||||
|
||||
|
||||
function numericOnlyComma(inputText) {
|
||||
return inputText.replace(/[^0-9.]/g, ''); // Remove any character that is not a number or dot
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function shortChar(fileName) {
|
||||
if (fileName.length > 10) {
|
||||
return fileName.substring(0, 7) + '...';
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
|
||||
|
||||
function showLoader(element){
|
||||
$(element).waitMe({
|
||||
effect : 'ios',
|
||||
text : 'Sedang memuat data...',
|
||||
});
|
||||
}
|
||||
|
||||
function CheckArrayNull(params) {
|
||||
let invalidFields = [];
|
||||
|
||||
for (let key in params) {
|
||||
if (params.hasOwnProperty(key)) {
|
||||
if (params[key] === null || params[key] === undefined || params[key] === '') {
|
||||
invalidFields.push(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (invalidFields.length > 0) {
|
||||
swal.fire({
|
||||
title: 'Validation Error',
|
||||
text: `Field berikut: ${invalidFields.join(', ')} tidak boleh kosong.`,
|
||||
icon: 'error',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function ValidationField(paramValue, Messages) {
|
||||
if (paramValue === null || paramValue === undefined || paramValue === '') {
|
||||
swal.fire({
|
||||
text: `${Messages}`,
|
||||
icon: 'error',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function hideLoader(element){
|
||||
$(element).waitMe("hide");
|
||||
}
|
||||
|
||||
|
||||
Vendored
vendor/almasaeed2010/adminlte/dist/css/adminlte.min.css → public/templates/dist/css/adminlte.min.css
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user