Database Seeding in Laravel With Example

What is Database Seeding? Database seeding is the process of seeding a database with actual or dummy data, according to Wikipedia. Seeding a database is the process of providing an initial collection of data to a database after setup. It’s especially beneficial when we need to populate the database with data that we’ll need later.

Learn More

How to Seed JSON Data in Laravel?

Suppose we have created a JSON file for a particular task like a country list and we need to use it at multiple locations and process some operations like sorting, searching, filtering, etc. So we can handle it more easily and save processing time with databases instead of files. But converting JSON Data into the

Learn More

Laravel Automatic Daily Database Backup Example

In software development, we need to be ready to handle server crashes or data being mistakenly and this can cause a lot of trouble for the business. So developing a system that takes database backup regularly is considered the best practice. Database backups are essential for protection against data loss that can disrupt operations and

Learn More

Database Backup with Spatie Backup in Laravel

As we already know database backup is an essential part of the software development process. But sometimes it will become messy or time-consuming to manually take database backups check which database is older and delete older databases. You will feel great after knowing that the Spatie Laravel-Backup library can perform most of the database backup

Learn More

Laravel One to One Relationship Example

In database design, relationships are important to perform normalization. With a relationship, we can easily store, retrieve, and validate data. In the Laravel framework, Eloquent provides an easy way to work with database relationships. In this example, we create two different tables and define the relationship between them. A one-to-one relationship is a very simple

Learn More

MySQL Database Connection Tutorial in PHP

While developing a dynamic website, the first thing we need to connect our database to a PHP application. Even small application that requires dynamic data needs a database connection. Without a database connection, we can’t perform any operations like create, read, update, and delete. In this tutorial, we will connect our PHP application with MySQL

Learn More

Check Database Connection in Laravel

In this example, we will check the database connection in Laravel. Before starting to create a new Laravel application start your database services like XAMPP or WAMPP and change database credentials in the .env file. Here, we will check database is connected and get an active database name using DB helper. To check database exists

Learn More

Delete All Data From Eloquent Model

Sometimes we need to delete all the data from a table. Some tables are just to store temporary data. So we need to delete or empty the table using a specific time or event. Laravel or Eloquent has many methods from query to static from removing all records from the table like DB class with

Learn More

How to Check Table Or Column Exists In Laravel

While working on an enterprise-level project, it commonly occurs that we want to create a particular table or column into a table that already exists and that shows an error. In this tutorial, we will see how to check particular table or column exists or not. Typical migration looks like below code: When we run

Learn More