How To Change Color Data [closed]

can someone to help me?
In this cases I want to my display data row to be other color(RED Color) when the data in statuswo is “INSPECTION”
Please help me. in the below this is my code.

Before add this code:
Before add this code

THIS MY CODE

while($row=sqlsrv_fetch_array($query, SQLSRV_FETCH_ASSOC)){
    

When I add this code below

$style = "";                  
if ($row['statuswo'] = "INSPECTION"){
    $style = "style='background:#FF0000;'";
}
echo '<tr>
    <td>'.$row['NopolWo'].'</td>
    <td>'.$row['Tipe'].'</td>
    <td>'.$row['Penerima'].'</td>
    <td>'.$row['statuswo'].'</td>
    </tr>';

After add code:
After add code

So My data got change all to INSPECTION, please help.

How to execute the if statement correctly so that an error does not appear

I use Laravel and I have the following problem – when I execute the function, the following error “Call to a member function prepare() on null” appears, but I want this error not to appear, but to execute the function in the if statement. Here is part of the code

 public function saveWizard(Request $request, Redirector $redirect)
{

    $rules = config('installer.environment.form.rules');
    $messages = [
        'environment_custom.required_if' => trans('installer_messages.environment.wizard.form.name_required'),
    ];

    $validator = Validator::make($request->all(), $rules, $messages);

    if ($validator->fails()) {
        return $redirect->route('LaravelInstaller::environmentWizard')->withInput()->withErrors($validator->errors());
    }

    $check = $this->checkDatabaseConnection($request);

    if (!$check) {
        return $redirect->route('LaravelInstaller::environmentWizard')->withInput()->withErrors([
            'database_connection' => trans('installer_messages.environment.wizard.form.db_connection_failed'),
        ]);
    }

    $results = $this->EnvironmentManager->saveFileWizard($request);

    event(new EnvironmentSaved($request));

    return $redirect->route('LaravelInstaller::database')
                    ->with(['results' => $results]);
}

and checkDatabaseConnection function

private function checkDatabaseConnection(Request $request)
{
    $connection = $request->input('database_connection');

    $settings = config("database.connections.$connection");

    config([
        'database' => [
            'default' => $connection,
            'connections' => [
                $connection => array_merge($settings, [
                    'driver' => $connection,
                    'host' => $request->input('database_hostname'),
                    'port' => $request->input('database_port'),
                    'database' => $request->input('database_name'),
                    'username' => $request->input('database_username'),
                    'password' => $request->input('database_password'),
                ]),
            ],
        ],
    ]);

    DB::purge();

    try {
        DB::connection()->getPdo();

        return true;
    } catch (Exception $e) {
        return false;
    }
}

Payfast Payment Integration: Signature: Generated signature does not match submitted signature

I am creatin a payment integration uses payfast integration, but the problem now i am getting an error 404 bad request unable to process payment due to Signature: Generated signature does not match submitted signature. How do i fix this issue so it can meet payfast payment integration?

//payment_integration.php

<?php
session_start();
// PayFast Integration Logic

// Get the order details from the checkout process
//$orderID = $_POST['order_id'];
//$products = $_POST['products'];
//$grandTotal = $_POST['grand_total'];
$amount = $_POST['amount'] = 100;
//$signature = $_POST['signature'];
$allItems = $_SESSION['allItems'];
$grand_total = $_SESSION['grand_total'];
//$name = $_POST['name'];
//$email = $_POST['email'];
//$phone = $_POST['phone'];
//$address = $_POST['address'];

// Set your PayFast merchant details
$merchantID = ' 10196067'; // Replace with your actual merchant ID
$merchantKey = 'n3wqwtxa1irme'; // Replace with your actual merchant key

// Set the PayFast URL based on your environment (testing or production)
$isTestingMode = true; // Set to true for testing environment or false for production environment
$payfastURL = $isTestingMode ? 'https://sandbox.payfast.co.za/eng/process' : 'https://www.payfast.co.za/eng/process';

// Function to generate the signature
function generateSignature($data, $passphrase = null)
{
    $pfOutput = '';
    foreach ($data as $key => $value) {
        if ($value !== '') {
            $pfOutput .= $key . '=' . urlencode(trim($value)) . '&';
        }
    }
    $pfOutput = substr($pfOutput, 0, -1); // Remove the trailing '&'

    if ($passphrase !== null) {
        $pfOutput .= '&passphrase=' . urlencode(trim($passphrase));
    }

    $signature = md5($pfOutput);

    return $signature;
}


$merchantID = '10010868'; // Replace with your actual merchant ID
$merchantKey = 'exnibu0q9zmuz'; // Replace with your actual merchant key
$passphrase = 'jt7NOE43FZPn'; // Replace with your actual passphrase (if applicable)

$data = array(
    'merchant_id' => $merchantID,
    'merchant_key' => $merchantKey,
    'return_url' => 'http://localhost/payment_success.php',
    'cancel_url' => 'http://localhost/payment_cancel.php',
    'notify_url' => 'http://localhost/payment_notify.php',
    'amount' => $amount,
    'item_name' => 'Cell Phone',
    'item_description' => 'Electronics',
    'email_address' => '[email protected]',
    'name_first' => 'John',
    'name_last' => 'Doe',
);


// Generate the signature
$signature = generateSignature($data, $passphrase);

// Add the signature to the payment data
$data['signature'] = $signature;

// If in testing mode, use the sandbox URL, otherwise use the production URL
$testingMode = true;
$pfHost = $testingMode ? 'sandbox.payfast.co.za' : 'www.payfast.co.za';

// Create the HTML form
$htmlForm = '<div class="container">
    <div class="card">
        <div class="card-body text-center">
            <form action="https://' . $pfHost . '/eng/process" method="post">
                <div class="row justify-content-center">
                    <div class="col-md-6">
                        <div class="mb-3">';
foreach ($data as $name => $value) {
    $htmlForm .= '<input name="' . $name . '" type="hidden" value='' . $value . '' />';
}
$htmlForm .= '<button type="submit" class="btn btn-primary">Pay Now</button></div></div></div></form>
        </div>
    </div>
</div>';

echo $htmlForm;



?>

Only NUll value getting from middleware Laravel

When I tried to get value from middleware to construct of controller it is getting Null

My Controller Code

$this->middleware(function ($request, $next) {
            $moduleCode = "property_module";
            $middleware = app()->make(PermissionAndRoleCheck::class, ['moduleCode' => $moduleCode]);
            $this->userModulePermissions = $request->attributes->get('userModulePermissions');
            dd($this->userModulePermissions);
            return $next($request);
        });

My Middleware

public function handle(Request $request, Closure $next)
    {
        $moduleCode = "property_module";
        $role = Auth::user()->user_type;
        $propertyModuleId ="6ca38e62-6c50-438d-bdcd-0db8f563ac4c";
        $roleId = "b9e57901-8077-4962-aad9-3329d8e02323";
        $module = Module::where('module_code', $moduleCode)->first();
        $userModulePermissions = Permission::where('role_id', $roleId)
            ->where('module_id', $propertyModuleId)
            ->first();

        if (!$userModulePermissions) {
            return response()->json(['message' => 'No Data here.'], 403);
        }

        app()->instance('userModulePermissions', $userModulePermissions);

        return $next($request);
    }

When I directly put query in controller I am getting values

id role_id module_id permissions
40469677-0331-4717-814b-7102f4b37d35 beb60b0e-bed4-4a77-9901-47113bbcba67 6ca38e62-6c50-438d-bdcd-0db8f563ac4c add,edit,view

When Write query in controller I am getting results, When I tried the same in Middleware not getting values

How to replace the value of a string within two characters in php

Good morning everyone,
I need to figure out if there is a way to change the values inside the * *.

Example:

Hello everyone, this is my 1st post.
*photo1*
*photo2*
*photo3*
See you soon...

and replace the code with:

Hello everyone, this is my 1st post.
*photo*
*photo*
*photo*
See you soon...

without number after the word photo

How it works currently:

I have a txt file that contains the words photo1, photo2, photo3 between asterisks. This file is read via the file_get_contents command and I would need to remove the number at the end of the word photo.

Depedency tree of php composer

Given a composer.json file, can you create a dependency tree while dry-running the installation?

According to the composer docs, the composer show --tree command only works for installed packages, is there a simple way to make it run with a dry-run installation?

Is there a different tool, other than composer, which can statically analyze the dependency tree of a composer.json?

Videos are loading slowly to the player when it is uploaded with Tus-php

I have used tus.js client and tus-php to upload videos to my server. But after uploading the files when I try to stream it on the player it is waiting the whole video to load to start playing.

This is my client

 const input = document.querySelector(".videoUploadInput");
        input.addEventListener('change', function(e) {
            // Get the selected file from the input element
            var file = e.target.files[0]
            const extension = file.name.split('.').pop();
            const uniqueId = Date.now().toString(36);
            const tempFileName = `${uniqueId}_${Date.now()}.${extension}`;
            // Create a new tus upload
            var upload = new tus.Upload(file, {
                headers: {
                    'X-CSRF-TOKEN': "{{ csrf_token() }}", // Include the CSRF token in the headers
                },
                // Endpoint is the upload creation URL from your tus server
                endpoint: '/tus',
                // Retry delays will enable tus-js-client to automatically retry on errors
                retryDelays: [0, 3000, 5000, 10000, 20000],
                // Attach additional meta data about the file for the server
                metadata: {
                    filename: tempFileName,
                    filetype: file.type,
                },
                // Callback for errors which cannot be fixed using retries
                onError: function(error) {
                    console.log('Failed because: ' + error)
                },
                // Callback for reporting upload progress
                onProgress: function(bytesUploaded, bytesTotal) {
                    var percentage = ((bytesUploaded / bytesTotal) * 100).toFixed(2)
                    console.log(bytesUploaded, bytesTotal, percentage + '%')

                    $('.progress-bar').css('width', percentage + '%').text(percentage + '%');

                },
                // Callback for once the upload is completed
                onSuccess: function() {
                    console.log("UPLOAD", upload);
                    $('.VideoInputFile').val('/storage/videos/' + tempFileName);
                    // console.log('Download %s from %s', upload.file.name, upload.url)
                    $('.submitButton').attr('disabled', false);
                },
            })

            // Check if there are any previous uploads to continue.
            upload.findPreviousUploads().then(function(previousUploads) {
                // Found previous uploads so we select the first one.
                if (previousUploads.length) {
                    upload.resumeFromPreviousUpload(previousUploads[0])
                }

                // Start the upload
                upload.start()
            })
        })

This is my backend service provider

<?php

namespace AppProviders;

use IlluminateSupportServiceProvider;
use TusPhpTusServer as TusServer;

class TusServiceProvider extends ServiceProvider
{
    /**
     * Register services.
     *
     * @return void
     */
    public function register()
    {



        $this->app->singleton('tus-server', function ($app) {
            $server = new TusServer();

            $server->setApiPath('/tus');
            $server->setUploadDir(public_path('storage/videos'));

            return $server;
        });
    }

    /**
     * Bootstrap services.
     *
     * @return void
     */
    public function boot()
    {
        //
    }
}

I am sending video chunks to my route and my route initiates the provider and it combines the video chunks. But after it combines the video to a single file I am waiting the whole video to load to stream

Laravel class based components class being ignored

I have laravel component created in nested folders in app/view/components/modules/Exchange/common

and i use this component like this in the code:

<x-modules.Exchange.common.text-input placeholder="{{ __('Email') }}"
                                label="{{ __('Email') }}" icon="ni ni-envelope" id="email_input"
                                name="account_email" />

the problem is that component class that has constructor and default values are being ignored completely

and Laravel renders the blade.php associated with that component directly.

And of course no default values are being passed to blade, that’s why I get this error:

Error ! with http_status: 500
Undefined variable $type (View: /var/www/html/laravel/resources/views/components/modules/Exchange/common/text-input.blade.php) (View: /var/www/html/laravel/resources/views/components/modules/Exchange/common/text-input.blade.php)

In my development environment (Window) it works without any errors and the class constructor is invoked, however, when I deployed to ECS Linux I got that error.

that error occurs in all of my components.

I tried composer dum-autoload, php artisan view:clear, php artisan cache:clear, php artisan config:clear and I tried to register the component.

Can anyone help with this issue please?
I’m using on Linux

Laravel 9.41.0
PHP 8.1.2

Thanks in advance.

Edit: All of my classes comply for PSR-4

bagaimana membuat halaman login dengan kode unik bisa terindex? [closed]

bagaimana membuat halaman login dengan kode unik bisa terindex?

Bagaimana caranya membuat halaman login tersimpan dan dapat di crawl oleh google seperti contoh berikut!

https://www.google.com/search?q=site%3Ahttps%3A%2F%2Fstackoverflow.com%2Fusers%2Fsignup%3Fssrc%3Danon_ask%26returnurl%3Dhttps%253a%252f%252fstackoverflow.com%252fquestions%252fask&rlz=1C1GCEA_enRO1019KH1027&oq=site%3Ahttps%3A%2F%2Fstackoverflow.com%2Fusers%2Fsignup%3Fssrc%3Danon_ask%26returnurl%3Dhttps%253a%252f%252fstackoverflow.com%252fquestions%252fask&aqs=chrome..69i57j69i58.1360j0j4&sourceid=chrome&ie=UTF-8

contoh gambar

saya pemula dan belum pernah mencoba,
mohon berikan petunjuknya
apakah url unik tersebut bisa dibuat sendiri dan dikirimkan keserver hosting?

“Error: Undefined constant” after upgrading to PHP 8?

I’m getting this PHP error after upgrading to PHP 8:

Error: Undefined constant "Api​" in /home/xxxxxx/public_html/api-res/data.php:74

And the 74 line of data.php is this:

if ($State -> dbStruct && isset(Api_Db::$list[$State -> db])) {

$State -> dbStruct is a non-empty array, Api_Db::$list is a static array of class Api_Db, and $State -> db is a plain string of db name.

Tried to use absolute namespace ApiApi_Db but it didn’t work.

What’s wrong here? It’s really a weird error?

======

When I switch back to PHP 7.2, it gives this error instead:

ErrorException: Use of undefined constant ​ - assumed '​' (this will throw an Error in a future version of PHP) in /home/datacty/public_html/api-res/data.php:74

What does this mean? There’s no constant in that line.

How can I pass npm install && npm run dev in Lavavel?

Just now I try to pass npm install & npm run dev, every time I happen error in command.
Then I did these process in my command ever.

1.composer require laravel/ui “^2.0”

2.php artisan ui vue –auth

3.npm install

4.npm run dev

I can pass command till 2.
Error happen 3,4 in process.
Like this
npm ERR! code FETCH_ERROR
npm ERR! errno FETCH_ERROR
npm ERR! invalid json response body at https://registry.npmjs.org/@popperjs%2fcore reason: Invalid response body while trying to fetch https://registry.npmjs.org/@popperjs%2fcore: EACCES: permission denied, link ‘/Users/–/.npm/_cacache/tmp/fbd35d79’ -> ‘/Users/–/.npm/_cacache/content-v2/sha512/6d/0f/b6771994954828c596048ebeb4382c9b4197afdf11e4753b4305236b7c2d9c90e5229dd60f33a8aafb13b3a63f7a0036850b230cb3837322870ed4af555c’
What point should I fix in command?

Please give me advice.

I try to this command.

1.sudo npm update npm -g

2.npm update

Finally it happened error.

Get Paypal Subscription status per cronjob problem

I have successfully set up paypal subscriptions, they work via sandbox without problems.
However, I want to query daily the status of customers ( ACTIVE, SUSPENDED, CANCELLED, EXPIRED …), but found no complete and understandable documentation for Paypal webhooks and unfortunately did not get it implemented.
I found this tutorial and implemented successfully: https://www.stacklounge.de/6328/tutorial-integrate-paypal-subscription-javascript-complete.
With this I can now check the status via cronjob regularly, it works fine.

My question, does anyone know how I can use this to get back not only the status but possibly more data, for example the custom_id and the total?

(If someone knows a good paypal documentation for webhooks, I’ll gladly take it. I know the outdated SDK and Paypal’s own, they are unfortunately incomplete …).

Thanks a lot!

how to integrate NMI payment gateway with Omnipay?

Omnipay is a popular payment library in Laravel that provides a unified API for interacting with various payment gateways. how to integrate the NMI payment gateway using the OmniPay Laravel package in Laravel. Please give some references or steps to follow.

What causes this 500 error while trying to load comments via AJAX in a Laravel 8 application?

I have made a blogging application in Laravel 8.

On the single article view, I am displaying comments and comment replies.

There is an option to load comments via AJAX, on page scroll.

When the “infinite scroll” option is checked, the first 10 comments are present on page load, the rest are loaded via AJAX.

enter image description here

In ArticlesController.php I have:

class ArticlesController extends FrontendController {

  public function show( $slug ) {
    // Single article
    $article     = Article::firstWhere( 'slug', $slug );
    $old_article = Article::where( 'id', '<', $article->id )->orderBy( 'id', 'DESC' )->first();
    $new_article = Article::where( 'id', '>', $article->id )->orderBy( 'id', 'ASC' )->first();

    // Comments
    $commentsQuery  = $this->get_commentQuery( $article->id );
    $comments_count = $commentsQuery->count();

    // If infinite scroll, paginate comments (to be loaded one page per scroll),
    // Else show them all 

    if (boolval($this->is_infinitescroll)) {
      $comments = $commentsQuery->paginate($this->comments_per_page);
    } else {
      $comments = $commentsQuery->get();
    }

    return view( 'themes/' . $this->theme_directory . '/templates/single',
                 array_merge( $this->data, [
                   'categories'        => $this->article_categories,
                   'article'           => $article,
                   'old_article'       => $old_article,
                   'new_article'       => $new_article,
                   'comments'          => $comments,
                   'comments_count'    => $comments_count,
                   'comments_per_page' => $this->comments_per_page,
                   'tagline'           => $article->title,
                   'is_infinitescroll' => $this->is_infinitescroll
                 ] )
    );
  }

  /**
   * AJAX Call for Loading extra comments
   *
   * @param Request $request
   *
   * @return void
   */
  public function get_comments_ajax( Request $request ) {
    if ( ! $request->ajax() ) {
      exit();
    }

    $more_comments_to_display = TRUE;

    $article_id  = $request->post( 'article_id' );
    $page_number = $request->post( 'page' );
    $offset      = $this->comments_per_page * $page_number;

    $data['comments'] = $this->get_commentQuery( $article_id, $this->comments_per_page, $offset )->get();
    $content          = '';
    if ( $data['comments']->count() ) {
      $content .= view('themes/' . $this->theme_directory . '/partials/comments-list',
                array_merge( $data, [
                  'is_infinitescroll' => $this->is_infinitescroll
                ])
      );
    } else {
      $more_comments_to_display = FALSE;
    }
    echo json_encode( [ 'html' => $content, 'page' => $page_number, 'more_comments_to_display' => $more_comments_to_display, 'article_id' => $article_id ] );
    exit();
  }

  /**
   * get_commentQuery
   *
   * @param int $article_id
   * @param int $limit
   * @param int $offset
   *
   * @return object
   */
  private function get_commentQuery( int $article_id, int $limit = 0, int $offset = 0 ): object {
    $commentQuery = Comment::where( [ 'article_id' => $article_id, 'approved' => 1 ] )
        ->orderBy( 'id', $this->comments_orderby_direction )
        ->with('replies', function($query){
             $query->where('approved', 1);
        });

    if ( $offset > 0 ) {
      $commentQuery = $commentQuery->offset( $offset );
    }
    if ( $limit > 0 ) {
      $commentQuery = $commentQuery->limit( $limit );
    }

    return $commentQuery;
  }
}

In infinite-comments.js I have:

/* Infinite comments
* ------------------------------------------------------ */
$(document).ready(function () {

    let flagMoreCommentsToDisplay = true;
    let flagCommentsBlockNewRequest = false;
    let domInfiniteScroll = $(".infinite-scroll");

    infiniteComments();

    function infiniteComments() {
        let page = 0;
        $(window).scroll(function () {
            if (flagCommentsBlockNewRequest === false) {
                if ($(window).scrollTop() + $(window).height() >= $(document).height() - $('.s-footer').height()) {
                    if (flagMoreCommentsToDisplay) {
                        flagCommentsBlockNewRequest = true;
                        page++;
                        loadMoreData(page);
                    }
                }
            }
        });
    }

    function loadMoreData(page) {
        let base_url = window.location.origin
        $.ajax({
            url: base_url + '/load_comments',
            type: 'POST', dataType: 'json',
            data: {'_token': token, 'page': page, 'article_id': article_id},
            beforeSend: function () {
                $('.ajax-load').show();
            }
        })
        .done(function (data) {
            $('.ajax-load').hide();
            let commentHtml = data.html;
            flagMoreCommentsToDisplay = data.more_comments_to_display;
            if (flagMoreCommentsToDisplay) {
                if (commentHtml !== '') {
                    domInfiniteScroll.append(commentHtml);
                }
            }
            flagCommentsBlockNewRequest = false;
        })
        .fail(function () {
            flagCommentsBlockNewRequest = false;
        });
    }
});

In the blade file that displays the comments – comments-list.blade.php:

@foreach ($comments as $comment)
    @if (null == $comment->parent_id)
        <li class="depth-1 comment">
            <div class="comment__avatar">
              <img class="avatar" src="{{ asset('images/avatars/' . $comment->user->avatar) }}" alt="{{ $comment->user->first_name }} {{ $comment->user->last_name }}" width="50" height="50">
            </div>
            <div class="comment__content">
                <div class="comment__info">
                    <div class="comment__author">{{ $comment->user->first_name }} {{ $comment->user->last_name }}</div>
                    <div class="comment__meta">
                        <div class="comment__time">{{ date('jS M Y', strtotime($comment->created_at)) }}</div>
                        @auth
                          <div class="comment__reply">
                              <a class="comment-reply-link" href="#0">Reply</a>
                          </div>
                        @endauth
                    </div>
                </div>
                <div class="comment__text">
                    <p>{{ $comment->body }}</p>
                </div>
            </div>

            @auth
                @include('themes/' . $theme_directory . '/partials/comment-form')
            @endauth

            {{-- Comment replies --}}
            @if (count($comment->replies))
                <ul class="children">
                    @foreach ($comment->replies as $reply)
                        <li class="depth-2 comment">
                            <div class="comment__avatar">
                                <img class="avatar" src="{{ asset('images/avatars/' . $reply->user->avatar) }}"
                                    alt="{{ $comment->user->first_name }} {{ $comment->user->last_name }}"
                                    width="50" height="50">
                            </div>
                            <div class="comment__content">
                                <div class="comment__info">
                                    <div class="comment__author">{{ $reply->user->first_name }}
                                        {{ $reply->user->last_name }}</div>
                                    <div class="comment__meta">
                                        <div class="comment__time">{{ date('jS M Y', strtotime($reply->created_at)) }}
                                        </div>
                                    </div>
                                </div>
                                <div class="comment__text">
                                    <p>{{ $reply->body }}</p>
                                </div>
                            </div>
                        </li>
                    @endforeach
                </ul>
            @endif
        </li>
    @endif
@endforeach

The problem

On page scroll, loading more comments fails with a 500 error:

POST https://larablog.com/load_comments 500 (Internal Server Error)

Questions

  1. What is my mistake?
  2. What is the most reliable way to fix this issue?