How-to articles, tricks, and solutions about LARAVEL

Laravel Query Builder where max id

In Laravel, you can use the Query Builder's max method to retrieve the maximum value of a specific column.

Laravel says "Route not defined"

There could be several reasons why you are seeing this error message in Laravel.

Laravel Socialite: InvalidStateException

The InvalidStateException is thrown by Laravel's Socialite package when the state parameter provided in the OAuth redirect URL does not match the one stored in the session.

Laravel storage link won't work on production

There are several reasons why the Laravel storage link may not be working on production.

Laravel: Error [PDOException]: Could not Find Driver in PostgreSQL

It looks like you are trying to connect to a PostgreSQL database from your Laravel application, but the PDO (PHP Data Objects) extension is not installed or enabled in your PHP environment.

Laravel: getting a single value from a MySQL query

To get a single value from a MySQL query in Laravel, you can use the value method on a query builder instance.

Laravel: How to get last N entries from DB

You can use the latest method on a query builder instance to get the last N entries from the database.

Laravel: redirect from controller to named route with params in URL

In Laravel, you can redirect from a controller to a named route with URL parameters using the redirect() helper function.

MassAssignmentException in Laravel

Here is an example of how a MassAssignmentException might be triggered in Laravel:

php artisan migrate - SQLSTATE[HY000] [1045] Access denied for user 'laravel'@'localhost'

This error message is indicating that the PHP script, "artisan," is attempting to run a database migration command, but the database server is denying access to the user "laravel" on the "localhost" location.

PHP Composer update "cannot allocate memory" error (using Laravel 4)

This error can occur when the composer process is trying to allocate more memory than is available to it.

Proper Repository Pattern Design in PHP?

The Repository pattern in PHP is a design pattern that allows for the separation of the business logic of an application from the storage and retrieval of data.

ReflectionException: Class ClassName does not exist - Laravel

This error message indicates that Laravel is trying to use a class that it can't find.

Reloading .env variables without restarting server (Laravel 5, shared hosting)

In Laravel 5, you can use the php artisan config:cache command to compile all of your configuration into a single file, which will be loaded quickly by the framework.

SQLSTATE[42S22]: Column not found: 1054 Unknown column

It looks like you are encountering an error with the message "SQLSTATE[42S22]: Column not found: 1054 Unknown column".

Switch in Laravel 5 - Blade

In Laravel 5, the Blade templating engine provides a "switch" statement that allows you to compare a variable to multiple values and execute different code for each match.

Tell Composer to use Different PHP Version

To use a specific version of PHP with Composer, you can specify the version you want to use in the config section of your composer.json file.

The Mix manifest does not exist when it does exist

This error message typically indicates that the Laravel Mix build process is unable to find the mix-manifest.json file that it generates when you run the npm run dev or npm run production command.

Truncate string in Laravel blade templates

To truncate a string in a Laravel blade template, you can use the str_limit function.

Trying to get Laravel 5 email to work

To get Laravel 5's email functionality to work, you will need to configure your SMTP settings in the .env file, located in the root directory of your Laravel project.

Use different PHP version CLI executable for one command

You can use the alias command in your terminal to create a new command that runs a different version of PHP.

What are the Differences Between "php artisan dump-autoload" and "composer dump-autoload"?

php artisan dump-autoload is a command that is part of the Artisan command-line interface included with Laravel.

1 2 3 4