Laravel 8.0 CRUD Tutorial Using Mysql Database

Hello Artisan,

Today we will create a CRUD application in Laravel using Mysql Database. CRUD extends Create, Read, Update, Delete. We performing This operation in our new fresh laravel project. So, let’s start.

Create a Laravel Project first, run thi…


This content originally appeared on DEV Community and was authored by devcse

Hello Artisan,

Today we will create a CRUD application in Laravel using Mysql Database. CRUD extends Create, Read, Update, Delete. We performing This operation in our new fresh laravel project. So, let’s start.

Create a Laravel Project first, run this command

composer create-project --prefer-dist laravel/laravel blog

After completion the creation of laravel project, lets go…

*Make databse Connection *
create a databse in the mysql database after that go to the .env file

and add the code

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel_crud
DB_USERNAME=root
DB_PASSWORD=

Set your Databasae name,username and password.

Now, run this command to migrate

php artisan migrate

Create Product model

php artisan make:model Product

Create migration for products table, run this command

php artisan make:migration create_products_table --create=products

let’s add products table column propertise to the migration file.

Schema::create('products', function (Blueprint $table) {
    $table->id();
    $table->string('title');
    $table->text('details');
    $table->timestamps();
});

Create Controller, run this command

php artisan make:controller ProductController --resource

In web.php add our route,

web.php

<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\ProductController;
use App\Http\Controllers\UserController;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('index');
});

Route::resource('product',ProductController::class);

To see out all route, run this command

php artisan route:list

Output

FULL CRUD GET HERE: Link


This content originally appeared on DEV Community and was authored by devcse


Print Share Comment Cite Upload Translate Updates
APA

devcse | Sciencx (2021-07-20T18:28:30+00:00) Laravel 8.0 CRUD Tutorial Using Mysql Database. Retrieved from https://www.scien.cx/2021/07/20/laravel-8-0-crud-tutorial-using-mysql-database/

MLA
" » Laravel 8.0 CRUD Tutorial Using Mysql Database." devcse | Sciencx - Tuesday July 20, 2021, https://www.scien.cx/2021/07/20/laravel-8-0-crud-tutorial-using-mysql-database/
HARVARD
devcse | Sciencx Tuesday July 20, 2021 » Laravel 8.0 CRUD Tutorial Using Mysql Database., viewed ,<https://www.scien.cx/2021/07/20/laravel-8-0-crud-tutorial-using-mysql-database/>
VANCOUVER
devcse | Sciencx - » Laravel 8.0 CRUD Tutorial Using Mysql Database. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/07/20/laravel-8-0-crud-tutorial-using-mysql-database/
CHICAGO
" » Laravel 8.0 CRUD Tutorial Using Mysql Database." devcse | Sciencx - Accessed . https://www.scien.cx/2021/07/20/laravel-8-0-crud-tutorial-using-mysql-database/
IEEE
" » Laravel 8.0 CRUD Tutorial Using Mysql Database." devcse | Sciencx [Online]. Available: https://www.scien.cx/2021/07/20/laravel-8-0-crud-tutorial-using-mysql-database/. [Accessed: ]
rf:citation
» Laravel 8.0 CRUD Tutorial Using Mysql Database | devcse | Sciencx | https://www.scien.cx/2021/07/20/laravel-8-0-crud-tutorial-using-mysql-database/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.