Laravel9: route parameter always missing in validation

I am using Laravel v9.2.1

I got a route

DELETE /api/v1/auth/tokens/{token}

for example (the token is an uuid)

DELETE http://example.com/api/v1/auth/tokens/5fcfa274-81d8-4e9f-8feb-207db77531af

And I am sure it works as expected via php artisan route:list
enter image description here

Before handling by the Controller, it should be validated by a FormRequest

app/Http/Controllers/V1/Auth/TokensController.php

namespace AppHttpControllersV1Auth;

use AppHttpRequestsV1AuthTokens{
    DestroyRequest,
};

class TokensController extends Controller
{
    public function destroy(DestroyRequest $request) {
        $request->user()->tokens()->where('id', $request->token)->first()->delete();
        return response()->noContent();
    }
}

app/Http/Requests/V1/Auth/Tokens/DestroyRequest.php

class DestroyRequest extends FormRequest
{
    public function rules()
    {
        return [
            'token' => [
                'required',
                'string',
                'regex:/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i', 
                Rule::exists('personal_access_tokens')->where(function ($query) {
                    return $query->where('tokenable_id', $this->user()->id);
                }),                         
            ]
        ];
    }
}

But what I only got is The token field is required

I had already pass the token, why the 'required' rule still working?

enter image description here


What I tried

Only if I pass the token parameter like below, it will work

DELETE /api/auth/tokens/something?token=test_regex_is_working

enter image description here

I try to dd($this->token) in app/Http/Requests/V1/Auth/Tokens/DestroyRequest.php, it works as expected.

enter image description here

How do I hide a section of a collapsible FAQ if the data is empty?

I have a collapsible FAQ section that sits on each members profile page. I’d like to hide the question and answer if the data field is empty.

    <div class="row">
        <div class="col-md-10">
            <div class="panel panel-default1">>
                <div class="panel-heading">
                    <h3 class="panel-title"><b>Who is the registered manager of <?php echo $user['full_name']?>?</b></h3>
                    <span class="pull-right clickable"><i class="glyphicon glyphicon-chevron-up"></i></span>
                </div>
                <div class="panel-body">
                                      <?php echo $user['registered_manager']?> is the registered manager of <?php echo $user['full_name']?>.
                </div>
                 </div>  </div>
                
           <div class="col-md-10">
            <div class="panel panel-default2">
                <div class="panel-heading">
                    <h3 class="panel-title"><b>How many beds are there at <?php echo $user['full_name']?>?</b></h3>
                    <span class="pull-right clickable"><i class="glyphicon glyphicon-chevron-up"></i></span>
                </div>
                <div class="panel-body">
                There are <?php echo $user['number_of_beds']?> beds in total at <?php echo $user['full_name']?>.</div>
                </div> </div>
               
                 <div class="col-md-10">
            <div class="panel panel-default3">
                <div class="panel-heading">
                    <h3 class="panel-title"><b>Who owns <?php echo $user['full_name']?>?</b></h3>
                    <span class="pull-right clickable"><i class="glyphicon glyphicon-chevron-up"></i></span>
                </div>
                <div class="panel-body">
                <?php echo $user['full_name']?> is owned and operated by <?php echo $user['group_name']?>.</div>
                </div> </div>
                   
 
  </div>
  </div>
<script type="text/javascript">
    jQuery(function ($) {
        $('.panel-heading span.clickable').on("click", function (e) {
            if ($(this).hasClass('panel-collapsed')) {
                // expand the panel
                $(this).parents('.panel').find('.panel-body').slideDown();
                $(this).removeClass('panel-collapsed');
                $(this).find('i').removeClass('glyphicon-chevron-down').addClass('glyphicon-chevron-up');
            }
            else {
                // collapse the panel
                $(this).parents('.panel').find('.panel-body').slideUp();
                $(this).addClass('panel-collapsed');
                $(this).find('i').removeClass('glyphicon-chevron-up').addClass('glyphicon-chevron-down');
            }
        });
    });
</script>
.panel-heading span
    {
        margin-top: -20px;
        font-size: 15px;
    
    }

    .row
    {
        margin-top: 40px;
        padding: 0 20px;
    
    }

    .clickable
    {
        cursor: pointer;
    }

The $user['full_name'] will always be populated so I don’t need to worry about that. In question one the field that needs to not be blank is $user['registered_manager']

Question 2 is $user['number_of_beds'] and Question 3 is “`<?php echo $user[‘group_name’]

thanks in advance

301 Re direct loop on Apache server

Can someone please explain why this simple 301 REDIRECT is creating a loop of the final directory name.

I’ve just finished altering a website where some url’s have changed slightly.
So I’ve created 301 redirects to the contents new location.

I am using a caching plugin and WordPress. I have re-cached the site and cleared all the cache in my browser too, but I’m still getting the same error on one domain url, which I’ve confirmed is a problem using;

https://wheregoes.com

At the bottom of my .htaccess file (below) you will see my Custom 301 redirects to all the newly formatted content.

All are working fine except;

Redirect 301 /tonbridge /tonbridge/nursery

For some reason this is creating a loop where the url spits out;

https://www.juniorsdaynursery.co.uk/tonbridge/nursery/nursery/nursery/nursery/nursery/nursery/nursery/nursery/

recurring until it crashes due to too many re-directs.

If I remove this specific 301 Redirect everything works perfectly, but then I don’t have a redirection in place for previous visitors who have the old url;

https://www.juniorsdaynursery/tonbridge

and then of course the 404 page gets returned.

Any ideas why this 301 wouldn’t work as expected?

# BEGIN WpFastestCache
# Modified Time: 19-07-22 19:37:14
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} =on
RewriteCond %{HTTP_HOST} ^www.juniorsdaynursery.co.uk
# Start WPFC Exclude
# End WPFC Exclude
# Start_WPFC_Exclude_Admin_Cookie
RewriteCond %{HTTP:Cookie} !wordpress_logged_in_[^=]+=DanGoldsmith|TanyaGoldsmith
# End_WPFC_Exclude_Admin_Cookie
RewriteCond %{HTTP_HOST} ^www.juniorsdaynursery.co.uk
RewriteCond %{HTTP_USER_AGENT} !(facebookexternalhit|WP_FASTEST_CACHE_CSS_VALIDATOR|Twitterbot|LinkedInBot|WhatsApp|Mediatoolkitbot)
RewriteCond %{HTTP_USER_AGENT} !(WPsFastestsCachesPreload(siPhonesMobile)?s*Bot)
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{REQUEST_URI} !(/){2}$
RewriteCond %{REQUEST_URI} /$
RewriteCond %{QUERY_STRING} !.+
RewriteCond %{HTTP:Cookie} !wordpress_logged_in
RewriteCond %{HTTP:Cookie} !comment_author_
RewriteCond %{HTTP:Cookie} !safirmobilswitcher=mobil
RewriteCond %{HTTP:Profile} !^[a-z0-9"]+ [NC]
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/all/$1/index.html -f [or]
RewriteCond /home/cf3cclcs/juniorsdaynursery.co.uk/wp-content/cache/all/$1/index.html -f
RewriteRule ^(.*) "/wp-content/cache/all/$1/index.html" [L]
</IfModule>
<FilesMatch "index.(html|htm)$">
AddDefaultCharset UTF-8
<ifModule mod_headers.c>
FileETag None
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Mon, 29 Oct 1923 20:30:00 GMT"
</ifModule>
</FilesMatch>
# END WpFastestCache
# BEGIN GzipWpFastestCache
<IfModule mod_deflate.c>
AddType x-font/woff .woff
AddType x-font/ttf .ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE x-font/ttf
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE font/opentype font/ttf font/eot font/otf
</IfModule>
# END GzipWpFastestCache
# BEGIN LBCWpFastestCache
<FilesMatch ".(webm|ogg|mp4|ico|pdf|flv|avif|jpg|jpeg|png|gif|webp|js|css|swf|x-html|css|xml|js|woff|woff2|otf|ttf|svg|eot)(.gz)?$">
<IfModule mod_expires.c>
AddType application/font-woff2 .woff2
AddType application/x-font-opentype .otf
ExpiresActive On
ExpiresDefault A0
ExpiresByType video/webm A10368000
ExpiresByType video/ogg A10368000
ExpiresByType video/mp4 A10368000
ExpiresByType image/avif A10368000
ExpiresByType image/webp A10368000
ExpiresByType image/gif A10368000
ExpiresByType image/png A10368000
ExpiresByType image/jpg A10368000
ExpiresByType image/jpeg A10368000
ExpiresByType image/ico A10368000
ExpiresByType image/svg+xml A10368000
ExpiresByType text/css A10368000
ExpiresByType text/javascript A10368000
ExpiresByType application/javascript A10368000
ExpiresByType application/x-javascript A10368000
ExpiresByType application/font-woff2 A10368000
ExpiresByType application/x-font-opentype A10368000
ExpiresByType application/x-font-truetype A10368000
</IfModule>
<IfModule mod_headers.c>
Header set Expires "max-age=A10368000, public"
Header unset ETag
Header set Connection keep-alive
FileETag None
</IfModule>
</FilesMatch>
# END LBCWpFastestCache
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

# Custom Redirects
Redirect 301 /tonbridge /tonbridge/nursery
Redirect 301 /tonbridge-teenies /tonbridge/teenies
Redirect 301 /tonbridge-toddlers /tonbridge/toddlers
Redirect 301 /tonbridge-preschool /tonbridge/preschool
Redirect 301 /tonbridge-pricing /tonbridge/pricing
Redirect 301 /tonbridge-gallery /tonbridge/gallery
Redirect 301 /tonbridge-policies /tonbridge/policies
Redirect 301 /cranbrook-teenies /cranbrook/teenies
Redirect 301 /cranbrook-toddlers /cranbrook/toddlers
Redirect 301 /cranbrook-preschool /cranbrook/preschool
Redirect 301 /cranbrook-pricing /cranbrook/pricing
Redirect 301 /cranbrook-gallery /cranbrook/gallery
Redirect 301 /cranbrook-policies /cranbrook/policies
Redirect 301 /tunbridge-wells-teenies /tunbridge-wells/teenies
Redirect 301 /tunbridge-wells-toddlers /tunbridge-wells/toddlers
Redirect 301 /tunbridge-wells-preschool /tunbridge-wells/preschool
Redirect 301 /tunbridge-wells-pricing /tunbridge-wells/pricing
Redirect 301 /tunbridge-wells-gallery /tunbridge-wells/gallery
Redirect 301 /tunbridge-wells-policies /tunbridge-wells/policies
Redirect 301 /boughton-monchelsea-teenies /boughton-monchelsea/teenies
Redirect 301 /boughton-monchelsea-toddlers /boughton-monchelsea/toddlers
Redirect 301 /boughton-monchelsea-preschool /boughton-monchelsea/preschool
Redirect 301 /boughton-monchelsea-pricing /boughton-monchelsea/pricing
Redirect 301 /boughton-monchelsea-gallery /boughton-monchelsea/gallery
Redirect 301 /boughton-monchelsea-policies /boughton-monchelsea/policies
Redirect 301 /headcorn /boughton-monchelsea/nursery
Redirect 301 /headcorn-teenies /boughton-monchelsea/teenies
Redirect 301 /headcorn-toddlers /boughton-monchelsea/toddlers
Redirect 301 /headcorn-preschool /boughton-monchelsea/preschool
Redirect 301 /headcorn-pricing /boughton-monchelsea/pricing
Redirect 301 /headcorn-gallery /boughton-monchelsea/gallery
Redirect 301 /headcorn-policies /boughton-monchelsea/policies

Codeigniter – Message: Undefined property: CI_Loader::$uri

I’m using my project on localhost and I don’t get any errors. But after uploading it to the server, I get an error like this. No matter how much I searched, I couldn’t find the solution. Can you help with this?

Severity: Warning

Message: Undefined property: CI_Loader::$uri

Filename: home/header.php

Line Number: 51

Backtrace:

File: /home/sehadetm/public_html/test/application/views/home/header.php
Line: 51
Function: _error_handler

File: /home/sehadetm/public_html/test/application/views/home/anasayfa.php
Line: 1
Function: view

File: /home/sehadetm/public_html/test/application/controllers/Anasayfa.php
Line: 13
Function: view

File: /home/sehadetm/public_html/test/index.php
Line: 315
Function: require_once

header.php Line Number:51

<li class="nav-item">
   <a class="nav-link <?= $this->uri->segment(1) == "" ? "active" : ""  ?>" href="<?= base_url("") ?>"> Anasayfa </a>
</li>

autoload.php

$autoload['helper'] = array('url', 'file','function');

Strange type of file appli

I created a script to upload files on the server and store the filetype and filename on mysql database.

When i try to upload file via php script it works with image files.
In mysql database some files are not correctly stored and in the filetype, it save a strange filetype

appli

I tried to search on the web but i cannot find this kind of filetype.

How to execute a function as well as a submit form in javascript [duplicate]

I have a javascript function which saves a canvas image as png on the server, as well as a form.

$(document).ready(function() {
    
    var lc = LC.init(document.getElementsByClassName('my-drawing')[0]);
    $('#submit_all').click(function(e) {
        e.preventDefault();
        
     var image = lc.getImage().toDataURL();
     
    $.ajax({
        type: "POST",
        url: "plugins/measurements/add.php",
        data: {
          image: image,
          uid: <?php echo $uid; ?>
        }
      });
    });
    });

The problem is when I use the e.preventDefault() function the image gets saved but the form is not submitted and when I remove it the opposite happens.
Any help on how to solve this would be greatly appreciated.

Generate quey on doctrine querybuilder

I have three entities Compound, ComponentQuantity, and Component the Compound has a ManyToMany relationship with ComponentQuantity and ComponentQuantity has a ManyToMany relationship with Component.

I need to get the Compound‘s which ComponentQuantity are related with a Component,

If I would need the component quantity I would use:

$qb = $this->createQueryBuilder("c")
            ->where(':componentQuantity MEMBER OF c.componentQuantities')
            ->setParameters(array('componentQuantity' => $componentQuantity));

but I need something like

$qb = $this->createQueryBuilder("c")
            ->where(':component MEMBER OF c.componentQuantities.components')
            ->setParameters(array('component' => $component));

but this not work.

Adding a dropdown menu in Prestashop 1.7 module

I’m so beginner in Prestashop 1.7, I wanted to add a dropdown select section in my banner module to select the way to open the banner link.

but the selected value is never passed to the HTML, the code below IS passed but the one under isn’t, can you please assist me?
[enter image description here][1]

array(
                        'type' => 'text',
                        'lang' => true,
                        'label' => $this->trans('Banner description', array(), 'Modules.Banner.Admin'),
                        'name' => 'BANNER_DESC',
                        'desc' => $this->trans('Please enter a short but meaningful description for the banner.', array(), 'Modules.Banner.Admin')
                    )
array(
                        'type' => 'select', //select
                        'lang' => true,
                        'label' => $this->trans('Banner tab', array(), 'Modules.Banner.Admin'),
                        'name' => 'BANNER_TAB',
                        'required'=>'true',
                        'options' => array(
                            'query' => array(
                                array('key' => '_blank', 'name' => 'New tab'),
                                array('key' => '_self', 'name' => 'Same tab'),
                            ),
                            'id' => 'key',
                            'name' => 'name'
                        ),
                        
                        'desc' => $this->trans('Please select the way to open the link.', array(), 'Modules.Banner.Admin')
                    )

This is how it looks in the Backoffice:
Here

How to Apply CSS based on variable

we have created a table (6×2) with column 2 containing a FA circle followed by a database field (environment in the example below) which contains the value (Outstanding, Very Good, Good, Needs Improvement & Adequate).

I need to be able to change the colour of the fa-circle (traffic light colours) depending on the value of field that is in that line.

How best to achieve this please?

</h2>

<table class="tableag" style="width: 80%;">
    <tbody>
        
        <tr>
            <td style="width: 40.0000%;background-color: #ffffff;color: #f2a34f;border-top: 3px solid #ffffff;
  border-left: 3px solid #ffffff;"><b>Category</b></td>
            <td style="width: 60.0000%;background-color: #ffffff;color: #f2a34f;border-top: 3px solid #ffffff;
  border-left: 3px solid #ffffff;"><b>Rating</b></td>
        </tr>
        <tr>
            <td style="width: 40.0000%;">Overall<br></td>
            <td style="width: 60.0000%;background-color: #ffffff;color: #000000; class = "outcome"; "><i class="fa fa-circle" aria-hidden="true"></i>  &nbsp;<br><?php echo $user['rating']?></td>
        </tr>
        <tr>
            <td style="width: 40.0000%;">Care &amp; Support<br></td>
            <td style="width: 60.0000%;background-color: #ffffff;color: #000000;class = "outcome";"> <i class="fa fa-circle" aria-hidden="true"></i>  &nbsp;<br><?php echo $user['care_and_support']?></td>
        </tr>
        <tr>
            <td style="width: 40.0000%;">Environment<br></td>
            <td style="width: 60.0000%;background-color: #ffffff;color: #000000;class = "outcome";"><i class="fa fa-circle" aria-hidden="true"></i>  &nbsp;<br><?php echo $user['environment']?></td>
        </tr>
        <tr>
            <td style="width: 40.0000%;">Leadership<br></td>
            <td style="width: 60.0000%;background-color: #ffffff;color: #000000;class = "outcome";"><i class="fa fa-circle" aria-hidden="true"></i>  &nbsp;<br><?php echo $user['leadership']?></td>
        </tr>
        <tr>
            <td style="width: 40.0000%;">Staff &amp; team</td>
            <td style="width: 60.0000%;background-color: #ffffff;color: #000000;class = "outcome";"><i class="fa fa-circle" aria-hidden="true"></i>  &nbsp;<br><?php echo $user['staff_team']?></td>
        </tr>
        <tr>
            <td style="width: 40.0000%;">Wellbeing<br></td>
            <td style="width: 60.0000%;background-color: #ffffff;color: #000000;class = "outcome";"><i class="fa fa-circle" aria-hidden="true"></i>  &nbsp;<br><?php echo $user['wellbeing']?></td>
        </tr>
        <tr>
            <td style="width: 40.0000%;">Full report<br></td>
            <td style="width: 60.0000%;background-color: #ffffff;color: #000000;"><a class="btn btn-warning btn-rg" href=<?php echo $user['cqc_url_report_english']?> target="_blank">Full Report</a></td>
            
        </tr>
    </tbody>
</table>

Fatal error: undefined function pg_connect() in C:… Stack trace: #0 {main} thrown [duplicate]

how can I fix this error:

Fatal error: Uncaught Error: Call to undefined function pg_connect() in C:xmapphtdocsesamecopiavisualizzatabelle.php:11 Stack trace: #0 {main} thrown in C:xmapphtdocsesamecopiavisualizzatabelle.php on line 11

this is line 11 in the code:

$conn = pg_connect("host=localhost port=5432 dbname=ospedali user=postgres password=Miomatti29");

How can I get div position in percentage from parent div

I am using drag and drop using jquery-ui. I am placing the draggable text on image. I need to find out the position of dropped text on image(In percentage) by using image div.

I have div like this:

<div>
<div>Some Text</div>
<div style="width=1000px; height:720px">
<img src="">
</div>
</div>

Add IF ELSE statements to PHP code, to specify colour change in text

I currently have a WordPress plugin installed, which sends an email to the owner listing “Key Dates” and their details.

Currently, if the due date has already passed, it will change the text to Red on the email, stating Originally Due on X date (as below screenshot)

Current Email Template

I would like to make a small modification to this, where the text is coloured as below:

Due within 30days – Green

Due within 15days – Yellow

Due less than 15 days/Overdue – Red

I think I need to add some IF/ELSE statements to the below code in the “propertyhive-email-schedule.php” file, however I am not quite sure of the correct code:

$details = '';
                            $schedule_start_date = new DateTime($start_date);
                            if ( $due_date < $schedule_start_date )
                            {
                                // was due in the past
                                $details = '<span style="color:#900">' . __( 'Originally due on', 'propertyhive' ) . ' ' . $due_date->format('jS M') . '</span>';

Could I please get some assistance/pointers on the correct code to put in over here please to make the changes stated above?
The PHP file itself is not too big, happy to attach the entire file if it makes it easier?

Thanks!

Twilio – continue messaging after reaching an unsubscribed number

I want to send an sms to a list of numbers. One of those numbers may have unsubscribed. However at the moment Twilio throws a very ugly error message if it encounters an unsubscribed number and then just stops.

How do I make it continue going through the array of numbers to text?

Here’s my code so far:

foreach($phoneNumbers as $phoneNumber) {
  try{
    $client->messages->create(
        $phoneNumber,
        array(
            'from' => $twilio_number,
            'body' => 'Testing from my website'
        )
    );
  } catch (DeserializeException $e) { }
    catch (TwilioException $e) { }
}