What is the correct format for passing parameters to PHP API with JSON? Noob here Sample example appreciated

http://happytohelptech.com/myhelpangels/ost_wbs/?query=user&condition=specific&sort=id&parameters={id=2}
Receiving Error = {“status”:”Error”,”data”:”Incorrect API Format”}

am I writing this right according to
https://bmsvieira.gitbook.io/osticket-api/users/get-specific-by-id

https://bestofphp.com/repo/BMSVieira-osticket-api-php-third-party-apis

Please guide me to a working example, thanks in advance

How to make a checkbox display an array Laravel php?

I have multiple checkboxes, I want to display an array of data when multiple checkboxes are clicked, but only one value is displayed, how to display an array ?What is the problem?

   @foreach($langs as $key => $lang)
                     <input type="checkbox" name="foo[]"  value="{{$key}}"> 
                     <label>{{ $lang }}</label>, 
   @endforeach

To controller

public function Method(Request $request)
 {
    foreach((array)$request->input('foo') as $value){
    $file = 'la.txt';
    file_put_contents($file,$value );
    }

     return redirect()->route('profile');
     
 }

Laravel Blade Does Not Load Up Somehow

I have this Blade:

<!DOCTYPE html>
<html lang="en" dir="rtl">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="style.css" />
    <title>Document</title>
  </head>
  <body>
    ...
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <script src="./grid.js"></script>
  </body>
</html>

As you can see I have called the style.css and the grid.js and they’re located in the root folder of public_html properly.

And here is also how I defined the public_html:

public function register()
    {
        $this->app->bind('path.public', function(){
            return base_path() . '/public_html';
        });
    }

So what’s going wrong here? How can I solve this issue and properly load the blade?

Checkbox with 2 values Laravel

i want to make checkbox with 2 values – One with “Yes” and other with “No” and send to database. I try to make it when is not send “Yes” to give me “No” but now dont work. I would be grateful if you could tell me how to do it and what are the errors in my code

<form method="post" action="/adminpanel/hofswitch">
                            @csrf
                            <div class="card-body">
                                @foreach($char as $value)

                                <div class="card-body">
                                @if($value->status == "Yes")
                                    <input type="hidden" name="id[]" value="{{$value->id}}">
                                    <input type="checkbox" name="switch[]" value="Yes" checked data-bootstrap-switch data-off-color="danger" data-on-color="success">

                                    <div class="form-group">
                                        <label class="col-form-label" for="inputSuccess"><i class="fas fa-check"></i> Character Class</label>
                                        <input type="text" name="class" value="{{$value->class}}" class="form-control is-valid" id="inputSuccess" readonly="true" placeholder="{{$value->class}}">
                                    </div>
                                    @else
                                        <input type="hidden" name="id[]" value="{{$value->id}}">
                                        <input type="checkbox" name="switch[]" value="Yes" data-bootstrap-switch data-off-color="danger" data-on-color="success">

                                        <div class="form-group">
                                            <label class="col-form-label" for="inputError"><i class="far fa-times-circle"></i> Character Class</label>
                                            <input type="text" name="class" value="{{$value->class}}" class="form-control is-invalid" id="inputError" readonly="true" placeholder="{{$value->class}}">
                                        </div>
                                    @endif
                                </div>

                            @endforeach

                                <!-- /.card-body -->

                                    <div class="card-footer">
                                        <button type="submit" class="btn btn-primary col-12">Submit</button>
                                    </div>
                        </form>

And controller

public function hof_switch(Request $request)
{

    foreach ($request->id as $i => $id) {
        $switch = $request->switch;
        if (!isset($request->switch))
        {
            $switch = "No";
        }


        $update = DB::connection('XXX')->table('XXX_HOF')
            ->where('class', $request->class[$i])
            ->update(
                [
                    'status' => $switch[$i],
                ]);
     
    }

    return redirect()->back()->withSuccess('You have switch this class successfully!');
}

database debug unnecessary requests yii2

I have a small gallery, it has two types of pictures, one is a preview, the other is a regular one, it opens when you click on the preview.

Here is this code, which is on line 173 of the controller:

$model = Gallery::getActive()->where(['code' => $code])->with(
  [
    'itemsPhoto' => static function (ActiveQuery $query) {
      $query->with(['photo', 'preview']);
    }
  ]
)->one();

So, I opened DB debug to look at the requests for this gallery, and I got this:

enter image description here

I have two pictures in my gallery right now. That is, for each picture there is a separate request (preview and regular).

How can I make requests for all pictures in the gallery not come separately, but all together, in one request, should this be done in the controller in this line or in another place?

my sql to laravel query builder: show summary of all payments made and total of invoices by date by laravel query

enter image description here

The Sql Query For this given image tables to take records is:

select
  x.date,
  sum(x.invoiceTotal) as invoiceTotal,
  sum(x.paymentsMade) as paymentMade
from
 (select
   i.date, 
   sum(i.rate * i.quantity /*?*/) as invoiceTotal,
   null as paymentMade    
 from
   invoice i
   inner join invoiceitem ii on ii.invoiceId = i.invoiceId
 group by
   i.date
 union all
 select
   p.date,
   null as invoiceTotal,
   sum(p.amount) as paymentMade    
 from
   payment p
 group by
   p.date) x
group by
  x.date
order by
  x.date

Now I want to write this query in laravel query builder how can i do that, I am new to laravel.

enter image description here

enter image description here

The output of the given my sql query

Here is the output of the given my sql query

take out components from array session and save in Database LARAVEL 9

How are you? Hope well. I have e-commerce project on laravel 9. Actually i want to make checkout. I have add to cart function with sessions(it works fine), i want to make checkout. I am recieving cart with sessions

 $order = session('cart');
 var_dump($order);

This is working fine. It makes output with array(‘title’,’price’,’quantity’). Actually i want to put out each other and next save it in database.

array(1) { [52]=> array(3) { ["title"]=> string(11) "MacBook Pro" ["quantity"]=> int(1) 
["price"]=> string(7) "2399.99" } }

This is array, which i have in checkout page. Please help me. I want to put out each other, for example: $order_title = ….
$order_price = …
$order_quantity = …
and next save it in database, table named ‘orders’.

Error: DOMDocument::loadXML(): Input is not proper UTF-8, indicate encoding ! Bytes: 0xE7 0x29 0x82 0x80 in Entity, line: 1

I want to integrate the Aadhaar Card Authentication API for Aadhaar number Verification in PHP. I tried this and wrote code for API access.

I am getting this error. Please help me in generating the XML encryption field data below in PHP?

   <Auth uid="" tid="" ac="" sa="" ver="" txn="" lk="">
        <Uses pi="" pa="" pfa="" bio="" bt="" pin="" otp=""/>
        <Tkn type="" value=""/>
        <Meta udc="" fdc="" idc="" pip="" lot=”G|P” lov=""/>
        <Skey ci="" ki="">encrypted and encoded session key</Skey>
        <Data type=”X|P”>encrypted PID block</Data>
        <Hmac>SHA-256 Hash of Pid block, encrypted and then encoded</Hmac>
        <Signature>Digital signature of AUA</Signature>
    </Auth>

Redirect http to https in htaccess file

What would be the correct way to redirect to https? Find these two ways:

RewriteCond %{HTTPS} !=on
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

o

RewriteCond  %{SERVER_PORT} ^80$
RewriteRule  ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

Which one would be correct?

Output of vc_link in Backend of wpBakery faulty

I have a strange display and I don’t know how to display it correctly.
When entering the link looks ok. But after saving it will be a long cryptic link.
In the frontend everything works and looks good.

Where is the mistake?

Backend Picture

Below is the code

function darkteaser_vc_map_init() {

$settings = array(
    'name'      => __( 'kleine Teaserbox mit Bild', 'js_composer' ),        // shortcode name
    'base'      => 'my_darkteaser_element',                         // shortcode base [my_darkteaser_element.php]
    'category'  => __( 'Meine Elemente', 'js_composer' ),   // param category tab in add elements view
    'icon'      => get_template_directory_uri() . '/image/darkteaser.png',   // Simply pass url to your icon here
    'description'   => __( 'kleine Teaserbox mit Bild und Text', 'js_composer' ),       // element description in add elements view

    'show_settings_on_create' => false,
    // don't show params window after adding
    'weight'                  => - 5,
    // Depends on ordering in list, Higher weight first
    
    'html_template'           => dirname( __FILE__ ) . '/vc_templates/my_darkteaser_element.php',
    // if you extend VC within your theme then you don't need this, VC will look for shortcode template in "wp-content/themes/your_theme/vc_templates/my_darkteaser_element.php" automatically. In this example we are extending VC from plugin, so we rewrite template

    'front_enqueue_css'       => preg_replace( '/s/', '%20', plugins_url( 'assets/front_enqueue_css.css', __FILE__ ) ),
    // This will load extra css file in frontend editor (when you edit page with VC)

    'params' => array(
        array(
            'type'          => 'attach_image',
            'class'         => 'teaserboxPicDunkel',
            'heading'       => __( 'Bild auswählen', 'js_composer' ),
            'param_name'    => 'bildteaser',
            'value'         => __(''),
            'description'   => 'Bild für Teaserbox hinzufügen.'
        ),
        array(
            'type'        => 'textarea_html',
            'holder'      => 'div',
            'class'       => 'teaserboxtextDunkel',
            'heading'     => __( 'Text eingeben', 'js_composer' ),
            'param_name'  => 'content', //param_name for textarea_html must be named "content"
            'value'       => __( '', 'js_composer' ),
            'description' => __( 'Text für Teaserbox.', 'js_composer' )
        ),
        array(
            'type'        => 'vc_link',
            'holder'      => 'div',
            'class'       => 'teaserboxbuttonDunkel',
            'heading'     => __( 'Link setzen', 'js_composer' ),
            'param_name'  => 'linkteaser',
            'value'       => __( '', 'js_composer' ),
            'description' => 'Link zur Seite'
        ),
    )
);
vc_map( $settings );

}
add_action(‘vc_after_init’, ‘darkteaser_vc_map_init’);

Add class dynamically from functions.php to div on singe product page – woocommerce

On a single product page (Woocommerce) a plugin in adding the following div structure:

<div class="variations-table">
<div class="variation">tennis</div>
</div>

I would like to add <?php $variations> (already defined) to the “variation” class so I can style these classes depending on the name of the variation.
So the result for a variation called “tennis” should be:

<div class="variations-table">
<div class="variation tennis">tennis</div>
</div>

How can I achieve this dynamically via my functions.php file, so I do not have to touch the plugin files?

Retrieve unmapped data from eventlistener in symfony form

I am currently creating a form that is supposed to retrieve the unmapped data to treat them before they are added to the database. How can I retrieve the unmapped data in the eventlistener?
Here is my formtype code :

    public function buildForm(FormBuilderInterface $builder, array $options): void
    {

        $builder
            ->add('currentState', ChoiceType::class, [
                'choices'  => [
                    'Disponible' => 1,
                    'Hors service' => 2,
                    'Réservé' => 3
                ],
            ])
            [...
            ->add('combination_reference', TextType::class, [
                'label'=>'Référence de la déclinaison',
                'mapped'=>false,
                'attr'=>[
                    'class'=>'form-control mb-2',
                    'placeholder'=>'Référence de la déclinaison'
                ]
            ])
            ->addEventListener(FormEvents::SUBMIT, function(FormEvent $formEvent){
                [retrieve unmapped data (combination_reference) here]
            })
        ;
     }
    public function configureOptions(OptionsResolver $resolver): void
    {

        $resolver->setDefaults([
            'data_class' => PhysicalProduct::class,
            "allow_extra_fields" => true
        ]);
    }




How to run one php ‘update’ script after another?

I have a simple php ‘update’ script that connects to an API, retrieves data and inserts it into a mysql table.

I need to be able to do this for several thousand products, one after the other each day.

I’ve been using JavaScript and ajax to call the php script and upon a successful response run the script for the next product in sequence.

It works but is there a better way to achieve this?