Posts Tagged with
Laravel
When I stop the vite live server sail npm run dev of Laravel 10 by ctrl + c, the CLI tells me to upgrade npm with this message.
npm notice npm notice New patch version of npm available! 9.6.4 -> 9.6.5 npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.6.5 npm notice Run npm install -g npm@9.6.5 to update! npm notice Here is a screenshot of the npm upgrade notice.
Upgrade npm inside Laravel Sail Docker environment You can not just run npm install -g npm@9.
1. Use eager loading to reduce the number of database queries Eager loading is a technique that allows you to load related models in a single query, reducing the number of queries needed to retrieve data.
Eager loading is a way to reduce the number of database queries in Laravel. It allows you to load related models in a single query, reducing the number of queries needed to retrieve data.
I have set up the github action to deploy laravel website using appleboy ssh-action but all actions failed with this weird error message.
2022/09/03 23:46:24 ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain The fix is simple. just change the permission of authorized-keys by this command.
chmod 700 ~/.ssh/authorized_keys If it works, share it with a friend or colleage.
If you want to store price in dollars such as 4.99, just store it as integer not float in database (499). And in your model add this function.
public function getPriceAttribute(){ return floatval(number_format($this->attributes["price"] / 100, 2)); } When you get the price, it is 4.99 , but it is stored as 499. This saves a huge space when you have more than 10k records in database.
The optimization aspect is to store double float values as integers in database.
Laravel is a framework for backend development for websites. It is written in PHP programming language. We use PHP to write website backend code in Laravel framework.
A list of operators on Eloquent’s where() method When you use Eloquent’s where() method, by default it will use the = operator (i.e. ->where('fieldname','value') will generate ... WHERE fieldname = 'value'....
However you are not limited to just =. You can do something like this:
laravel new project-name create a new folder named “project-name” in the current directory. Then create all necessary Laravel project files inside it.
composer require vendor/package update composer.json with the necessary details of the package you are choosing to install, then install the package in your project.
composer update update the installed packages.
composer dump-autoload updates your vendor/composer/autoload_classmap.php file. You have to run this command if you have a new class in your project that has not yet been loaded.