samedi 6 mai 2023

Query Builder Skip Blank messages

I don't want users to whom the user has not sent or received messages before appear in the list, how can I fix this? Currently all users are listing.

DATABASE: DATABASE PHOTO

Query Command:

 public static function otherUserData($user_id)

  {

    $value = DB::table('users')

    ->select(['*', DB::raw('MAX(conver_date) AS lastConver')])

    ->leftJoin('conversation', function ($join) use ($user_id) {

        $join->on('conversation.conver_seller_id', '=', 'users.id')

            ->on('conversation.conver_user_id', '=', DB::raw($user_id))

            ->orOn('conversation.conver_seller_id', '=', DB::raw($user_id))

            ->on('conversation.conver_user_id', '=', 'users.id'); 

    })

    ->where('user_type', '!=', 'admin')

    ->where('id', '!=', $user_id)

    ->where('drop_status', '=', 'no')

    ->orderBy('lastConver', 'desc')

    ->groupBy('id')

    ->get(); 



return $value;

  }

I will be glad if you help me thank you.



via Chebli Mohamed

vendredi 5 mai 2023

when my laravel proj keep in wampp C:\wamp64\www than why this is use xampp version and ^7.1.3 your php version (8.1.6) not satisfy with requirement

enter image description here

Problem 29 - phpunit/php-file-iterator is locked to version 2.0.2 and an update of this package was not requested. - phpunit/php-file-iterator 2.0.2 requires php ^7.1 -> your php version (8.1.6) does not satisfy that requirement. Problem 30 - phpunit/php-timer is locked to version 2.0.0 and an update of this package was not requested. - phpunit/php-timer 2.0.0 requires php ^7.1 -> your php version (8.1.6) does not satisfy that requirement. Problem 31 - phpunit/php-token-stream is locked to version 3.0.0 and an update of this package was not requested. - phpunit/php-token-stream 3.0.0 requires php ^7.1 -> your php version (8.1.6) does not satisfy that requirement. Problem 32 - phpunit/phpunit is locked to version 7.3.5 and an update of this package was not requested. - phpunit/phpunit 7.3.5 requires php ^7.1 -> your php version (8.1.6) does not satisfy that requirement. Problem 33 - sebastian/code-unit-reverse-lookup is locked to version 1.0.1 and an update of this package was not requested. - sebastian/code-unit-reverse-lookup 1.0.1 requires php ^5.6 || ^7.0 -> your php version (8.1.6) does not satisfy that requirement. Problem 34 - sebastian/comparator is locked to version 3.0.2 and an update of this package was not requested. - sebastian/comparator 3.0.2 requires php ^7.1 -> your php version (8.1.6) does not satisfy that requirement. Problem 35 - sebastian/diff is locked to version 3.0.1 and an update of this package was not requested. - sebastian/diff 3.0.1 requires php ^7.1 -> your php version (8.1.6) does not satisfy that requirement. Problem 36 - sebastian/environment is locked to version 3.1.0 and an update of this package was not requested. - sebastian/environment 3.1.0 requires php ^7.0 -> your php version (8.1.6) does not satisfy that requirement. Problem 37 - sebastian/exporter is locked to version 3.1.0 and an update of this package was not requested. - sebastian/exporter 3.1.0 requires php ^7.0 -> your php version (8.1.6) does not satisfy that requirement. Problem 38 - sebastian/global-state is locked to version 2.0.0 and an update of this package was not requested. - sebastian/global-state 2.0.0 requires php ^7.0 -> your php version (8.1.6) does not satisfy that requirement. Problem 39 - sebastian/object-enumerator is locked to version 3.0.3 and an update of this package was not requested. - sebastian/object-enumerator 3.0.3 requires php ^7.0 -> your php version (8.1.6) does not satisfy that requirement. Problem 40 - sebastian/object-reflector is locked to version 1.1.1 and an update of this package was not requested. - sebastian/object-reflector 1.1.1 requires php ^7.0 -> your php version (8.1.6) does not satisfy that requirement. Problem 41 - sebastian/recursion-context is locked to version 3.0.0 and an update of this package was not requested. - sebastian/recursion-context 3.0.0 requires php ^7.0 -> your php version (8.1.6) does not satisfy that requirement.fy that requirement. Problem 42 - theseer/tokenizer is locked to version 1.1.0 and an update of this package was not requested. quirement. - theseer/tokenizer 1.1.0 requires php ^7.0 -> your php version (8.1.6) does not satisfy that requirement. Problem 43 y that requirement. - webmozart/assert is locked to version 1.3.0 and an update of this package was not requested. - webmozart/assert 1.3.0 requires php ^5.3.3 || ^7.0 -> your php version (8.1.6) does not satisfy that requirement.y that requirement. ny/http-foundation[v4.1.4]. Problem 44 sted. - symfony/http-foundation v4.1.4 requires php ^7.1.3 -> your php version (8.1.6) does not satisfy that requirement. - barryvdh/laravel-cors v0.11.2 requires symfony/http-foundation ^3.1|^4 -> satisfiable by symfony/http-foundation[v4.1.4]. - barryvdh/laravel-cors is locked to version v0.11.2 and an update of this package was not requested.



via Chebli Mohamed

jeudi 4 mai 2023

Redirection issue in laravel 5.6

I have one project in laravel 5.6 which is specifically with nginx and the issue that I am facing with that is if I hit the url with the HTTPS than the URL works fine but if the same URL, I hit with HTTP than it shows me the error.

Example:

Https://example.com

..this works fine and it redirect me to login page

Http:/example.com

..But in this case it shows me the error like not secure connection.

Although I have entered the proper code and redirect in web.php file and as well as in appserviceprovider.php to force fully redirect to HTTPS if the entered url is HTTP.

Anyone have any idea. How can I debug or how can I add any logging or any thing to find the exact issue? Please help me with this I really need to resolve this as it's blocker for me now.

I have entered the diffrent configuration code in nginx l.config file but didn't get any success.

Thanks.



via Chebli Mohamed

Laravel file storage issues

I have an issue with Laravel

Case:

  1. Create a file test.csv with data "abcdefg"
  2. Delete the file test.csv
  3. Recreate the file test.csv with data "zmamamama"

My code

$data = "asdsdsds";

 if(file_exists(storage_path('app/public/test/test.csv'))){
   unlink(storage_path('app/public/test/test.csv' ));
 }

Excel::store(new SomeTest($data), '/public/test/test.csv');

The issue is that test.csv still shows the old data ("abcdefg") even though the file o nthe local server show the new data accessed the file from the URL test.com/storage/test/test.csv

I'm using CentOS on the machine running my Laravel server.



via Chebli Mohamed

mercredi 3 mai 2023

Laravel MySQL Full text search InnoDB Relevancy Calculation for multiple rows with same number of occurences in total

using mysql from xaamp v8.1.10 along with laravel v5.5.3. Full text Search enabbled in table 'ex1' for column 'des' and 'ft_min_word_len = 1'.

laravel query:

$string='pink item product;

$result = ex::active()->selectRaw("*,match(des) against('$string' in boolean mode) as relevance")->whereRaw("match(des) against('$string' in boolean mode)")->orderBy('relevance', 'desc')->get();

I am getting the result as :

id | Relevance | des

64 | 1.3543391227722 | amazing pink petite lace item is item. 182 | 1.3543391227722 | this pink tall polyester item is item. 598 | 1.3543391227722 | which pink large polyester item is item. 653 | 1.3543391227722 | amazing pink plus size linen item is item. 808 | 1.3543391227722 | what pink tall cashmere item is item. 19 | 1.344024181366 | different pink large silk product is item. 134 | 1.344024181366 | that pink large wool product is item. 140 | 1.344024181366 | this pink tall lace item is product. 233 | 1.344024181366 | new pink extra-small lace item is product. 273 | 1.344024181366 | this pink tall cashmere item is product. 625 | 1.344024181366 | amazing pink medium lace product is item. 893 | 1.344024181366 | that pink extra-small leather item is product. 908 | 1.344024181366 | which pink tall lace product is item. 992 | 1.344024181366 | this pink large cotton product is item. 21 | 1.3337094783783 | that pink extra-small cashmere product is product. 28 | 1.3337094783783 | amazing pink small denim product is product. 71 | 1.3337094783783 | different pink medium cashmere product is product. 225 | 1.3337094783783 | the pink small cotton product is product. 283 | 1.3337094783783 | that pink extra-large silk product is product. 297 | 1.3337094783783 | old pink large lace product is product. 446 | 1.3337094783783 | different pink tall silk product is product. 629 | 1.3337094783783 | this pink extra-small silk product is product. 740 | 1.3337094783783 | new pink extra-small wool product is product. 789 | 1.3337094783783 | what pink extra-small leather product is product.

My question is :

64 | 1.3543391227722 | amazing pink petite lace item is item. and 21 | 1.3337094783783 | that pink extra-small cashmere product is product., though having the same number of occurences:

column 64 has : item-2 times, pink-1 time and column 21 has : product-2 times pink-1 time.

my question is how is the relevance calulated ?

also, even though column 64 and column 182 has same set of occureneces, both has pink-1 time and item-2 times, the relevance for column 64 is higher. why ?

initially i though this was based on row number in database, the order inn which it was created. But inthat case, my first question should be invalid as column 21 should come before column 64. i cant understand how it is calculated.

i did caalculation this far with MySQL doc on full text search and i cant find a documnetation covering this kind of scenario.

Thanks in Advance.



via Chebli Mohamed

lundi 1 mai 2023

How to fix this issue "PHP Fatal error: Uncaught Error: Call to private PHPUnit\Framework\TestSuite::__construct() from scope"

I am facing below mentioned issue when executing the command "phpunit" in Lumen:

PHP Fatal error:  Uncaught Error: Call to private PHPUnit\Framework\TestSuite::__construct() from scope PHPUnit\TextUI\TestSuiteMapper in /usr/share/php/PHPUnit/TextUI/TestSuiteMapper.php:38
Stack trace:
#0 /usr/share/php/PHPUnit/TextUI/Command.php(390): PHPUnit\TextUI\TestSuiteMapper->map()
#1 /usr/share/php/PHPUnit/TextUI/Command.php(111): PHPUnit\TextUI\Command->handleArguments()
#2 /usr/share/php/PHPUnit/TextUI/Command.php(96): PHPUnit\TextUI\Command->run()
#3 /usr/bin/phpunit(73): PHPUnit\TextUI\Command::main()
#4 {main}
Next PHPUnit\TextUI\RuntimeException: Call to private PHPUnit\Framework\TestSuite::__construct() from scope PHPUnit\TextUI\TestSuiteMapper in /usr/share/php/PHPUnit/TextUI/Command.php:98
Stack trace:
#0 /usr/bin/phpunit(73): PHPUnit\TextUI\Command::main()
#1 {main}
  thrown in /usr/share/php/PHPUnit/TextUI/Command.php on line 98


via Chebli Mohamed

Solving dependecy confilct for upgraing laravel backpack

I'm attempting to upgrade laravel backpack to v3.4.0 guiding by this document.

currently this laravel version is 5.7.x.(yeah it is really outdated project).

in 9th step says run php artisan backpack:base:install, when in run this command this error will be occur :


The command "composer require laracasts/generators:dev-master --dev" failed.           
                                                                                         
  Exit Code: 2(Misuse of shell builtins)                                                 
                                                                                         
  Working directory: /home/user/php/laravel/                             
                                                                                         
  Output:                                                                                
  ================                                                                       
                                                                                         
                                                                                         
  Error Output:                                                                          
  ================                                                                       
  ./composer.json has been updated                                                       
  Running composer update laracasts/generators                                           
  Loading composer repositories with package information                                 
  Updating dependencies                                                                  
  Your requirements could not be resolved to an installable set of packages.             
                                                                                         
    Problem 1                                                                            
      - Root composer.json requires laracasts/generators dev-master -> satisfiable by l  
  aracasts/generators[dev-master].                                                       
      - laracasts/generators dev-master requires illuminate/support ~6.0|~7.0|~8.0|~9.0  
  |^10.0 -> found illuminate/support[v6.0.0, ..., v6.20.44, v7.0.0, ..., v7.30.6, v8.0.  
  0, ..., v8.83.27, v9.0.0, ..., v9.52.7, v10.0.0, ..., v10.9.0] but these were not loa  
  ded, likely because it conflicts with another require.                                 
                                                                                         
  Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removal  
  s for packages currently locked to specific versions.                                  
                                                                                         
  Installation failed, reverting ./composer.json and ./composer.lock to their original   
  content.

In summary laracasts/generators depends on illuminate/support v6.0.0 - v10.9.0 which is not loaded.

how should i solve this conflict?

as error says : i have tried run this command with -W option which is : composer require laracasts/generators:dev-master --dev -W and same error has occured :

- Root composer.json requires laracasts/generators dev-master -> satisfiable by laracasts/generators[dev-master].
    - laracasts/generators dev-master requires illuminate/support ~6.0|~7.0|~8.0|~9.0|^10.0 -> found illuminate/support[v6.0.0, ..., v6.20.44, v7.0.0, ..., v7.30.6, v8.0.0, ..., v8.83.27, v9.0.0, ..., v9.52.7, v10.0.0, ..., v10.9.0] but these were not loaded, likely because it conflicts with another require.
`



via Chebli Mohamed