In this post, we'll show you how to connect your Laravel app to a MySQL database, make database tables, and add some sample data.
Follow these simple steps in Laravel to build a database table:
Step1: Using your composer command prompt, create a new Laravel project using the following command
composer create-project --prefer-dist laravel/laravel dbmeza |
A new directory dbtable is created a new Laravel is installed
Step 2: First, we must create a new database in which we will create Laravel tables. Create a new database called "Lalaveltables" in PHPmyAdmin
Step 3: Now connect your Laravel application with the database. To establish a connection, open your .env file and configure your DB_CONNECTION, DB_Host, DB_PORT, DB_DATABASE, DB_USERNAME, and DB_PASSWORD
We have successfully connected our database to our web application
Step 4: Now, in the composer command prompt, run the command
composer require laravel/jetstream |
Step 5: using the command php artisan Jetstream: install livewire, Install livewire
Step 6: Now, we need to run the npm install and npm run dev
npm install
npm run dev
Step 7: Run the php artisan migrate. To create the new tables in the database and insert sample data.
That’s it. New tables have been created in the database, and sample data inserted
Article Contributed By :
|
|
|
|
1342 Views |