Welcome Guest, Not a member yet? Register   Sign In
  datbase migration
Posted by: anjanesh - 02-27-2025, 02:27 AM - Replies (1)

Does CI not have the concept of make migrations / migrate for syncing database models to the database tables ?


  CI4.6 Error Pages
Posted by: SoccerGuy3 - 02-26-2025, 02:21 PM - Replies (4)

Since upgrading to CI4.6 I have noticed that the error pages thrown in Development aren't formatted like they were previously. Prior to 4.6 they were neatly organized and should the full error messages. Now I am getting a brown bar at the top with version info (which is very helpful) and then a bunch of truncated lines of the error messages in a large font. Then at the bottom is one window with some code related to the part of CI that has the error (not the code I wrote, but the CI Code). What happened to the old, helpful error pages? Did I do something wrong in the install? Can they be restored?[Image: screenshot-2025-02-26-at-1-20-07%E2%80%AFpm.png]

After some more digging, I found a tab at the very bottom called "response" and this was in it. Seems related, but no idea how to fix:

Code:
Fatal error: Uncaught Error: Class "Services" not found in /Users/marcpinnell/Sites/cattle/app/Views/errors/html/error_exception.php:228 Stack trace: #0 /Users/marcpinnell/Sites/cattle/vendor/codeigniter4/framework/system/Debug/BaseExceptionHandler.php(266): include() #1 /Users/marcpinnell/Sites/cattle/vendor/codeigniter4/framework/system/Debug/BaseExceptionHandler.php(269): CodeIgniter\Debug\BaseExceptionHandler->CodeIgniter\Debug\{closure}() #2 /Users/marcpinnell/Sites/cattle/vendor/codeigniter4/framework/system/Debug/ExceptionHandler.php(116): CodeIgniter\Debug\BaseExceptionHandler->render(Object(ErrorException), 500, '/Users/marcpinn...') #3 /Users/marcpinnell/Sites/cattle/vendor/codeigniter4/framework/system/Debug/Exceptions.php(162): CodeIgniter\Debug\ExceptionHandler->handle(Object(ErrorException), Object(CodeIgniter\HTTP\IncomingRequest), Object(CodeIgniter\HTTP\Response), 500, 1) #4 /Users/marcpinnell/Sites/cattle/vendor/codeigniter4/framework/system/Debug/Exceptions.php(317): CodeIgniter\Debug\Exceptions->exceptionHandler(Object(ErrorException)) #5 [internal function]: CodeIgniter\Debug\Exceptions->shutdownHandler() #6 {main} thrown in /Users/marcpinnell/Sites/cattle/app/Views/errors/html/error_exception.php on line 228


  Understanding the Basics of GitHub: An Introduction for Beginners
Posted by: InsiteFX - 02-26-2025, 07:59 AM - Replies (2)

Understanding the Basics of GitHub: An Introduction for Beginners


Photo SELECT FROM DATABASE CI 3
Posted by: rudibudi2491 - 02-26-2025, 05:04 AM - No Replies

hello everyone, I am using CI 3 and want to do multiple insert forms, this form contains select input from the database, after we select it will display the stock of the item we selected, when we press the (+) blue button to add a row using javascript, we must fill the select input with the same item data from the previous select input, now what I want to ask, is it possible that the select data that has been used will not be in the display of other select options.

if you see from the example, row 1 I select apple, and in row 2 I don't want the apple item to be option selected in row 2.

[Image: select.jpg]

Here my view code : 

PHP Code:
<button type="button" class="btn btn-info tambah-form" disabled><class="fa fa-plus"></i></button>
                                            <button type="button" class="btn btn-warning del-elements" disabled><class="fa fa-minus"></i></button>
                                            <div class="row" style="margin-top:20px;">
                                                <div class="col-8">
                                                    <div class="form-group">
                                                        <div class="controls">
                                                            <label>Nama Resep</label>
                                                            <select class="form-control select2 product" name="id_liquid1" id="id_liquid1" onchange="cari(1)" required>
                                                                <option>-- Nama Resep --</option>
                                                                <?php
                                                                
foreach ($resep as $value) {
                                                                    echo "<option value='$value->id_liquid'>$value->nama_resep ($value->ukuran mL)</option>";
                                                                }
                                                                ?>
                                                            </select>
                                                        </div>
                                                    </div>
                                                </div> 

My function javascript :
PHP Code:
$(".tambah-form").on('click', function(){
                
                
var jumlahkolom = $('#jumlahkolom').val();
                if(jumlahkolom == 5){
                    $(".tambah-form").attr('disabled','disabled');
                }
                
                row 
'<div class="rec-element'+i+'">'+
                        '<div class="row">'+
                            '<div class="col-8">'+
                                '<div class="form-group">'+
                                    '<div class="controls">'+
                                        '<label>Nama Resep</label>'+
                                        '<select class="form-control select2 product" name="id_liquid'+i+'" id="id_liquid'+i+'" onchange="cari('+i+')"  required>'+
                                            '<option>-- Nama Resep --</option>'+
                                            <?php foreach ($resep as $value) { ?>
                                                '<option value="<?php echo $value->id_liquid;?>"><?php echo $value->nama_resep." (".$value->ukuran." mL)";?></option>;'+
                                            <?php ?>
                                        '</select>'+
                                    '</div>'+
                                '</div>'+
                            '</div>'+ 


  Add initController section in spark make:controller
Posted by: Corsari - 02-25-2025, 10:35 PM - Replies (5)

Hello, in my personal opinion
It would be logical for

Code:
php spark make:controller

to include the

Code:
initController()

skeleton as part of its default template, similar to how it handles models with make:model . 

The parallel with

Code:
make:model

is fitting: when you generate a model with PHP Spark, it comes populated with various default settings that you can adapt or remove based on your needs. Applying the same approach to controllers would make sense.
Considering that:
  • Most controllers end up needing at least one model
  • The implementation of initController() follows a fairly standard pattern
  • It's easier to remove unnecessary code than to remember to add important code
This would help developers adopt the best practices suggested by the framework.

Regards
R.


  Shield Login possible on active = 0
Posted by: petewulf1 - 02-25-2025, 09:47 AM - Replies (5)

Hey guys,
as the title says, its possible to login with Shield although active flag is set to 0 in users table.
I can activate/deactivate user with the corresponding functions ($user->activate() / $user->activate() ), the status in the database gets updated correctly but the function $user->isActivated() always returns true.
My version is 4.6.0
There are several existig threads about this bug, but none of them addresses the problem.
Thanks!


  PAypal implementation, error with json response on develompment
Posted by: pippuccio76 - 02-25-2025, 06:16 AM - No Replies

Hi , starting by this code:
https://www.codexworld.com/paypal-standa...on-in-php/
 i try to implement paypal payment on ci4 ,
this is my form :

Code:
<?= $this->extend('vetrina/templates/layout_home') ?>
<?= $this->section('custom_css') ?>

<style type="text/css">

.header-style1{

    background-color: black;
}

.video-overlay, .video-placeholder{

    z-index: -1;
}

.input-group:not(.has-validation) > :not(:last-child):not(.dropdown-toggle):not(.dropdown-menu) {
    -webkit-border-top-left-radius: 1.2rem;
-webkit-border-bottom-left-radius: 1.2rem;
-moz-border-radius-topleft: 1.2rem;
-moz-border-radius-bottomleft: 1.2rem;
border-top-left-radius: 1.2rem;
border-bottom-left-radius: 1.2rem;
}


#buttons-container{

    text-align: center !important;
}

</style>

<?= $this->endSection() ?>

<?= $this->section('content') ?>

<div class="container mt-5 ">
   
    <div class="row mt-5">
          <div class="col-md-12 text-center">



                <div class="card mt-5 mb-5">
                    <div class="overlay hidden"><div class="overlay-content"><i class="fa-solid fa-spinner"></i></div></div>

                    <div class="card-header">
                        <h3 class="panel-title"><?=lang('Clienti_ricerca_tratte.paga') ?> <?=$totale_da_pagare; ?> <?=lang('Clienti_ricerca_tratte.con_paypal') ?></h3>
                       
                        <!-- Product Info -->
                        <p><b><?=lang('Clienti_ricerca_tratte.tratta') ?> <?= $tratta_acquistata_andata->punto_partenza; ?> -> <?= $tratta_acquistata_andata->punto_arrivo; ?> </p>
                        <p><b><?=lang('Clienti_ricerca_tratte.prezzo') ?>:</b> <?php echo 'EUR '.$totale_da_pagare ?></p>
                    </div>

                    <div class="card-body text-center">
                        <!-- Display status message -->
                        <div id="paymentResponse" class="hidden"></div>
                       
                        <!-- Set up a container element for the button -->                                       
                        <center><div id="paypal-button-container" ></div></center>         
                                   
                    </div>
                </div>


           
          </div>
         
    </div>
       


</div>









<?= $this->endSection() ?>

<?= $this->section('script') ?>
<script src="https://www.paypal.com/sdk/js?client-id=<?=$paypal_client_id ?>&currency=EUR"></script>

<script>
paypal.Buttons({
    // Sets up the transaction when a payment button is clicked
    createOrder: (data, actions) => {

        console.log('create_order');

        return actions.order.create({
            "purchase_units": [{
                "custom_id": "<?=$tratta_acquistata_andata->id; ?>",
                //"description": "<?php  ?>",
                "amount": {
                    "currency_code": "EUR",
                    "value": "<?= $totale_da_pagare; ?>",
                    "breakdown": {
                        "item_total": {
                            "currency_code": "EUR",
                            "value": "<?= $totale_da_pagare; ?>"
                        }
                    }
                },
               
               
                "items": [
                    {
                        "name": "<?= $tratta_acquistata_andata->id; ?>",
                        "description": "<?= $tratta_acquistata_andata->punto_partenza.'->'.$tratta_acquistata_andata->punto_arrivo ?>",
                        "unit_amount": {
                            "currency_code": "EUR",
                            "value": "<?=$totale_da_pagare; ?>"
                        },
                        "quantity": "1",
                        "category": "DIGITAL_GOODS"
                    },
                ]
               
            }]
        });
    },
    // Finalize the transaction after payer approval
    onApprove: (data, actions) => {

        console.log('onApprove');


        return actions.order.capture().then(function(orderData) {
            setProcessing(true);

            console.log('orderData'+JSON.stringify(orderData));

            var postData = {paypal_order_check: 1, order_id: orderData.id};
            fetch(' <?=base_url('paypal/check_validate') ?>', {
                method: 'POST',
                headers: {'Accept': 'application/json'},
                body: encodeFormData(postData)
            })
            .then( 
                    response =>{return  response.json() }
                    //console.log('response'+ JSON.stringify(response)),

            )
            .then((result) => {

                console.log('result:'+ JSON.stringify(result) );
               
                if(result.status == 1){

                    console.log('resultStatus-if');

                    window.location.href = "<?=base_url('paypal/success_pagamento_tratta/') ?>"+result.ref_id;
               
                }else{
                   
                    console.log('resultStatus-else');


                    const messageContainer = document.querySelector("#paymentResponse");
                    messageContainer.classList.remove("hidden");
                    messageContainer.textContent = result.msg;
                   
                    setTimeout(function () {
                        messageContainer.classList.add("hidden");
                        messageText.textContent = "";
                    }, 5000);
                }
               
                setProcessing(false);
            })
            .catch(error => console.log(error));
        });
       


    }
}).render('#paypal-button-container');

const encodeFormData = (data) => {

    console.log('encodeFormData');

    var form_data = new FormData();

    for ( var key in data ) {
        form_data.append(key, data[key]);
    }
   
    return form_data; 
}

// Show a loader on payment form processing
const setProcessing = (isProcessing) => {

    console.log('setProcessing');


    if (isProcessing) {
        document.querySelector(".overlay").classList.remove("hidden");
    } else {
        document.querySelector(".overlay").classList.add("hidden");
    }
}   
</script>

<?= $this->endSection() ?>
This is my method check_validate:
Code:
public function check_validate()
    {

        //log_message('debug','inside check_validate');

        $pagamenti_paypal_model = new Pagamenti_paypalModel();
        $tratte_acquistate_model = new Tratte_acquistateModel();

        $paypal = new PaypalCheckout;


       
        $response = array('status' => 0, 'msg' => 'Transaction Failed!');

        if(!empty($_POST['paypal_order_check']) && !empty($_POST['order_id'])){
            // Validate and get order details with PayPal API
            try { 
                $order = $paypal->validate($_POST['order_id']);
            } catch(Exception $e) { 
                $api_error = $e->getMessage(); 
            }

            //log_message('debug','Order:'.print_r($order,true));
           
            if(!empty($order)){
                $order_id = $order['id'];
                $intent = $order['intent'];
                $order_status = $order['status'];
                $order_time = date("Y-m-d H:i:s", strtotime($order['create_time']));
       
                if(!empty($order['purchase_units'][0])){



                    $purchase_unit = $order['purchase_units'][0];
       
                    $id_tratta_acquistata = $purchase_unit['custom_id'];

                    $item = $purchase_unit['items'][0];

                    //log_message('debug','items'.json_encode($item));

                    $category = $item['category'];

                    $item_name = $item['description'];
                   

                    if(!empty($purchase_unit['amount'])){
                        $currency_code = $purchase_unit['amount']['currency_code'];
                        $amount_value = $purchase_unit['amount']['value'];
                    }
       
                    if(!empty($purchase_unit['payments']['captures'][0])){
                        $payment_capture = $purchase_unit['payments']['captures'][0];
                        $transaction_id = $payment_capture['id'];
                        $payment_status = $payment_capture['status'];

                        $seller_receivable_breakdown = $payment_capture['seller_receivable_breakdown'];


                        //log_message('debug','seller_receivable_breakdown'.print_r($seller_receivable_breakdown,true));

                        $paid_fee = $seller_receivable_breakdown['paypal_fee']['value'];

                        log_message('debug','seller_receivable_breakdown'.print_r($seller_receivable_breakdown['paypal_fee'],true));


                    }


                    /*
                    if(!empty($purchase_unit['payee'])){
                        $payee = $purchase_unit['payee'];
                        $payee_email_address = $payee['email_address'];
                    }
                    */
                }
       
                $payment_source = '';

                if(!empty($order['payment_source'])){
                    foreach($order['payment_source'] as $key=>$value){
                        $payment_source = $key;
                    }
                }
       
                if(!empty($order['payer'])){
                    $payer = $order['payer'];
                    $payer_id = $payer['payer_id'];
                    $payer_name = $payer['name'];
                    $payer_given_name = !empty($payer_name['given_name'])?$payer_name['given_name']:'';
                    $payer_surname = !empty($payer_name['surname'])?$payer_name['surname']:'';
                    $payer_full_name = trim($payer_given_name.' '.$payer_surname);
                    $payer_full_name = htmlspecialchars($payer_full_name);

                    //log_message('debug','payer_full_name:'.$payer_full_name);
       
                    $payer_email_address = $payer['email_address'];
                    $payer_address = $payer['address'];
                    $payer_country_code = !empty($payer_address['country_code'])?$payer_address['country_code']:'';
                }
       
                if(!empty($order_id) && $order_status == 'COMPLETED'){


                    $db = \Config\Database::connect();
                   
                    $db->transStart();
                       
                   


                    // Check if any transaction data is exists already with the same TXN ID
                    $pagamenti_paypal_model->where('transaction_id',$transaction_id)
                                            ->first();

                    log_message('debug','pagamenti_paypal_model:'.$pagamenti_paypal_model->getLastQuery());

                    if(!empty($row_id)){
                   
                        $payment_id = $row_id;
                   
                    }else{
                       
                        // Insert transaction data into the database
                        $data_to_insert_pagamenti = [

                            'id_tratte_acquistate' => $id_tratta_acquistata,
                            'payer_id' => $payer_id,
                            'payer_name' => $payer_full_name,
                            'payer_email' => $payer_email_address,
                            'payer_country' => $payer_country_code,
                            'order_id' => $order_id,
                            'transaction_id' => $transaction_id,
                            'paid_amount' => $amount_value,
                            'paid_fee' => $paid_fee,
                            'paid_amount_currency' => $currency_code,
                            'payment_source' => $payment_source,
                            'payment_status' => $payment_status,

                        ];

                        log_message('debug','data_to_insert_pagamenti'.json_encode($data_to_insert_pagamenti));


                        $pagamenti_paypal_model->insert($data_to_insert_pagamenti);


                        if($pagamenti_paypal_model->getInsertID()){

                            $data_to_update_tratta_acquistata=[

                                'deleted_at' =>NULL

                            ];

                            $tratte_acquistate_model->update($id_tratta_acquistata,$data_to_update_tratta_acquistata);

                        }
                    }
       
                    $db->transComplete();



                    if($db->transStatus()!==false) {

                        $ref_id_enc = base64_encode($transaction_id);
                        $response = array('status' => 1, 'msg' => 'Transaction completed!', 'ref_id' => $ref_id_enc);
                   
                    }



                }


            }else{

                $response['msg'] = $api_error;
            }
        }
       
        // Make sure file is not cached (as it happens for example on iOS devices)
        header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
        header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
        header("Cache-Control: no-store, no-cache, must-revalidate");
        header("Cache-Control: post-check=0, pre-check=0", false);
        header("Pragma: no-cache");

        log_message('debug','response:'.json_encode($response));
        echo json_encode($response);
   
    }
   
I spend several hours tofind the error and the error was debug bar on     CI_ENVIRONMENT = development
Why?


ANother question how can i resend transaction encoded on url ? because base64_encode($transaction_id);  return equal at and of string ...


  connecting db2 database
Posted by: foxedu - 02-25-2025, 04:23 AM - Replies (4)

Please help me connect CI4 to a db2 database.
I need to be able to read data from this database.


  Bonfire 2 Shield Config Files are incorrect
Posted by: positron - 02-25-2025, 01:41 AM - Replies (4)

To test Bonfire 2 which has installation guide here: https://lonnieezell.github.io/Bonfire2/i...tallation/
I followed every step proposed by the document. First I created a CI4 AppStarter project. Then configured the .json file. Finally installed bonfire with composer. However I realized that bonfire installation modifies the Shield configuration files in Config wrongly. Therefore "php spark bf:install --continue" gives below error:

Code:
CodeIgniter v4.6.0 Command Line Tool - Server Time: 2025-02-25 08:32:54 UTC+00:00

Running all new migrations...
[Error]
Class "Config\BonfireAuth" not found
at APPPATH\Config\Auth.php:19

Backtrace:
  1    VENDORPATH\composer\ClassLoader.php:576
      include()

  2    VENDORPATH\composer\ClassLoader.php:427
      Composer\Autoload\{closure}('C:\\..\\Desktop\\Github\\bf2test\\vendor\\composer/../../app/Config\\Auth.php')

  3    [internal function]
      Composer\Autoload\ClassLoader()->loadClass('Config\\Auth')

  4    SYSTEMPATH\Config\Factories.php:290
      class_exists('Config\\Auth')

  5    SYSTEMPATH\Config\Factories.php:216
      CodeIgniter\Config\Factories::locateClass([...], 'Auth')

  6    SYSTEMPATH\Config\Factories.php:159
      CodeIgniter\Config\Factories::getDefinedInstance([...], 'Auth', [])

  7    SYSTEMPATH\Config\Factories.php:188
      CodeIgniter\Config\Factories::__callStatic('config', [])

  8    SYSTEMPATH\Common.php:210
      CodeIgniter\Config\Factories::get('config', 'Auth')

  9    VENDORPATH\codeigniter4\shield\src\Database\Migrations\2020-12-28-223112_create_auth_tables.php:32
      config('Auth')

10    SYSTEMPATH\Database\MigrationRunner.php:837
      CodeIgniter\Shield\Database\Migrations\CreateAuthTables()->__construct(Object(CodeIgniter\Database\MySQLi\Forge))

11    SYSTEMPATH\Database\MigrationRunner.php:182
      CodeIgniter\Database\MigrationRunner()->migrate('up', Object(stdClass))

12    SYSTEMPATH\Commands\Database\Migrate.php:85
      CodeIgniter\Database\MigrationRunner()->latest(null)

13    SYSTEMPATH\CLI\Commands.php:70
      CodeIgniter\Commands\Database\Migrate()->run([...])

14    SYSTEMPATH\Common.php:190
      CodeIgniter\CLI\Commands()->run('migrate', [...])

15    VENDORPATH\lonnieezell\bonfire\src\Commands\Install.php:272
      command('migrate')

16    VENDORPATH\lonnieezell\bonfire\src\Commands\Install.php:132
      Bonfire\Commands\Install()->migrate()

17    SYSTEMPATH\CLI\Commands.php:70
      Bonfire\Commands\Install()->run([...])

18    SYSTEMPATH\CLI\Console.php:48
      CodeIgniter\CLI\Commands()->run('bf:install', [...])

19    SYSTEMPATH\Boot.php:360
      CodeIgniter\CLI\Console()->run()

20    SYSTEMPATH\Boot.php:104
      CodeIgniter\Boot::runCommand(Object(CodeIgniter\CLI\Console))

21    ROOTPATH\spark:84
      CodeIgniter\Boot::bootSpark(Object(Config\Paths))

Finally I realized this issue:
Auth, AuthGroups and AuthToken Config classes are defined this way:

PHP Code:
use CodeIgniter\Shield\Config\AuthGroups as ShieldAuthGroups;
class 
AuthGroups extends BonfireAuthGroups
-----
use 
CodeIgniter\Shield\Config\Auth as ShieldAuth;
class 
Auth extends BonfireAuth
-----
use 
CodeIgniter\Shield\Config\AuthToken as ShieldAuthToken;
/**
 * Configuration for Token Auth and HMAC Auth
 */
class AuthToken extends BonfireAuthToken 

Those classes must extend "Shield" I guess. Because there is no BonfireAuth related class. I dont know why I face this issue. Maybe it is because of first initialization of bonfire with "
Code:
php spark bf:install". Any help will be appreciated. Thanks.

p.s. Should I create an issue in bonfire github repo instead of posting here? Please inform.


  Flashdata is cached and repeat with refresh
Posted by: manojnation7 - 02-25-2025, 12:47 AM - No Replies

Hi, I am using ci4 and made a project on it, now i have added cache filter to it and cache is working fine, but the issue is i have some forms in various places of project, where user can send query, but the issue is the flashdata which is showing after submitting the form is displaying with refresh means 1st time showing, which is good but when you refresh the page its showing again and is being cached, if i remove cache filter then its working fine, I tried many solutions but still no luck, added cache clear in before method, but its not working, its same, check the code,

    

PHP Code:
public function before(RequestInterface $request$arguments null)
{
    $cache Services::cache();
    $response service('response');
    $uri $request->uri->getPath();
    $cacheKey $this->sanitizeCacheKey($uri);
    // ✅ If Flashdata exists, clear cache for this page & disable caching
    if (session()->getFlashdata('success') || session()->getFlashdata('error')) {
        $cache->delete($cacheKey); // Clear cache for this page
        log_message('info'"? Cache Cleared due to Flashdata for: " $cacheKey);
        $response->setHeader('Cache-Control''no-store, no-cache, must-revalidate, max-age=0');
        $response->setHeader('Pragma''no-cache');
        return;
    }
    // ✅ Proceed with cache check
    $cachedResponse $cache->get($cacheKey);
    if ($cachedResponse instanceof ResponseInterface) {
        log_message('info'"? Cache HIT: " $cacheKey);
        return $cachedResponse;
    }
    log_message('info'"❌ Cache MISS: " $cacheKey);


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Latest Threads
Ajax post failing with Ty...
by PaulC
1 hour ago
Magic login link not work...
by InsiteFX
3 hours ago
Is codeigniter 5 upco...
by InsiteFX
4 hours ago
Why PHP is still worth le...
by InsiteFX
9 hours ago
Any user guid or video o...
by msnisha
Yesterday, 02:30 PM
MVC vs MVCS vs CodeIgnite...
by massimiliano1.mancini
Yesterday, 10:15 AM
Is hiring a digital marke...
by Markhenry123
Yesterday, 02:45 AM
my controller fails to fi...
by PaulC
Yesterday, 01:40 AM
My Library cannot see ses...
by InsiteFX
05-08-2025, 08:48 PM
update the framework to t...
by captain-sensible
05-08-2025, 12:14 PM

Forum Statistics
» Members: 145,096
» Latest member: sin88boats
» Forum threads: 78,383
» Forum posts: 379,424

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB