当前位置:网站首页>Laravel8 fill data
Laravel8 fill data
2022-06-25 05:51:00 【Yuan starts and ends】
First , We need to download the latest version of laravel frame :
composer create-project --prefer-dist laravel/laravel www.zfw.comAfter the download is completed, you can switch the directory to the... After the download is completed www.zfw.com Under the table of contents :
cd www.zfw.comnext , We can install a... In the frame PHPstorm Development plug-ins for , It can make our development more convenient and fast :
composer require barryvdh/laravel-ide-helperAfter downloading the plug-in , Using this command makes the editor we use better support plug-ins :
php artisan ide-helper:gen![]()
If the above figure appears, the installation is successful .
Next , The environment we may use in development is a small skin system , We need to turn on ;
Then we need to configure a new local domain name for the newly generated framework , Be careful ! If the domain name of the newly downloaded framework is set by the Xiaopi system , The contents of the hidden entry file will disappear , Need to rewrite the entry file !
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
or
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
</IfModule>After setting the local domain name , We can enter the local domain name just set in the website , See if you can enter :
![]()
The framework is basically completed , Now let's do the filling configuration
here , We need to modify the database information that the framework needs to connect to in the framework's configuration file , The following configuration information needs to be written in the root directory of the framework env In file :
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=wwwzfwcom
DB_USERNAME=root
DB_PASSWORD=root
DB_PREFIX=zfw_among database For the database name in the database ,username Account number for the database ,password Password for the database ,prefix Prefix the table with
Next , The database tool we use is Navicat, You need to create a new database :

Then , We need to create a file in the root directory of the framework config Found a folder named database.php Find this method in the file and modify :
'prefix' => env('DB_PREFIX'),Then we can modify the local configuration of the framework , Because of the laravel The framework is built for foreign developers , So we need to change the localization configuration of the framework :
1: Change the root directory app.php in timezone The time zone of is :
'timezone' => 'PRC',2: Download the Chinese language pack , Put in the frame root directory ->resources->lang in
use first composer download :
composer require "overtrue/laravel-lang:~3.0"Second, replace config/app.config Class in
take :
Illuminate\Translation\TranslationServiceProvider::class,Replace with :
Overtrue\LaravelLang\TranslationServiceProvider::class,Last modified config/app.config Medium locale:
'locale' => 'zh-CN',3: take Faker The filling class configuration is modified to :
'faker_locale' => 'zh_CN',In this way, the basic configuration is completed , Let's start setting the migration data table , Create build models and migration files :
php artisan make:model User -mnext , In the frame of database/migrations The newly created user table... Is found in the folder user

In a up Write the information to create the database in the method of :
$table->bigIncrements('id');
// role
$table->unsignedInteger('role_id')->default(0)->comment(' role ID');
$table->string('username',100)->comment(' account number ');
$table->string('truename',50)->default(' Unknown ')->comment(' What a name ');
$table->string('password',255)->comment(' password ');
//nullable It can be for null
$table->string('email',50)->nullable()->comment(' mailbox ');
$table->string('phone',15)->default('')->comment(' Phone number ');
$table->enum('sex',[' sir ',' ma'am '])->default(' sir ')->comment(' Gender ');
$table->char('last_ip',15)->default('')->comment(' Sign in IP');
$table->timestamps();
// Soft delete Generate a field deleted_at Field
$table->softDeletes();Then perform the migration file at this time :
php artisan migratehere , Such error messages may occur

We need to be in app->Providers->AppServiceProvider Medium boot Use in
use Illuminate\Support\Facades\Schema;
public function boot()
{
Schema::defaultStringLength(191);
}Then you can continue to execute the migration command

Last , We started using Faker Fill in the data
Create user's fill file
php artisan make:seeder UserSeederhere , We need to be in user Use... In the model layer
protected $guarded = [];Otherwise , Will not be able to fill the data
next , We generate a data factory
php artisan make:factory UserFactory -m /Userstay UserFactory.php Modify the data filling the file in the file
'username' => $this->faker->userName,
'password' => bcrypt('admin'),
'truename' => $this->faker->name,
//password_hash('admin666')
'email' => $this->faker->unique()->safeEmail,
'phone' => $this->faker->unique()->phoneNumber,stay userseeder.php In file :
// Reset table data
User::truncate();
User::factory()
// Generate 100 Data
->count(100)
//->hasPosts(1)
->create();
// modify id=1 user
User::where('id',1)->update(['username'=>'admin']);Last in DatabaseSeeder.php Modify the total call
$this->call([
UserSeeder::class
]);Execute the fill command
php artisan migrate:fresh --seedHere we are , Filling complete
laravel8 Fill in the data _SunNang The blog of -CSDN Blog _laravel8 Data filling
边栏推荐
- CSDN cerebral palsy bug has wasted nearly two hours of hard work
- "APEC industry +" biov Tech talks about the cross-border of Chinese biotechnology enterprises and "Pratt & Whitney Kangyu" | apec-hub public welfare
- Use of pytorch tensorboard
- Part 34 of SAP ui5 application development tutorial - device adaptation of SAP ui5 application based on device type
- Technology Review: Interpretation of cloud native architecture trend in 2022
- Try with resource close resource flow
- CVPR2021-Semi-supervised Domain Adaptation based on Dual-level Domain Mixing for Semantic Segmentati
- Double recursion in deep analysis merge sort
- Day17 (set)
- Use of collection
猜你喜欢
SAP ui5 beginner tutorial No. 27 - unit test tool quNit introduction trial version for SAP ui5 application
MySQL transaction learning notes (I) first encounter
Tutorial 35 of SAP ui5 application development - how to deploy locally developed SAP ui5 applications to ABAP server for trial reading

CVPR2021-Semi-supervised Domain Adaptation based on Dual-level Domain Mixing for Semantic Segmentati
Summary of 6 common methods of visual deep learning model architecture

By inserting a section break, the word header, footer, and page number can start from any page

Double recursion in deep analysis merge sort

Semantic segmentation cvpr2019-advance: advantageous enterprise minimization for domain adaptation in semantic segmentation
Linus' speech recordings, which were lost in 1994, were made public

ERDAS 9.2 installation tutorial
随机推荐
How to add an external header file in vs?
What changes have taken place in the project file after SAP ui5 tools ran the Fiori add deploy config command
The e-book "action guide for large organizations to further promote zero code application platform" was officially released!
Linus' speech recordings, which were lost in 1994, were made public
Makefile Foundation
SAP ui5 beginner tutorial 25 - using proxy server to solve the cross domain problem of SAP ui5 application accessing remote OData service trial version
SSRF-lab
Synchonized introduction
Guava-IO
Volatile and JMM memory models
The locally developed SAP ui5 application is deployed to the ABAP server to perform error analysis
Pointer array function combination in C language
Go Basics
Fundamentals of C language
What are the reasons why most webmasters choose Hong Kong site group servers?
Japanese fifty tone diagram
Is the securities account of Qiantang education safe? Is it reliable?
I got to know data types and function variables for the first time. I learned data types and function variables together today and yesterday, so I saved them in the first issue to record.
SAP ui5 date type sap ui. model. type. Analysis of date parsing format
CVPR2021-Semi-supervised Domain Adaptation based on Dual-level Domain Mixing for Semantic Segmentati