How to remove /public/ from a Laravel 10 [closed]

I want to remove the /public/ fragment from my Laravel 10 URLs to avoid duplicate pages. Google doesnt like duplicate pages.

I have plesk panel for my domain. I didnt change anything. My root document is public.

Can you help me solve this problem, thank you in advance.

public htaccess

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>
    RewriteEngine On
    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
     # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]
    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

I want to help create an order delivery system

I want to develop websites and create an advanced web page that contains a system for tracking orders
I am a beginner in programming and I want advice. I want to develop websites and create an advanced web page that contains a system for tracking orders, not via satellite, but tracking the status of the shipment (in shipment – with the representative – delivered) and I want to enable customers to enter the site with specific permissions. To add their shipments, modify them, print receipts, view and create reports, and the representative can also enter with certain powers as well.
I want to know what programming languages I use or learn first hand, and what are the websites or applications that help me develop the website, and because you are a professional, I want advice from you and tools that facilitate programming.

I tried a lot, but I don’t know some codes and I don’t know where to find them, so I want help from professionals.
I will never stop learning and asking questions 😉

Ioncube 13 does NOT work with XDEBUG up from php 8.1

has anybody a solution for running XDEBUG 3.x together with the IonCube-Loader 13?
It does not work anymore since v13 of Ioncube and the recommended solution from IonCube is to not use XDEBUG, this can only be a joke. Developing in projects where other encoded plugins or routines are present is daily business. Nobody really expects to step through encoded code but it had to be executed properly while debugging and coding the rest. Of course, for some bucks everyone could decode ioncube files what makes its protection a joke too, but in general and for my opinion XDEBUG and the IonCube-Loader is a very common combination.
Any hints or workarounds available to make this work again?

Laravel Filament list resource relation

I’m using Laravel Filament, and I have hard time to list the resource relations in a way I want.

I have a Survey and a Question model. A survey can have many question, and a question belongs to a survey. In the SurveyResource I want to list the survey’s questions in the table, and use survey as just a filter. Also I want to ordering the questions there.

return $table
            ->columns([
                TablesColumnsTextColumn::make('questions.title')

            ])
            ->filters([
                //
            ])
            ->actions([
                TablesActionsEditAction::make(),
            ])
            ->bulkActions([
                TablesActionsBulkActionGroup::make([
                    TablesActionsDeleteBulkAction::make(),
                ]),
            ]);

This list the questions in one row, but I want to appear in different rows.

Should I use RelationManager or a custom page for this feature?

syntax error, unexpected token “@” (View: /data/sites/web/admin/report/rec_revenue.blade.php

I am Using Laravel and my code was working fine i don’t know if this error is because of server or something else. but i guess in blade template it is having trouble converting @php to i would be happy if you will guide me
my code look like this

<tbody>
@foreach ($arrData as $k => $data)
@php($i = 1)
@php($yearTotal = 0)
@php($futureYearTotal = 0)
@foreach ($data as $k2 => $yd)
   <tr>
   <td><h6><span class="badge bg-light">{{$k}} {{ $k2 }}</span></h6></td>
   <td class="total-amount" align="right">{{ number_format($yd['total']??0, 2, ',', ' ') }}{{ $yd['currency'] }}</td>
   </tr>
@php($yearTotal += $yd['total'])
@endforeach
@endforeach
</tbody>

enter image description here

php string to array with json encode values

hello i have json encoded dynamic string i want to do split it into my array example;

my string:

$mystring = "u0671u0671u0631u0651u064eu062du0652u0645u064eu0670u0646u0650 u0671u0644u0631u0651u064eu062du0650u064au0645u0650";

my array must be;

Array("u0671","u0671"... ");

thanks for help.

i tried manty times with explode but i didnt.

how to foreach loop in multidemensional array in php

i am new to php and want to understand the foreach loop. sorry if it is an offtopic and was earlier discussed, but i found little help from other posts.

below are 2 different arrays and the loops used for them to fetch out the keys-values (the first called $size is pretty easy and I have no problems with it; the second called $size2 loops thru an array, but i see error messages in the browser – please suggest what i did wrong):

one level array:
$size = array(
    "day" => "friday",
    "place" => "office",
    "task" => "smalot",
);
foreach loop to fetch our key-values from $size (it works fine):

foreach ($size as $key => $value) {
    echo $key . "=>" . $value . "";
}
two level array:

$size2 = array(
    "day" => "friday",
    "place" => "office",
    "task" => "smalot",
    "level2" => array(
        "place" => "desk",
        "laptop" => "lenovo",
        "coffee" => "black",
    )
);
foreach loop to fetch our key-values from $size2 (it works not properly):

foreach ($size2 as $key => $value) {
    echo $key . "=>" . $value . "<br>";
    
    foreach ($value as $subkey => $subvalue) {
        echo $subkey . "=>" . $subvalue . "<br>";
        }
}

the result of the foreach loop for $size2 is below:

day=>friday

Warning: foreach() argument must be of type array|object, string given in C:xampphtdocspdfparsersize.php on line 35
place=>office

Warning: foreach() argument must be of type array|object, string given in C:xampphtdocspdfparsersize.php on line 35
task=>smalot

Warning: foreach() argument must be of type array|object, string given in C:xampphtdocspdfparsersize.php on line 35

Warning: Array to string conversion in C:xampphtdocspdfparsersize.php on line 33
level2=>Array
place=>desk
laptop=>lenovo
coffee=>black

if i uncomment the inner loop, then i can fetch the key-values from upper array:

foreach ($size2 as $key => $value) {
    echo $key . "=>" . $value . "<br>";
    
//   foreach ($value as $subkey => $subvalue) {
//        echo $subkey . "=>" . $subvalue . "<br>";
//    }
}

result:
day=>friday
place=>office
task=>smalot

Warning: Array to string conversion in C:xampphtdocspdfparsersize.php on line 33
level2=>Array

but the goal is to fetch upper and inner key-values from an array and see no error messages. what shall i do? thanks again!

PHP determine if request contains POST form submission

I have this form for resetting passwords:

<form action = "resetpwd.inc.php" method = "post" class = "form">
    <div class = "input-group">
        <input type = "text" name = "email" placeholder = "Enter your email:">
        <span class = "icon">&#9993;</span>
    </div>
    <div class = "input-group">
        <button class = "submitbtn" type = "submit">Reset Password</button>
    </div>
</form>

I also have a resetpwd.inc.php file with the following code that handles the form submission:

if(isset($_POST["submitbtn"]))

My goal is to have this PHP code execute when I submit the form, however it isn’t doing that and it’s just refreshing the page.

Why doesn’t this for loop stop when $n equals 3?

So I have this code:

<?php 
 for ($n = 0, $result = 0, $m = 1071225; (pow($n, 3) + $result + 1) !== $m || $n < 2; $n++) {
            if ($n === 10) {
                dd('stop');
            }
            $result += pow($n, 3);
        }
dd($result);
?>

And when $n equals 3 my code doesn’t stop to execute – it stops when $n === 10, as I wrote this in my if condition. As far as I understand for loop, the middle part (in my case being):

(pow($n, 3) + $result + 1) !== $m || $n < 2

stands for stopping the code = so as I understand it will either stop if (pow($n, 3) + $result + 1) !== $m or $n < 2, but that doesn’t happen. Why is that?

I tried to solve this kata: https://www.codewars.com/kata/5592e3bd57b64d00f3000047/train/php and came up with an idea, so I tried it.

Overwriting (AuthO) Vendor package functionality in Laravel

In this file, I would like to overwrite some functionality of the one function in that file:
AuthO Laravel Package

The package is installed as a Vendor package in the application.

I dont want to change any route functionality in the application, and I dont want to fork the package.

The above file/function runs on a callback from AuthO. All this works fine, and I run Log::info() from the file to check that it runs the code. Assume this works as intended in the Vendor package.

I have the following custom provider:

<?php

namespace AppProviders;

use AppServicesAuthOService;
use IlluminateSupportServiceProvider;

class CustomAuthOServiceProvider extends ServiceProvider
{
/**
 * Register services.
 *
 * @return void
 */
  public function register(): void
  {
    // Bind the custom controller to the original controller
    $this->app->bind(Auth0LoginControllersCallbackControllerAbstract::class, AuthOService::class);
  }
}

This is registered is configapp :

..
        'providers' => [
            AppProvidersCustomAuthOServiceProvider::class,
        ]
...

Then I have a service class in AppServices:

<?php

namespace AppHttpControllers;

use IlluminateHttpRequest;
use VendorAuth0LoginControllersCallbackControllerAbstract;
// use Auth0LoginControllersCallbackControllerAbstract;

class AuthOService extends CallbackControllerAbstract
{
    /**
     * Handle the callback from the identity provider.
     *
     * @param IlluminateHttpRequest $request
     *
     * @return IlluminateHttpResponse
     */
    public function __invoke(Request $request): Response
    {
        Log::info('Handling provider callback. test');

        // Change the redirection URL to '/testtest'
        return redirect('/testtest')->intended('/');
    }
}

With all the code implementations above, there are no errors when the application runs.

But the function __invoke is not running, and the Log is not hit in my AuthOService.php.

I have checked the following:

Overwrite Laravel vendor package

Best way to override a class inside a vendor package?

How Can I Override/Change a Vendor Class?

The above links have helped me to be at the current stage of where I am at, but now I am stuck and dont know what to do from here.

How do I overwrite/extend on the specific file mentioned at the top, in a Laravel Application, without forking or changing routes?

What I specifically want to change/overwrite is the exception on line 105:

$exception = new CallbackControllerException(sprintf(CallbackControllerException::MSG_API_RESPONSE, $error, $errorDescription));

Laravel Route Not Found Error in Pest Test

I’m currently developing a Laravel package and writing tests for my API routes using Pest and orchestra/testbench. However, I’m encountering an issue where my routes cannot be found when running the test.

Can someone

Here’s the route I’m trying to test: /api/my-web/matches

<?php

use IlluminateSupportFacadesConfig;

test('', function () {
    Config::set([
        "football.route_prefix" => "api/football",
        "football.middlewares" => []
    ]);

    $response = $this->getJson('/api/my-web/matches');

    dd($response->json());
});

Error:

array:1 [
  "message" => "The route /api/my-web/matches could not be found."
] 

Pest setup:

<?php

/*
|--------------------------------------------------------------------------
| Test Case
|--------------------------------------------------------------------------
|
| The closure you provide to your test functions is always bound to a specific PHPUnit test
| case class. By default, that class is "PHPUnitFrameworkTestCase". Of course, you may
| need to change it using the "uses()" function to bind a different classes or traits.
|
*/

// uses(TestsTestCase::class)->in('Feature');
use AlexFootballtestsFootballTestCase;

uses(FootballTestCase::class)->in(__DIR__);

/*
|--------------------------------------------------------------------------
| Expectations
|--------------------------------------------------------------------------
|
| When you're writing tests, you often need to check that values meet certain conditions. The
| "expect()" function gives you access to a set of "expectations" methods that you can use
| to assert different things. Of course, you may extend the Expectation API at any time.
|
*/

expect()->extend('toBeOne', function () {
    return $this->toBe(1);
});

/*
|--------------------------------------------------------------------------
| Functions
|--------------------------------------------------------------------------
|
| While Pest is very powerful out-of-the-box, you may have some testing code specific to your
| project that you don't want to repeat in every file. Here you can also expose helpers as
| global functions to help you to reduce the number of lines of code in your test files.
|
*/

function something()
{
    // ..
}

Package TestCase:

<?php

namespace AlexFootballtests;

use AlexFootballFootballServiceProvider;
use OrchestraTestbenchTestCase;

class FootballTestCase extends TestCase
{
    protected function getPackageProviders($app): array
    {
        return [
            FootballServiceProvider::class,
        ];
    }
}

PhpUnit.xml:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
  <testsuites>
    <testsuite name="Package">
      <directory suffix=".php">./tests/</directory>
    </testsuite>
  </testsuites>
  <source>
    <include>
      <directory>src/</directory>
    </include>
  </source>
</phpunit>

ServiceProvider:

<?php

namespace AlexFootball;


use IlluminateSupportServiceProvider;

class FootballServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot(): void {
        //publish config
        $this->publishes([
            __DIR__ . '/../config/football.php' => config_path('football.php'),
        ], "football.config");

        //load api routes
        $this->loadRoutesFrom(__DIR__ . '/../routes/api.php');
    }

    /**
     * Register the application services.
     *
     * @return void
     */
    public function register() {}
}

Any help on what might be causing this issue and how to resolve it would be greatly appreciated. If someone could possibly assist me in troubleshooting this, I would be very thankful. Thank you!

How to send variables from a php file to another file in java script [duplicate]

I recently began to learn about web developement, and I notoriously created a website as a training which consists of typing as fast as possible the words that appear successively on screen. All the code was in html, css and javascript.

This week, I began to learn the basis of PHP. As my first website is quite limited (the words asked were always the same), I want to link a database of words to my project – and to do so, I would like to use php and MySQL. But here’s my issue : all the management of the words asked is made in js, which means that I would need to send some php variables to js.

To be honest, I don’t know how to do that. I don’t see how I could link both files. Does anybody knows how I could transfer the obtained php variables to js. I don’t really want to modify my html file as it could enable the users to directly access my variables.

how can I make the questions go to the database [closed]

So I’m working on a project of my senior he left the company and the owner has distributed his projects among juniors and I’ve also gotten one.

Now in this project admin is able to create new services form admin panel and they have asked me to add the area above it from where the admin can add questions for the service I’ve made the add question section =>

enter image description here

Actually I copied this from the other part of the code from where admin can edit / update the service :p But I’m not able to get these questions into the database can anyone please provide me with the proper solution on how can I achieve it?

here’s the code of it =>

<form action="#" method="post" enctype="multipart/form-data">
            <div class="row" style="margin-top: 20px; margin-left: 5px;margin-right: 5px">
               <div class=col-sm-3>
                    <div class="form-group mb-10">
                        <label>Service Category :<span style="color:red"></span></label>
                        <select class="form-control" name="category" required="required">
                          <?php $service=mysqli_query($con,"SELECT `id`, `cast` FROM `cat` ORDER BY `cast` ASC");while($runservice=mysqli_fetch_array($service)){?>
                            <option value="<?php echo $runservice['id']; ?>"><?php echo ucwords($runservice['cast']); ?></option>
                          <?php }?>
                        </select>
                    </div>
                </div>
            <div class=col-sm-6>
                    <div class="form-group mb-10">
                        <label> Service Name<span style="color:red">*</span></label>
                        <input type="text" class="form-control" name="name" maxlength="225" required placeholder="Enter Here" />
                    </div>
                </div>
                <div class=col-sm-3>
                    <div class="form-group mb-10">
                        <label> Service Cost<span style="color:red">*</span></label>
                        <input type="text" pattern="[0-9]+" class="form-control" name="servicecost" maxlength="10" required placeholder="Enter Here" />
                    </div>
                      <div class="form-group mb-10">
                        <label>Distribution Amt<span style="color:red">*</span></label>
                        <input type="text" pattern="[0-9]+" class="form-control" name="cashback" maxlength="10" required placeholder="Enter Here" />
                    </div>
                </div>
                <div class=col-sm-5>
                    <div class="form-group mb-10">
                        <label> Advance Required </label>
                       <select class="form-control" name="advance">
<option value="yes">Yes</option>
<option value="no">No</option></select>
                    </div>
                </div>
                <div class=col-sm-4>
                    <div class="form-group mb-10">
                        <label>Advance Percentage <small>(Fill Number only)</small></label>
                        <input type="text" pattern="[0-9]+" class="form-control" name="advancepercentage" placeholder="Enter Here"/>
                    </div>
                </div>
                <div class=col-sm-4>
                    <div class="form-group mb-10">
                        <label>Service Due Days (Fill Number only)</label>
                        <input type="text" pattern="[0-9]+" class="form-control" name="serviceduedays" placeholder="Enter Here" />
                    </div>
                </div>
                <div class=col-sm-4>
                    <div class="form-group mb-10">
                        <label>Payment Due Days (Fill Number only)</label>
                        <input type="text" pattern="[0-9]+" class="form-control" name="paymentduedays" placeholder="Enter Here" />
                    </div>
                </div><div class=col-sm-3>
                    <div class="form-group mb-10">
                        <label>Image</label>
                       
                       <input type="file" name="pic">
                    </div>
                </div>
<div class=col-sm-12></div>
                <div class=col-sm-4>
                    <div class="form-group mb-10">
                        <label>Service Type</label>
                <select class="form-control" name="servicetype">
<option value="onetime">One Time</option>
<option value="recurrent">Recurrent</option>
</select>
                    </div>
                </div>
                <div class=col-sm-8>
                    <div class="form-group mb-10">
                        <label>Required Documents:<span style="color:red"></span></label>
    <select class="form-control select2" multiple="multiple" data-placeholder="Select Documents"
                        style="width: 100%;" name="documents[]" id="documentlist"> 
<?php
$dcs=mysqli_query($con,"SELECT `name`, `type`FROM `documentlist` ORDER BY `name` ASC");while($doctsrun=mysqli_fetch_array($dcs)){?>
<option value="<?php echo ucwords($doctsrun['name']); ?>"><?php echo ucwords($doctsrun['name']); //echo ucwords($doctsrun['type']);?></option>
<?php }?></select></div>
                    <div id="result"></div>
                </div>
              </div>
                  
              <!-- Dynamic Questions From Admin -->
                <strong> Add Form Questions <button id="rowwAdder" width="50%" type="button" class="btn btn-dark">
                  <span class="bi bi-plus-square-dotted">
                    </span> <i class="fa fa-plus"></i>
                  </button></strong>
                  <div class="">
                    <div id="newinput"></div>
                    <?php
            $in_question = mysqli_query($con, 'INSERT INTO form_question (question, cat_id, service_id)VALUES("'.$question.'","'.$category_id.'", "'.$service_id.'")');?>

                    <div align="center" style="padding-top:3%;"> <input type="submit" class="btn btn-info" name="submit"></div>
        </form>

and here’s the js code of it which is loading the input field for adding the question on button click =>

$("#rowwAdder").click(function () {
  newRowAdd = '<div id="row"> <div class="input-group m-3">' + '<div class="input-group-prepend">' 
  + '<button class="btn btn-danger" id="DeleteRow" type="button">' +
    '<i class="fa fa-remove"></i></button> </div>' +
    '<input type="text" class="form-control m-input " name="multi_question[]" style="width:1215px;"> </div> </div>';

  $('#newinput').append(newRowAdd);
});
$("body").on("click", "#DeleteRow", function () {
  $(this).parents("#row").remove();
})

if you need any more clearness or want me to post the whole code of this page please let me know I’m here its 706 lines long.