Laravel 10 didn’t show pictures from resources

When ever i give path in laravel for resources folder, it not shows pictures and apply css from resources but then i found solutions on stack. Which was save my file’s, pictures css js in public folder then give path like this, {{asset(‘/img/img.png’)}} it works only when files are in public not for resources folder.

My question is keep files regarding website pictures css js etc in public is safe, or not. Does it have any vulnerabilities for hackers to access these files from public folder.

And what about resources folder, why am not able to show my pictures from here and css.

I tried this syntax as href to access my files and pictures to show on home page of site, but not working.

{{asset(‘resources/img/img.png’)}}
Also try simple href and give path resources/img/img1.png not working for artisan serve but it works in local host.

Removing Laravel global scopes via a controller method apiResource

I’m using global scopes in a few of my models. I’d like to be able to dynamically remove the scoped logic at a controller level. My scope is applied to my PingtreeGroup model, and when I try to remove the global scope via my controller show method I get an error.

Too few arguments to function IlluminateDatabaseEloquentBuilder::withoutGlobalScope(), 0 passed

/**
 * Display the specified resource.
 *
 * @return IlluminateHttpResponse
 */
public function show(Company $company, PingtreeGroup $pingtreeGroup)
{
    $this->authorize('view', $pingtreeGroup);

    $pingtreeGroup = $pingtreeGroup->withoutGlobalScope()->load([
        'pingtree_group_entries',
        'pingtree_group_entries.pingtree' => function ($query) {
            $query->withCount('pingtree_entries');
        },
        'pingtree_group_entries.pingtree.pingtree_entries',
        'pingtree_group_entries.pingtree.pingtree_entries.buyer_tier',
        'pingtree_group_entries.pingtree.pingtree_entries.buyer_tier.buyer',
    ])->loadCount('pingtree_group_entries');

    return new ApiSuccessResponse($pingtreeGroup);
}

What am I missing?

Are empty tables in database a good idea? They are needed but will not always be populated

Designing a simple website for a game as a learning project. The challenge I have is that I want the game host to specify how many rounds the game will have. This will be an input and then based on this we will record our scores in generated fields. Sometimes the game will have 4 rounds and sometimes 6 and at the end the system will sum up all the points. Is it good to create a game table in my database which will have 6 columns (they will not always be populated due to different number of rounds) or shall I look at other options? Any tools I could use to make it more dynamic? I’m brand new so a lot to learn.

The only idea I have is to create a table with 6 columns. I assume this will work with this project but will not if a game goes for 20 or 30 rounds.

Need help implementing this PHP library in my Project

For a class assignment I have to build a calculator that uses a PHP backend logic to calculate the user input. I came across this library on GitHub that is a perfect fit for my requirement;

https://github.com/chriskonnertz/string-calc

From what I understand I can simply send an user input string (e.g. ’64*5′) from HTML to the calculate() function in StringCalc.php to evaluate a result that I can display back to HTML.

My problem however is I am unable to setup a index.php file that can create an StringCalc oject so that I can use it’s function calculate() for user input that I may fetch using $_POST. (I have attached a screenshot of what I am writing in index.php).
index.php file code

I created an empty directory and then used composer as stated in README of this repo.

composer require chriskonnertz/string-calc

In the base folder I created an index.php file (I have attached a screenshot for reference) and included StringCalc.php using its relative path.

But I keep getting this error:

“Fatal error: Uncaught Error: Class “ChrisKonnertzStringCalcContainerServiceProviderRegistry” not found in C:xampphtdocsStringCalcvendorchriskonnertzstring-calcsrcChrisKonnertzStringCalcStringCalc.php:68 Stack trace: #0 C:xampphtdocsStringCalcindex.php(5): ChrisKonnertzStringCalcStringCalc->__construct() #1 {main} thrown in C:xampphtdocsStringCalcvendorchriskonnertzstring-calcsrcChrisKonnertzStringCalcStringCalc.php on line 68″empty folder pulled code using composer
Error as displayed in browser

How should I support localization for my project with Laravel with Vue using Inertia?

I am intermediate in Laravel. I have some published projects in Laravel for my clients.

I started a Project with Laravel with Vue using Inertia. I used a starter kit of Laravel 10 with the breeze and vue. While I am setting up my project and configuring various things, I walked through the lang directory which I published by artisan command by Laravel 10.

I am stuck at localization. I knew how to translate and localize things with Laravel only. Here is Laravel with vue is absolutely new to me.

I researched for implementing localization but I found 3 to 4 years old resources without proper implementations and a lot of hard work even lack of some translation features of laravel.

As I stated I used the starter kit and I publish the lang directory using the artisan command. I tried to change the failed message of the auth.php file located in lang/en/auth.php. I checked it by entering the wrong credential and it’s appeared my updated message in error. However now I created the hi directory for the Indian HINDI language. I copied the auth.php and translated all three messages for this file. I changed the default locale from config/app.php and tested again with the wrong credentials. This time it does not show my HINDI translation. It is showing the same English translation again. Even again I tried to change the translation line in English and it showed the updated line.

I inspected those file components for locating the translation source and I realize that it just showed an error message by form. I don’t know why it not picking up my translation files when I changed the default locale.

I am looking for an easier and more efficient way for localization in Laravel with Vue and Inertia.

After a lot of research, I found this package https://github.com/rmariuzzo/Laravel-JS-Localization.

Please let me know if will it do the job in an efficient way or if there is something default in Laravel with Vue and Inertia that is hidden from my eyes.

Thanks

Abhishek Kumar

Open ssl ecncrypted string decryption using unix command

I have encrypted a plain text using openssl_encrypt method in php. The code is given below.

 $plain_text = 'hello world';
 $password = '1224567892abcdef1231567390a1cde2';
 $iv = '3234367890fbceef';
 $options = OPENSSL_RAW_DATA;

 $enc_data = bin2hex(openssl_encrypt($plain_text, 'aes-256-ctr', $password, $options, $iv));

 echo $enc_data;

This php code generates this encrypted string: 3fd4e82b5c21ad4c2abd74

And for decrypting I am using this php code:


$plain_text = openssl_decrypt(hex2bin($enc_data), 'aes-256-ctr', $password, $options, $iv);

But I want to decrypt this encrypted code using unix command in terminal. Could anyone help me on this?

I have tried with this command:

echo -n "3fd4e82b5c21ad4c2abd74" | xxd -r -p | openssl enc -aes-256-ctr -K 1224567892abcdef1231567390a1cde2 -iv 3234367890fbceef -d -nosalt

But I am not getting the expected plain text.

I am looking for some unix command using which I can get the decrypted plain text.

How to convert gmt time to UTC using php [closed]

I am working on Php and right now i am getting “start_date” from database and i am trying to convert datetime into “UTC” time , But how can i do this ? I tried with following code

$tymEnd2 = $_POST['end_time']; // dynamic time
$endTime2 = date('h:i A', strtotime($tymEnd2));
$dateEnd2 = $_POST['end_date'];
$nft_end_data3 = $dateEnd2.' '.$endTime2;
$dateStr3 = $nft_end_data3;
$timestamp_end_utc = DateTime::createFromFormat('Y-m-d h:i A', $dateStr3)->getTimestamp();

How to use sync if I have such an array?

Good afternoon. I work with laravel and use sync. I get an array in this form:

[ 
0 => ['attribute' => '...', 'value' => '...']
1 => ['attribute' => '...', 'value' => '...']
...
]

Is it possible to stuff such an array into sync? If possible, can you tell me how to do it correctly?

Already used sync, but with an array of type:
[0 => a, 1 => b, 2 => c, ...]

Android stdio lấy dữ liệu từ php mysql [closed]

Mọi người chỉ e cách lấy dữ liệu php dùng xamp mysql trong android stdio thì làm như nào ạ

Em thử xem trên mạng họ dùng nhữ thư viện khó hiểu quá làm theo thì nhiều lúc khai báo lớp còn không có, em muốn làm cách chúng nhất để hiểu hơn về nó để tư duy hơn về sau ạ.

phpmyadmin not working after change php version from php8.1 to php7.4

Recently I have changed the PHP version on my Ubuntu ec2 server from php 8.1 to php 7.4.

After changing php version i am not able to access my phpmyadmin so i am very tired to solve this problem.

I have a problem with phpmyadmin in Ubuntu. http://server_ip/phpmyadmin doesn’t work.

Can anyone help with this?

Thank you

I added phpmyadmin to Apache configuration:

Include /etc/phpmyadmin/apache.conf

But after that not working

Display information about mysql queries in PHP

please tell me, in php there is a command like phpinfo (), which displays a query table on a page from the database (request and its processing time)

very handy tool, but after changing the project I forgot the name. Searching again on google didn’t help.

Uncaught Error: Class “MongoDBDriverManager” not found

I’m having an issue with a WordPress plugin that i created.
The plugin is supposed to connect to my mongodb atlas database and compare all the document’s contents to the users form inputs, But when i upload and activate the plugin i get this Error:

Fatal error: Uncaught Error: Class "MongoDBDriverManager" not found in C:...vendormongodbmongodbsrcClient.php:126

The error is triggered in the mongodb connection string line

$mongoClient = new MongoDBClient('mongodb+srv://XXXX:[email protected]/test?retryWrites=true&w=majority');

on my php file and is due to ‘Manager’ not being defined in 'C:...vendormongodbmongodbsrcClient.php'
I tried to import the class using use MongoDBDriverManager; but it didn’t work.
There’s the line : `

$this->manager = new Manager($uri, $uriOptions, $driverOptions);

NB: I’ve already installed and configured the mongodb php driver and the the library mongodb library.
The Plugin works fine when i run it locally, but i get this error when i upload it and activate it on wordpress.
Thanks in advance.

PHP mysql read function error (Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax;)

This is database. php file: and I am getting fatal error on line 30($result = $stm->execute($data);)

The data and query there goes from the read function in the folder named user.class.php and I carry that function with it.

Class Database
{
    public static $con;

    public function __construct()
    {
        try{
            $string = DB_TYPE .": host=" . DB_HOST . ";dbname=" . DB_NAME;
            self::$con = new PDO($string,DB_USER,DB_PASS);
        }catch (PDOException $e){
            die($e->getMessage());
        }
    }

    public static function getInstance()
    {
        if(self::$con)
        {
            return self::$con;
        }

        return $instance = new  self();
    }

    public function read($query, $data=array())
    {
        $stm= self::$con->prepare($query);
        $result = $stm->execute($data);

        if($result)
        {
            $data = $stm->fetchAll(PDO::FETCH_OBJ);
        
            if(is_array($data) && count($data) >0)
            {
                return $data;
            }
        }
        return false;

        
    }

user.class.php read function:

$data['url_adress'] = $this->get_random_string_max(60);
        //kayıtlı url_adress var mı
        $arr = false;
        $sql = "SELECT * from users where url_adress = :url_adress limit ";
        $arr['url_adress'] = $data['url_adress'];
        $check = $db->read($sql,$arr);

        if(is_array($check))
        {
            $data['url_adress'] = $this->get_random_string_max(60);
        }

So I have this error and I dont know waht to do
error message:

Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or
access violation: 1064 You have an error in your SQL syntax; check the
manual that corresponds to your MariaDB server version for the right
syntax to use near ” at line 1 in
C:xampphtdocsozimusicappcoredatabase.php:30 Stack trace: #0
C:xampphtdocsozimusicappcoredatabase.php(30):
PDOStatement->execute(Array) #1
C:xampphtdocsozimusicappmodelsuser.class.php(54):
Database->read(‘SELECT * from u…’, Array) #2
C:xampphtdocsozimusicappcontrollerssignup.php(12):
User->signup(Array) #3 C:xampphtdocsozimusicappcoreapp.php(40):
Signup->index(‘home’) #4
C:xampphtdocsozimusicpublicindex.php(15): App->__construct() #5
{main} thrown in C:xampphtdocsozimusicappcoredatabase.php on
line 30