Giter Site home page Giter Site logo

blog's Introduction

laravel 练习项目

项目初始化

基本配置

  1. 时区 config/app.php timezone Aisa/changhai Aisa/chongqing PRC

laravel 环境

  1. clone项目后执行composer i;
  2. packagist,可以到该网站查找三方包
  3. 语言包 composer require caouecs/laravel-lang:dev-laravel58 拷贝zn-CN 到lang;
  4. packgist 搜索 Captcha 找到验证码相关库 composer require mews/captcha
  5. 配置 In Windows, you'll need to include the GD2 DLL php_gd2.dll in php.ini. And you also need include php_fileinfo.dll and php_mbstring.dll to fit the requirements of mews/captcha's dependencies.

数据表的迁移与填充

迁移文件操作

  1. 编写迁移文件 php artisan make:migration '迁移文件名字'
  2. 执行迁移文件 (第一次: php artisan migrate:install 生成迁移记录表)
    php artisan migrate 执行迁移文件中up方法
    php artisan migrate:rollback 执行迁移文件中down方法(同批次)

填充器(种子文件)创建与编写,seeds目录下

  1. php artisan make:seeder PaperTableSeeder 然后去该文件编写run方法添加模拟数据
  2. php artisan db:seed --class=PaperTableSeeder

联表查询

  1. 准备
    php artisan make:migration create_article_table
    php artisan make:migration create_author_table
    编写迁移文件
    php artisan migrate
    php artisan make:seeder ArticleAndAuthorTableSeeder
    php artisan db:seed --class=ArticleAndAuthorTableSeeder 如果报错找不到类执行composer dump-autoload 后再运行

  2. 写原始sql 语句
    select t1.id, t1.article_name, t2.author_name from article as t1 left join author as t2 on t1.author_id = t2.id

关联模型

  1. 创建模型
    php artisan make:model Home/Article
    php artisan make:model Home/Author

blog's People

Contributors

wangfan1007 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.