1. Database file .env is located
above the frame of the database is arranged laravel
red box indicates that the name of the database table
2. The model
<1> defined position
<2> Name Model
laravel frame for defining the model is not strictly, in the form of a table name (capitalized) .php's
Note: the model name you want to have associated with the database table name
and because it is associated with the database can not sub-directory management, put their name each table so there is no separate the need for sub-directory management
<3> to create the model
created by the form of the command line
php artisan make: model Member
will be created as models, above is the model has been successfully created
<4> Notes on defining the model
3.DB class in the controller the use of
DB class is a class frame provided by the database operation, the database table can operate all
steps of:
introducing class DB (DB use)
using the DB class DB :: table (table)
test
output
may also be used operating table model
" 1. "introduction member class
" 2 "there are two ways to use
<1> facade DB using the same mode of operation, in order to call the static method based form, this form of model does not require Examples of, for example:
Member: GET () :: Table equivalent to DB ( 'Member') -> GET ()
<2> Examples of models and then to use the class
For example: $ Model = new new Member ();
$ Model-> GET ();
selection criteria in two ways;
1. If the frame is carrying laravel method chosen arbitrarily
2. If you define a method, the choice of two kinds
Database and Model laravel framework
Guess you like
Origin blog.csdn.net/Ya_Tou945/article/details/105148305
Recommended
Ranking