Lưu dữ liệu từ cửa sổ bật lên phương thức php

Lưu dữ liệu từ cửa sổ bật lên phương thức php

Amit Kumar

Làm theo

ngày 1 tháng 5 năm 2021

·

4 phút đọc

Cách lưu trữ dữ liệu trong Pop-Modal trong Laravel

Trong hướng dẫn này, tôi sẽ mô tả cách lưu trữ dữ liệu trong bootstrap 4 pop modal trong laravel

composer create-project laravel/laravel employee "5.8.*"

Bước 2-> Vào. env và thiết lập kết nối với cơ sở dữ liệu

DB_HOST=127. 0. 0. 1
DB_PORT=3306
DB_DATABASE=popup-modal
DB_USERNAME=root
DB_PASSWORD=





Hãy tiếp tục tạo mô hình

php artisan make:model Employee

Chuyển đến mô hình Nhân viên và dán mã bên dưới


namespace App;

use Illuminate\Database\Eloquent\Model;

class Employee extends Model
{
//
}

Tiếp theo tạo bộ điều khiển

php artisan make:controller EmployeeController -r

Đi đến EmployeeController và dán mã bên dưới

________số 8_______

Tiếp theo tạo route vào Route/web. php và dán mã bên dưới


/*
|--------------------------------------------------------------------------
| 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('welcome');
});

Route::resource('/employee','EmployeeController');

tiếp theo vào trình duyệt và tìm kiếm

php artisan migrate
0

Bây giờ Form trông như thế này

Điền vào tất cả các trường và nhấp vào gửi

Tiếp theo Truy cập Localhost/phpmyadmin và kiểm tra xem dữ liệu của bạn đã được lưu thành công chưa

Thanks