Home >Backend Development >PHP Tutorial >Laravel study notes one

Laravel study notes one

WBOY
WBOYOriginal
2016-08-08 09:31:34927browse

1. Create a new file

php artisan generate:seed page

Create a new app/database/seeds/PageTableSeeder.php file.

php artisan generate:model article

Create a new app/models/Article.php file.

php artisan generate:view admin._layouts.default

Create a new app/views/admin/_layouts/default.blade.php file.

2. Install the composer component

Add the component name and version number in require or require-dev of composer.json:

"edvinaskrucas/notification": "3.0.1"

Execute composer update in the root directory of the application Command

Add a line in the providers of app.php:

  'KrucasNotificationNotificationServiceProvider',

Add a line in the aliases of app.php:

  'Notification'   => 'KrucasNotificationFacadesNotification',

3. Prompt class not found The processing method

composer dump-autoload

4. After creating the folder, add a new line of folder path in the autoload classmap of composer.json, so that the files in it can be found.

5.

Sentry::check() Check whether the user is logged in

Input::get('email') Obtain the data obtained by the user's get method

Execute the command php artisan serve and run lavarel development server.

Redirect ::route('admin.login')

Redirect::to('eadmin/products')

HTML::link('accounts/newaccount', 'Registration', array('class'=>'default -btn'))

Form::open(array('url'=>'accounts/signin'))

6. Eloqyent

class Page extends Eloquent {

//Use users database by default

protected $table = 'myusers'; //If the value of the tabel attribute is specified, the table named table will be used.

//The primary key of the default table is id

protected $primaryKey ='ids'; //Change the primary key name by specifying primaryKey

//By default, each database has updated_at and created_at fields

You can set

protected $timestamps = false; Cancel these two fields

protected $appends = array("",""); //Fields that need to be used but are not in the database,

protected $hidden = array("",""); //Fields that need to be hidden are restricted to attribute data that can appear in arrays or JSON format

Use SoftDeletingTrait; //Enable the soft deletion function. When deleting data using a model instance, the data will not be deleted from the database. The value is to add a deleted_at timestamp. .

protected function getDateFormat() { return 'U'; } //This method can be overridden to customize the timestamp format

}

The above introduces Laravel study notes 1, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn