How-to articles, tricks, and solutions about LARAVEL

Access denied for user 'homestead'@'localhost' (using password: YES)

This error message indicates that there was a problem connecting to the MySQL database with the provided credentials.

artisan migration error "Class 'Doctrine\\DBAL\\Driver\\PDOMySql\\Driver' not found"

This error message is indicating that the PHP extension for PDO MySQL is not installed or not enabled on your system.

Assets not referencing to public folder (Laravel)

In the Laravel framework, the "public" folder is the web server's document root and it's where assets such as CSS, JavaScript, and images should be stored.

Calculate difference between two dates using Carbon and Blade

To calculate the difference between two dates using Carbon and Blade, you can use the following steps:

Calling other function in the same controller?

In PHP, you can call a function within the same controller by simply calling the function name followed by parentheses.

can't write image data to path in laravel using the Intervention library

There could be several reasons why you are unable to write image data to a path in Laravel using the Intervention library.

Composer: file_put_contents(./composer.json): failed to open stream: Permission denied

This error message is indicating that the script is trying to write to the file "composer.json" in the current directory (indicated by "./"), but it doesn't have the necessary permissions to do so.

Could not open input file: artisan

It looks like you are trying to run the artisan command but are getting an error saying that the input file could not be found.

create folder in laravel

In Laravel, you can create a new folder using the File facade's makeDirectory method.

Displaying the Error Messages in Laravel after being Redirected from controller

In Laravel, you can use the withErrors method to pass error messages to a view after a redirect.

Doing HTTP requests FROM Laravel to an external API

To make an HTTP request from Laravel to an external API, you can use the HTTP client of your choice.

Eloquent model mass update

To update multiple records in the Eloquent ORM (Object-Relational Mapping) in Laravel, you can use the update() method on the query builder or on a model instance.

Fatal error: Class 'Illuminate\Foundation\Application' not found

This error message indicates that the Laravel framework is unable to find the Application class from the Illuminate\Foundation namespace.

Find last iteration of foreach loop in laravel blade

In Laravel Blade, you can use the @forelse loop to check if the last iteration of a loop has been reached.

Format Timezone for Carbon Date

To format a timezone for a Carbon date in PHP, you can use the format() method and include the e or I format codes.

Get an image extension from an uploaded file in Laravel

To get the extension of an uploaded file in Laravel, you can use the getClientOriginalExtension method of the UploadedFile instance, which is available in the request object.

Get environment value in controller

To get an environment value in a PHP controller, you can use the getenv function.

Get only specific attributes with from Laravel Collection

To get specific attributes from a Laravel Collection, you can use the pluck method.

How Can I Remove “public/index.php” in the URL Generated Laravel?

To remove "public/index.php" from the URL in a Laravel application, you can use the built-in PHP web server or set up a web server with Apache or Nginx.

How do I write to the console from a Laravel Controller?

You can use the Log facade to write to the console from a Laravel controller.

How I can put composite keys in models in Laravel 5?

In Laravel 5, you can specify a composite key on a model by defining a protected $primaryKey property on the model and setting it to an array of the column names that make up the primary key.

How to alias a table in Laravel Eloquent queries (or using Query Builder)?

To alias a table in a Laravel Eloquent query, you can use the as method on a DB facade.

How to delete multiple records using Laravel Eloquent

You can use the destroy() method in Laravel Eloquent to delete multiple records.

How to disable registration new users in Laravel

To disable registration of new users in Laravel, you can remove the registration routes from the web.php file in the routes folder.

1 2 3 4