Method AppHttpControllersCD4Controller::importcd4 does not exist. Facing this error

I want to upload excel file to database table CD4 and i am facing issue this method cant find


Route::get('importcd4',[CD4Controller::class, 'importcd4'])->name('importcd4');

here is controller function

  public function  importcd4(){
        Excel::import(new CD4, request()->file('file')->store('files'));
    return redirect()->route('cd4.index')->with('success');
    }
}

Need Solution for that and i why its showing this error to me….

register_activation_hook not firing when activating plugin

I have a main file for my plugin that contains the following:

<?php
/**
Plugin info
 */

define( 'PLUGIN__DIR', plugin_dir_path( __FILE__ ) );

require_once( PLUGIN__DIR . 'class.properties.php' );

// Init properties
add_action( 'init', array( 'properties', 'init' ) );

Inside the class that is required I add a register_activation_hook that needs to create some tables. I noticed no tables were added so I tried adding a die() or wp_die() to see if it even comes there at all, but nothing happens when activating the plugin.

So I am guessing it never gets to the activation hook, but why?

What am I missing?

My class that contains the activation hook:

<?php

class Properties
{
    private static $initiated = false;

    public static function init()
    {
        if (!self::$initiated) {
            self::initHooks();
        }
    }

    private static function initHooks()
    {
        self::$initiated = true;
        register_activation_hook(PLUGIN__DIR, 'initTables');
        add_menu_page('Properties', 'Properties', 'manage_options', 'properties/overzicht', array(__CLASS__, 'propertiesIndex'), 'dashicons-admin-multisite', 6);
    }

    public static function initTables()
    {
        wp_die();

        global $wpdb;
        $charset_collate = $wpdb->get_charset_collate();

        $sql = "
        CREATE TABLE ". $wpdb->prefix ."properties (
        id int(10) UNSIGNED NOT NULL,
        office_id int(10) UNSIGNED NOT NULL,
        system varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        reference varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        tiara_id varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        active tinyint(1) NOT NULL DEFAULT '1',
        vertrouwelijk tinyint(1) NOT NULL DEFAULT '0',
        publish tinyint(1) NOT NULL DEFAULT '1',
        featured tinyint(1) NOT NULL DEFAULT '0',
        hidden tinyint(1) NOT NULL DEFAULT '0',
        quiet tinyint(1) NOT NULL DEFAULT '0',
        straat varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
        huisnummer varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        huisnummer_toevoeging varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        postcode varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        wijk varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        gemeente varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        plaats varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
        provincie varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        land varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        latitude decimal(10,8) DEFAULT NULL,
        longitude decimal(11,8) DEFAULT NULL,
        status varchar(40) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        aanmelding varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        koop tinyint(1) NOT NULL DEFAULT '0',
        koopprijs_voorvoegsel varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        koopprijs int(10) UNSIGNED DEFAULT NULL,
        koopprijs_conditie varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        koopprijs_specificatie varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        vov_datum datetime DEFAULT NULL,
        vov_datum_tot datetime DEFAULT NULL,
        transactie_datum datetime DEFAULT NULL,
        woz_waarde int(10) UNSIGNED DEFAULT NULL,
        woz_peildatum date DEFAULT NULL,
        koopmengvorm varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        huur tinyint(1) NOT NULL DEFAULT '0',
        huurprijs_voorvoegsel varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        huurprijs int(10) UNSIGNED DEFAULT NULL,
        huurprijs_conditie varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        huurprijs_specificatie varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        prijs_tonen tinyint(1) NOT NULL DEFAULT '1',
        servicekosten int(10) UNSIGNED DEFAULT NULL,
        aanvaarding varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        aanvaarding_datum datetime DEFAULT NULL,
        aanvaarding_toelichting varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        omschrijving longtext COLLATE utf8mb4_unicode_ci,
        omschrijving_engels text COLLATE utf8mb4_unicode_ci,
        gekoppelde_makelaar varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        bouwvorm varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        openhuis_van datetime DEFAULT NULL,
        openhuis_tot datetime DEFAULT NULL,
        openhuis_toelichting text COLLATE utf8mb4_unicode_ci,
        ingevoerd_op datetime NOT NULL,
        gewijzigd_op datetime DEFAULT NULL,
        veiling_op datetime DEFAULT NULL,
        gewijzigd_status_op datetime DEFAULT NULL,
        gewijzigd_media_op datetime DEFAULT NULL,
        gewijzigd_prijs_op datetime DEFAULT NULL,
        verwijderd_op datetime DEFAULT NULL,
        created_at timestamp NULL DEFAULT NULL,
        updated_at timestamp NULL DEFAULT NULL,
        bouwtype_id int(10) UNSIGNED DEFAULT NULL,
        url_360 varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        url_tour varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        url_youtube varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        url_floorplanner varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        show_maps tinyint(1) NOT NULL DEFAULT '1',
        show_streetview tinyint(1) NOT NULL DEFAULT '1',
        prioriteit int(11) DEFAULT NULL,
        accountmanager varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL
        PRIMARY KEY  (id)
        )". $charset_collate .";";

        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
        dbDelta($sql);
    }

    public static function propertiesIndex()
    {
        include 'views/index.php';
    }

}

I also tried removing the activation hook from my class and adding it in the main plugin file just above the init action like so:

define( 'PLUGIN__DIR', plugin_dir_path( __FILE__ ) );

require_once( PLUGIN__DIR . 'class.properties.php' );

// Init properties
register_activation_hook( PLUGIN__DIR, array( 'Properties', 'initTables' ) );
add_action( 'init', array( 'properties', 'init' ) );

But again no results. Why is my activation hook not firing?

I want to output data into row without repeating the table head information

i want to try and output a data from database with some conditions but it keeps repeating the table head information along with it also i dont want the table to show on my applications if there is no data .please kindly help.

<?php
$query= "select *from `exitform`;";
if(count(fetchAll($query))>0){
    foreach(fetchAll($query)as $row){
        if($_SESSION['lm_name']==$row['manager']){                                                                             
            if($row['Dams']==Null and $row['empname']!=NULL){
    ?>                                     
    <div class="container">  
        <table class= "table">
        <thead>
            <th scope = "col">SI no</th>
            <th scope = "col">Employee Name </th>
            <th scope = "col"> Status Information </th>
            <center><th Scope = "col">  </th></center>
            <th scope = "col"> Date </th>
        </thead>
    </div>                                                    
        <td><?php echo $row['id'] ?>'</td>
        <td><?php echo $row['empname'] ?></td>
        <td><?php echo $row['message'] ?><td>
        <td><i><?php echo $row['date'] ?></i><td>
        <td><a href="linemanager.php?id=<?php echo $row['id']?>" 
            class="btn btn-primary my-2">Pending request</a></td>
    
    <?php

the code above is to output the data into the table , it worked but it was also repeating the table head information , how can it be rectified . kindly advice me on what to do.

this is the output

**SI no     Employee Name   Status Information                      Date**
87'     Kemi Adetiba    Kemi Adetiba is awaiting your approval      2022-11-21 08:49:46     
Pending request
**SI no     Employee Name    Status Information         Date**
88'     Alex        Alex is awaiting your approval  2022-11-21 08:50:56     
Pending request

but i don’t want the table head information to be duplicated

php update not changing in database

<?php include 'database/db.php'; 

if(isset($_POST['insertdata'])){

    $id = $_POST['id'];

    $fname = $_POST['fname'];
    $mname = $_POST['mname'];
    $lname = $_POST['lname'];
    $dbirth = $_POST['dbirth'];
    $email = $_POST['email'];
    $address = $_POST['address'];
    $number = $_POST['number'];
    $civil = $_POST['civil'];
    $gender = $_POST['gender'];
    $hobbies = $_POST['hobbies'];

    $sql = "UPDATE crud_activity_tb  SET fname='$fname', mname='$mname', lname='$lname', dbirth='$dbirth', email='$email', address='$address',
    number='$number', civil='$civil', gender='$gender', hobbies='$hobbies' WHERE id = '$id' ";
    $query_run = mysqli_query($conn, $sql);

    if($query_run){
        echo'<script>alert("data update");</script>';
        header('Location: index.php');
    }
    else{
        echo '<script>alert("data not save");</script>';
    }

}

?>

the data are not changing but there is no error.. please help me

woocommerce block delivery date based on single product

I need to block out a delivery date on my shipping calendar, if a certain product is selected. E.g if we can’t ship sunflowers on the 10th Dec for some reason and the customer has added sunflowers to the cart, when they get to the checkout page, the 10th Dec should be blocked out as unavailable.

I’ve found the following code, but I don’t know how to change it from product categories to single product ids.. and also to be able to specific the date I want blocked. Can anyone help with this please

add_action( 'woocommerce_after_checkout_form', 'add_checkout_script' );
function add_checkout_script() {
    // HERE define your product categories in the array (Ids, slugs or names)
    $categories = array( 't-shirts', 'sweet-shirts' );

    $product_id = $cart_item['product_id'];
    $found = false;

    // Loop through cart items to find out specific product categories
    foreach( WC()->cart->get_cart() as $cart_item )
        if( has_term( $categories, 'product_cat', $product_id ) ) {
            $found = true;
            break;
        }

    // If product categories are not found in cart items, we exit
    if ( ! $found ) return

    ?>
    <script>
        jQuery(function($) {
            var disableddates = ["14-02-2018", "25-12-2018"];

            function DisableSpecificDates(date) {
                var string = $.datepicker.formatDate("dd-mm-yy", date);
                return [disableddates.indexOf(string) == -1];
            }

            $("#billing_delivery_date").datepicker({
                dateFormat: "DD, d MM, yy",
                beforeShowDay: DisableSpecificDates,
                minDate: new Date()
            });
        });
    </script>
    <?php    
}

Thanks!

Deprecated: Return type of PHPUnitFrameworkTestCase::count() should either be compatible with Countable::count(): int, or the #[ReturnTypeWillChang

please help me with an error. I updated my app to php 8.1 and now I am getting this error :

Deprecated: Return type of PHPUnitFrameworkTestCase::count() should either be compatible with Countable::count(): int, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in path

TestCase :

/**
 * Counts the number of test cases executed by run(TestResult result).
 *
 * @return int
 */
public function count()
{
    return 1;
}

I tried adding #[ReturnTypeWillChange] in annotations :

/**
 * Counts the number of test cases executed by run(TestResult result).
 *
 * [ReturnTypeWillChange]
 */
public function count()
{
    return 1;
}

Problem with unit tests in Symfony (PHPUnit and WebTestCase)

I have a little problem with my unit tests, I don’t know how I can assert the recipe’s likes number after increase/decrease process in my test.
I give you my code below.

<?php

declare(strict_types=1);

namespace AppTestsController;

use AppRepositoryRecipeRepository;
use AppRepositoryUserRepository;
use SymfonyBundleFrameworkBundleTestWebTestCase;
use SymfonyBundleFrameworkBundleKernelBrowser;

class RecipeControllerTest extends WebTestCase
{
    private ?KernelBrowser $client = null;
    private ?RecipeRepository $recipeRepository = null;
    private ?UserRepository $userRepository = null;

    public function setUp(): void
    {
        $this->client = static::createClient();
        $this->recipeRepository = static::getContainer()->get(RecipeRepository::class);
        $this->userRepository = static::getContainer()->get(UserRepository::class);
        $this->urlGenerator = static::getContainer()->get('router.default');
    }

    /**
     * @dataProvider userIdProvider
     */
    public function testUserFavorites(int $userId)
    {
        $testUser = $this->userRepository->find($userId);
        /* login testUser */
        $this->client->loginUser($testUser);

        $recipeId = 1;
        /* simulate a user request to get a recipe */
        $crawler = $this->client->request('GET', $this->urlGenerator->generate('app_recipe_show', ['id' => $recipeId]));
        /* assert that the response is OK (200) */
        $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
        /* get the recipe from the database */
        $recipe = $this->recipeRepository->find($recipeId);

        $this->assertStringContainsString($recipe->getName(), $crawler->filter('h1.main-title')->text());
        /* if the recipe is in the user's favorites */
        $isFavorite = $testUser->getFavorites() !== null && in_array($recipe->getId(), $testUser->getFavorites(), true);
        /* submit button name to get favorite form */
        $selector = (!$isFavorite) ? 'Add to favorites' : 'Remove from favorites';
        /* favorite form */
        $form = $crawler->selectButton($selector)->form();
        /* submit the form */
        $this->client->submit($form);
        /* assert code 303 (HTTP_SEE_OTHER) redirection */
        $this->assertEquals(303, $this->client->getResponse()->getStatusCode());
        /* logout testUser */
        $this->client->request('GET', $this->urlGenerator->generate('app_logout'));
    }

    public function testRecipeLikes()
    {
        /* TODO */
        $recipeId = 1;
        $recipe = $this->recipeRepository->find($recipeId);
        /* after increase the number of likes with 3 users */
        $this->assertEquals(3, $recipe->getLikes());
        /* after decrease the number of likes with 3 users */
        $this->assertEquals(0, $recipe->getLikes());
    }

    public function userIdProvider()
    {
        return [
            [1], [2], [3]
        ];
    }
}

Quite simply, I just want assert the recipe’s likes number after increase/decrease process. If I first run the test the recipe (with id=1) will get 3 likes, and if I run one more time the recipe will get 0 likes. How could I do ? I had the idea to create one test named testRecipeLikes to check the recipe’s likes after process but I don’t know the process increase or deacrease. Thanks for your help ! If you have any comments on my code let me know! I’m a beginner in the discipline.

How to implode array of value in PHP [closed]

I am trying to use implode in PHP to insert this array of values as below:

[13:00, 14:00, 15:00, 16:00, 17:00, 18:00] but for some reason I get an error message warning: implode(): Invalid arguments passed I implemented my implode as below:

$time_picked = [13:00, 14:00, 15:00, 16:00, 17:00, 18:00];

$time_slot = implode(",", time_picked);


Can anyone help out with this? I think I need to wrap each array after the comma with a " " but will be glad about any hint.

array_search returns false when using a math expression as search parameter PHP [duplicate]

I’ve got an array like this:

$scores = array(22.5,88.8,56,0);

when I search for a value like this:
$index = array_search(88.8,$scores);
$index is correct (1)

When I do the following:
$search = 88.8; $index = array_search($search,$scores);
everything is fine too.

But when I generate the search parameter like this:
$search= (100/(intval($count[0]))*intval($countwon[0]));
it returns bool(false)
When I var_dump $search it is a float(88.8).

So what am I doing wrong here?

How to Filter Database Records using Dropdown (PHP)

I want to filter database records using dropdown and display it in table but my code isn’t working which the data is not displayed. Here are my codes:

This the dropdown code:

<div class="cent3">
      <div class="form-group row">
        <div class="col-lg-4">
            <select name="month" class="form-control col-sm-12">
            <option>Select Expenses Month</option>
            <option value="January" style="color:black;">January</option>
            <option value="February" style="color:black;">February</option>
            <option value="March" style="color:black;">March</option>
            <option value="April" style="color:black;">April</option>
            <option value="May" style="color:black;">May</option>
            <option value="June" style="color:black;">June</option>
            <option value="July" style="color:black;">July</option>
            <option value="August" style="color:black;">August</option>
            <option value="September"style="color:black;">September</option>
            <option value="October"style="color:black;">October</option>
            <option value="November" style="color:black;">November</option>
            <option value="December" style="color:black;">December</option>
          </select>
          <input type="submit" name="submit" class="btn btn-primary">
      </div>
    </div>
    </div> 

And this code for data to be display in the table:

<div class="cent3">
      <div class="col-md-6">
        <table class="table table-hover table-bordered" >
                <tr>
                  <caption><p style="color:black;">Expenses by Month</p></caption>
                  <th><p style="color:black;">Month</p></th>
                  <th><p style="color:black;">Amount</p></th>
                  <th><p style="color:black;">Category</p></th>      
                </tr>
          <tr>
              <?php
                if(isset($_POST['submit'])){
                  $month = $_POST['MONTH(expenses_date)'];
                  $amount = $_POST['totalexp'];
                  $category = $_POST['expenses_category'];


                  if ($month != "" ) {
                    $query = "SELECT expenses_category, SUM(expenses_amount) as totalexp,MONTHNAME(expenses_date)as month 
                              FROM expenses 
                              WHERE MONTH(expenses_date) = '$month' AND user_id = '$user_id'
                              GROUP BY expenses_category";

                    $data = mysqli_query($con, $query) or die('error');
                    if(mysqli_num_rows($data) > 0){
                      while($row = mysqli_fetch_assoc($data)){
                        $month = $row['month'];
                        $amount = $row['totalexp'];
                        $category = $row['expenses_category'];

                      ?>
                      <tr>
                        <td><?php echo $month;?></td>
                        <td><?php echo $amount;?></td>
                        <td><?php echo $category;?></td>
                      </tr>
                      <?php 
                      }
                    }
                    else{
                        ?>
                        <tr>
                          <td>Records Not Found!</td>
                        </tr>
                        <?php
                        }
                    }

                }        
              ?>
        </table>
      </div> 
    </div>  

Currently, I’m using date picker for expenses_date input (format ‘Y-M-D’) but I want to display it in month name. So, the data in the table should display month, total amount in category and the category

I really appreciate your help. Thank you.

Mysql query is taking so much time when trying to fetch data based on institutes using subquery

I have a question listing page where I want to sort the data with the following for each question

Requirement 1

  • Total Question attempted

  • Total Passed students

  • Passed students percentage

Requirement 2

  • Total Question attempted (for particular institute, Institute id is 20 in our case which we get by logged in user’s Institute)

  • Total Passed students (for particular institute, Institute id is 20 in our case which we get by logged in user’s Institute)

  • Passed students percentage (for particular institute, Institute id is 20 in our case which we get by logged in user’s Institute)

I have achieved “Requirement 1” but for the “Requirement 2” which is very similar to “Requirement 1” I forced to run 4 subqueries to find out below:

  • total_students_facility

  • passed_students_facility

  • percentage_facility

Which is making the query very slow for 9M records. I wonder if I can achieve “Requirement 2” also with join and correct indexing.

Also I run two subquery again to calculate percentage as we cannot use ALIAS in calculation it shows unknown column. As we can just use ALIAS in “group by”, “having”, and “order by” any solution will be helpful.

enter image description here


CREATE TABLE IF NOT EXISTS `mdl_question` (
  `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `category` bigint(20) NOT NULL DEFAULT 0,
  `parent` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `name` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `questiontext` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `questiontextformat` tinyint(4) NOT NULL DEFAULT 0,
  `generalfeedback` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `generalfeedbackformat` tinyint(4) NOT NULL DEFAULT 0,
  `defaultmark` decimal(12,7) NOT NULL DEFAULT 1.0000000,
  `penalty` decimal(12,7) NOT NULL DEFAULT 0.3333333,
  `qtype` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '''1''',
  `length` bigint(20) UNSIGNED NOT NULL DEFAULT 1,
  `stamp` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `version` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `hidden` tinyint(3) UNSIGNED NOT NULL DEFAULT 0,
  `timecreated` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `timemodified` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `createdby` bigint(20) UNSIGNED DEFAULT NULL,
  `modifiedby` bigint(20) UNSIGNED DEFAULT NULL,
  `type_data_id` bigint(20) NOT NULL,
  `img_id` bigint(20) DEFAULT NULL,
  `qimg_gallary_text` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `qrimg_gallary_text` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `qimg_gallary_ids` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `qrimg_gallary_ids` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `case_id` bigint(20) NOT NULL DEFAULT 0,
  `ques_type_id` bigint(20) DEFAULT NULL,
  `year` bigint(20) DEFAULT NULL,
  `spec` bigint(20) DEFAULT NULL,
  `sub_speciality_id` int(11) DEFAULT NULL,
  `sub_sub_speciality_id` int(11) DEFAULT NULL,
  `spec_level` bigint(20) DEFAULT 1,
  `is_deleted` int(11) NOT NULL DEFAULT 0,
  `sequence` int(11) NOT NULL DEFAULT 0,
  `sort_order` bigint(20) NOT NULL DEFAULT 0 COMMENT 'Question order in list',
  `idnumber` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `addendum` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `text_for_search` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'this is for the text based searching, this will store the text of the question without html tags',
  `text_for_search_ans` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `type_data_id` (`type_data_id`),
  UNIQUE KEY `mdl_ques_catidn_uix` (`category`,`idnumber`),
  KEY `mdl_ques_cat_ix` (`category`),
  KEY `mdl_ques_par_ix` (`parent`),
  KEY `mdl_ques_cre_ix` (`createdby`),
  KEY `mdl_ques_mod_ix` (`modifiedby`),
  KEY `id` (`id`),
  KEY `mq_spec_ix` (`spec`),
  KEY `sort_order` (`sort_order`),
  KEY `idx2` (`is_deleted`,`sort_order`,`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='The questions themselves';



CREATE TABLE IF NOT EXISTS `mdl_question_attempts` (
  `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `questionusageid` bigint(20) UNSIGNED NOT NULL,
  `slot` bigint(20) UNSIGNED NOT NULL,
  `behaviour` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `questionid` bigint(20) UNSIGNED NOT NULL,
  `variant` bigint(20) UNSIGNED NOT NULL DEFAULT 1,
  `maxmark` decimal(12,7) NOT NULL,
  `minfraction` decimal(12,7) NOT NULL,
  `flagged` tinyint(3) UNSIGNED NOT NULL DEFAULT 2,
  `questionsummary` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `rightanswer` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `responsesummary` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `timemodified` bigint(20) UNSIGNED NOT NULL,
  `maxfraction` decimal(12,7) DEFAULT 1.0000000,
  `in_remind_state` int(11) NOT NULL DEFAULT 0,
  `is_correct` tinyint(1) DEFAULT 1,
  `institution_id` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  UNIQUE KEY `mdl_quesatte_queslo_uix` (`questionusageid`,`slot`),
  KEY `mdl_quesatte_que2_ix` (`questionusageid`),
  KEY `is_correct` (`is_correct`),
  KEY `idx1` (`questionid`,`is_correct`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Each row here corresponds to an attempt at one question, as ';
COMMIT;


CREATE TABLE IF NOT EXISTS `mdl_quiz_attempts` (
  `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniqueid` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `quiz` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `userid` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `attempt` mediumint(9) NOT NULL DEFAULT 0,
  `sumgrades` decimal(10,5) DEFAULT NULL,
  `timestart` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `timefinish` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `timemodified` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `layout` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `preview` smallint(5) UNSIGNED NOT NULL DEFAULT 0,
  `needsupgradetonewqe` smallint(5) UNSIGNED NOT NULL DEFAULT 0,
  `comments` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_deleted` int(11) NOT NULL DEFAULT 0,
  `groupname` text CHARACTER SET utf8mb3 DEFAULT NULL,
  `pageid` int(11) DEFAULT 0,
  `currentpage` bigint(20) DEFAULT 0,
  `state` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT 'inprogress',
  `timemodifiedoffline` bigint(20) NOT NULL DEFAULT 0,
  `timecheckstate` bigint(20) DEFAULT 0,
  `retake` int(11) NOT NULL DEFAULT 0,
  `is_on_going` int(1) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  UNIQUE KEY `mdl_quizatte_uni_uix` (`uniqueid`),
  KEY `mdl_quizatte_use_ix` (`userid`),
  KEY `mdl_quizatte_qui_ix` (`quiz`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


CREATE TABLE IF NOT EXISTS `mdl_user` (
  `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `auth` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'manual',
  `confirmed` tinyint(1) NOT NULL DEFAULT 0,
  `policyagreed` tinyint(1) NOT NULL DEFAULT 0,
  `deleted` tinyint(1) NOT NULL DEFAULT 0,
  `suspended` tinyint(1) NOT NULL DEFAULT 0,
  `mnethostid` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `username` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `password` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `idnumber` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `firstname` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `lastname` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `email` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `recommend_email` tinyint(1) NOT NULL DEFAULT 0,
  `emailstop` tinyint(3) UNSIGNED NOT NULL DEFAULT 0,
  `icq` varchar(15) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `skype` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `yahoo` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `aim` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `msn` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `phone1` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `phone2` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `institution` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `department` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `address` varchar(70) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `city` varchar(120) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `country` varchar(2) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `lang` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'en',
  `theme` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `timezone` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '99',
  `firstaccess` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `lastaccess` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `lastlogin` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `currentlogin` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `lastip` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `secret` varchar(15) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `picture` tinyint(1) NOT NULL DEFAULT 0,
  `url` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `description` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `descriptionformat` tinyint(3) UNSIGNED NOT NULL DEFAULT 0,
  `mailformat` tinyint(3) UNSIGNED NOT NULL DEFAULT 1,
  `maildigest` tinyint(3) UNSIGNED NOT NULL DEFAULT 0,
  `maildisplay` tinyint(3) UNSIGNED NOT NULL DEFAULT 2,
  `htmleditor` tinyint(3) UNSIGNED NOT NULL DEFAULT 1,
  `ajax` tinyint(3) UNSIGNED NOT NULL DEFAULT 1,
  `autosubscribe` tinyint(3) UNSIGNED NOT NULL DEFAULT 1,
  `trackforums` tinyint(3) UNSIGNED NOT NULL DEFAULT 0,
  `timecreated` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `timemodified` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `trustbitmask` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `imagealt` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `screenreader` tinyint(1) NOT NULL DEFAULT 0,
  `furlastname` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `furfirstname` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `grade` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `group_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `jobtitle` varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL,
  `comment` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `actstatus` enum('1','0') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0',
  `slearncount` int(11) NOT NULL DEFAULT 0,
  `agrrement_status` tinyint(1) NOT NULL DEFAULT 0,
  `excludesure` int(11) DEFAULT 0,
  `calendartype` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'gregorian',
  `lastnamephonetic` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `firstnamephonetic` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `middlename` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `alternatename` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `version` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `reviewertype` smallint(6) DEFAULT 0,
  PRIMARY KEY (`id`),
  KEY `mdl_user_del_ix` (`deleted`),
  KEY `mdl_user_con_ix` (`confirmed`),
  KEY `mdl_user_fir_ix` (`firstname`),
  KEY `mdl_user_las_ix` (`lastname`),
  KEY `mdl_user_cit_ix` (`city`),
  KEY `mdl_user_cou_ix` (`country`),
  KEY `mdl_user_las2_ix` (`lastaccess`),
  KEY `mdl_user_ema_ix` (`email`),
  KEY `mdl_user_aut_ix` (`auth`),
  KEY `mdl_user_idn_ix` (`idnumber`),
  KEY `mdl_user_fir2_ix` (`firstnamephonetic`),
  KEY `mdl_user_las3_ix` (`lastnamephonetic`),
  KEY `mdl_user_mid_ix` (`middlename`),
  KEY `mdl_user_alt_ix` (`alternatename`),
  KEY `mdl_user_institution_ix` (`institution`),
  KEY `actstatus` (`actstatus`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='One record for each person';


CREATE TABLE IF NOT EXISTS `mdl_my_ques_type_data` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `question_id` bigint(20) DEFAULT NULL,
  `ques_pref` int(11) DEFAULT NULL,
  `ques_case` bigint(20) DEFAULT NULL,
  `ques_type_id` bigint(20) DEFAULT NULL,
  `year` bigint(20) DEFAULT NULL,
  `spec` bigint(20) DEFAULT NULL,
  `subspec` bigint(20) DEFAULT NULL,
  `subsubspec` bigint(20) DEFAULT NULL,
  `spec_level` bigint(20) NOT NULL,
  `is_deleted` tinyint(4) NOT NULL DEFAULT 0,
  `institute_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `question_id` (`question_id`),
  KEY `id` (`id`),
  KEY `ques_type_id` (`ques_type_id`),
  KEY `ques_case` (`ques_case`),
  KEY `spec` (`spec`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;


CREATE TABLE IF NOT EXISTS `mdl_my_ques_attributes` (
  `attrib_id` int(11) NOT NULL AUTO_INCREMENT,
  `question` bigint(20) NOT NULL,
  `related_question` varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `keywords` varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `explanation` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ext_link` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ext_link_txt` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `link_type` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `diff_id` int(11) DEFAULT NULL,
  `shuffle` int(11) DEFAULT NULL,
  `ownerid` int(11) DEFAULT NULL,
  `creator_id` int(11) DEFAULT NULL,
  `date_created` bigint(20) DEFAULT NULL,
  `last_modified_id` int(11) DEFAULT NULL,
  `last_modified_date` bigint(20) DEFAULT NULL,
  `status` int(11) DEFAULT NULL,
  `insti_id` bigint(20) NOT NULL DEFAULT 0,
  `ques_type` int(11) NOT NULL,
  `no_ques` bigint(20) NOT NULL DEFAULT 0,
  `is_deleted` tinyint(4) NOT NULL DEFAULT 0,
  `review_id` int(11) NOT NULL DEFAULT 1,
  `land_id` int(11) NOT NULL DEFAULT 1,
  `ques_label` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `exclude_self_learning` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `text_for_search` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'this is for the text based searching, this will store the text of the question without html tags',
  PRIMARY KEY (`attrib_id`),
  KEY `attrib_id` (`attrib_id`),
  KEY `question` (`question`),
  KEY `diff_id` (`diff_id`),
  KEY `mqa_ques_type_ix` (`ques_type`),
  KEY `mqa_insti_id_ix` (`insti_id`),
  KEY `status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


CREATE TABLE IF NOT EXISTS `specilities` (
  `sp_id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `parent_id` int(11) DEFAULT NULL,
  `percentage` float NOT NULL DEFAULT 0,
  `color` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `order` bigint(20) NOT NULL DEFAULT 0,
  `is_deleted` int(11) NOT NULL DEFAULT 0,
  `institute_id` int(11) NOT NULL DEFAULT 0,
  `sp_level` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`sp_id`),
  KEY `sp_id` (`sp_id`),
  KEY `mq_spec_parent_ix` (`parent_id`),
  KEY `specilities_institute_id` (`institute_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


select 
    mq.id, mq.ques_type_id, mq.qtype, mq.name, mq.qimg_gallary_ids, 
    qtd.question_id, qtd.year, qtd.spec, qtd.subspec, qtd.subsubspec, 
    qa.status, qa.review_id, qa.diff_id, qa.land_id, qa.insti_id, qa.exclude_self_learning, 
    COUNT(mqa.questionid) AS total_students,
    SUM(CASE WHEN is_correct = 1 then 1 else 0 end) passed_students,
    round((SUM(CASE WHEN is_correct = 1 then 1 else 0 end) / COUNT(mqa.questionid) * 100 ),2) AS percentage,
    
    (SELECT COUNT(mqas1.questionid) 
        FROM mdl_question_attempts mqas1 
        LEFT JOIN mdl_quiz_attempts mquizas1 ON mqas1.questionusageid=mquizas1.uniqueid
        LEFT JOIN mdl_user us1 ON mquizas1.userid=us1.id
        WHERE us1.institution=20 AND mqas1.questionid=mq.id) AS total_students_facility,
        
    (SELECT COUNT(mqas1.questionid) 
        FROM mdl_question_attempts mqas1 
        LEFT JOIN mdl_quiz_attempts mquizas1 ON mqas1.questionusageid=mquizas1.uniqueid
        LEFT JOIN mdl_user us1 ON mquizas1.userid=us1.id
        WHERE us1.institution=20 AND mqas1.questionid=mq.id AND mqas1.is_correct=1) AS passed_students_facility,
        
     round(((SELECT COUNT(mqas1.questionid) 
        FROM mdl_question_attempts mqas1 
        LEFT JOIN mdl_quiz_attempts mquizas1 ON mqas1.questionusageid=mquizas1.uniqueid
        LEFT JOIN mdl_user us1 ON mquizas1.userid=us1.id
        WHERE us1.institution=20 AND mqas1.questionid=mq.id AND mqas1.is_correct=1) / (SELECT COUNT(mqas1.questionid) 
        FROM mdl_question_attempts mqas1 
        LEFT JOIN mdl_quiz_attempts mquizas1 ON mqas1.questionusageid=mquizas1.uniqueid
        LEFT JOIN mdl_user us1 ON mquizas1.userid=us1.id
        WHERE us1.institution=20 AND mqas1.questionid=mq.id) * 100 ),2) AS percentage_facility
    
    from mdl_question mq 
    LEFT JOIN mdl_question_attempts mqa ON mq.id = mqa.questionid
    left join mdl_my_ques_type_data qtd on (qtd.question_id=mq.id) 
    left join mdl_my_ques_attributes qa on (qa.question=mq.id)
    left join specilities as s on(s.sp_id=qtd.spec) 
    where NOT mq.is_deleted
    and ((qa.status = 1) OR (qa.insti_id = 20 and qa.status = 0)) 
    GROUP BY mq.id 
    ORDER by mq.sort_order desc, mq.id DESC
    LIMIT 0,50;

Return an array into payload

I need to send my cart contens in orderlines.

I can get the my orderlines as follows:

 foreach ($jcart->get_contents() as $item) {
                
            $queryString .= 'name'  . $count.  '=' . urlencode($item['name']);
            $queryString .= 'unit_price'  . $count . '=' . urlencode($item['price']);
            $queryString .= 'quantity' . $count . '=' . urlencode($item['qty']);
      $queryString .= 'total_amount' . $count . '=' . (urlencode($item['qty']) * urlencode($item['price']));
            // Increment the counter
        ++$count;   
        }  

I want to send it as follows:

        $data = <<<DATA
        {
        "intent": "buy",
          "purchase_country": "GB",
          "purchase_currency": "GBP",
          "locale": "en-GB",
          "order_amount": 10,
          "order_tax_amount": 0,
            "order_lines": [
{
            "name": "name0",
            "quantity": quantity0,
            "unit_price": unit_price0,
            "total_amount": total_amount0
          },
    {
            "name": "name1",
            "quantity": quantity1,
            "unit_price": unit_price1,
            "total_amount": total_amount1
          }]
          
          
        }
        DATA;

How can I get my for each loop to populate the orderlines. so they can be send as example above

I tried:

 $data = <<<DATA
    {
    "intent": "buy",
      "purchase_country": "GB",
      "purchase_currency": "GBP",
      "locale": "en-GB",
      "order_amount": 10,
      "order_tax_amount": 0,
        "order_lines": [$queryString]
      
      
    }
    DATA;

This needs to be send as follows:

$url = "https://api.playground.klarna.com/payments/v1/sessions";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$headers = array(
   "Authorization: Basic $auth",
   "Content-Type: application/json",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
//for debug only!
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$resp = curl_exec($curl);
curl_close($curl);

This does not work
Any help welcome

Class PermissionTableSeeder does not exist

i have an error. when i run php artisan db:seed --class=PermissionTableSeeder

appeared this error

C:xampphtdocsvendorlaravelframeworksrcIlluminateContainerContainer.php:809
ReflectionException::(“Class PermissionTableSeeder does not exist”)

<?php

namespace DatabaseSeeders;

use IlluminateDatabaseSeeder;
use SpatiePermissionModelsPermission;
// 

// 

class PermissionTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $permissions = [
            'role-list',
            'role-create',
            'role-edit',
            'role-delete',
        ];

        foreach ($permissions as $permission) {
            Permission::create(['name' => $permission]);
        }
    }
}

jQuery modify existing ajax request to clear cache

I need to have no-cached ajax request, because I have problems, when it’s cached. I can’t modify original code, because it’s from plugin and I need stable coded solution to modify it.

I have tried this code:

jQuery.ajaxSetup({
   cache: false,
});

But unfortunatelly, it’s having again cache.
Can anyone give me a tip about it?
Thanks