librarySeating

系统环境

OS: Mac OS X 10.10.5
安装PHP 7.1

brew install php71 --with-pear

安装Composer

curl -sS https://getcomposer.org/installer | php 
mv composer.phar /usr/local/bin/composer 

安装辅助工具

新建Laravel项目

composer create-project --prefer-dist laravel/laravel librarySeating "5.5.*"

初始化

修改config/app.php中的
'url' => env('APP_URL', 'http://localhost:8000'),
'timezone' => 'PRC',
'locale' => 'zh',

同步到GitHub仓库

创建仓库

初次推送

git init
git add -A
git commit -m "first commit"
git remote add origin https://github.com/patientkitty/librarySeating.git
git push -u origin master

启动站点

在Laravel项目目录下运行

php artisan serve Laravel development server started on [http://localhost:8000](http://localhost:8000)

配置数据库链接

编辑环境变量 .env文件

创建类(Model)并关联到数据库

创建新类,存放在APP\Models目录,同时创建数据库迁移(-m)

php artisan make:model Models/Seat -m

编辑database\migrations下对应文件

public function up()
    {
        Schema::create('seats', function (Blueprint $table) {
            $table->increments('id');
            $table->timestamps();
            $table->string('seat_code');
            $table->string('seat_desc'->nullable());
            $table->string('qrcode');
            $table->string('created_by');
        });
    }

执行数据库迁移

php artisan migrate

填充测试数据

在app/database/seeds下创建一个名为SeatTableSeeder.php的文件,增加如下:

class SeatTableSeeder extends Seeder {
    public function run()
    {
       for($i=1;$i<=3;$i++){
            Seat::create([
                'seat_code' => 'test00' . $i,
                'seat_desc' => 'test seat 00' . $i,
                'qrcode' => 'qrcode00' . $i,
                'created_by' => 'Sam Shen',
            ]);
    }
}

然后在DatabaseSeeder.php中增加:

$this->call('SeatTableSeeder');

刷新项目中的类文件

composer dump-autoload 

之后就真正地向数据库填充数据:

php artisan db:seed

你可以查看数据库,会发现seats表中多了三条记录。


使用weui(微信界面风格)

加载weui库到public目录

NYUSH1499LP-MX:public ss9545$ git clone https://github.com/weui/weui.git

在public目录下创建css、js、font、images目录
拷贝weui.min.css到public\css目录


创建View

创建Controller

php artisan make:controller MyNewController
  1. 将会在/my_laravel/app/http/controllers目录下创建一个新的Controller文件

修改数据库字段类型

安装依赖

To add this dependency open the composer.json at the root of your project (in the same level as app, public etc.) and in the require section add the doctrine/dbal package like:

"require": {
    "laravel/framework": "4.1.*",
    "doctrine/dbal": "v2.4.2"
},

Save the file and run composer update

php artisan change_exports_date_type

in the migration file up function

 Schema::table('exports', function (Blueprint $table) {
            $table->date('date')->change();
        });
php artisan migrate

加载基本页面元素

祖传CSS

https://pan.baidu.com/s/1JhweZQKKFEmfbWO3PjXYOg
复制到public\css目录下

祖传layouts

https://pan.baidu.com/s/18A39UvcsXMTNH0Xk4If91g
在resources\views目录下创建layouts目录,并复制文件

祖传参考view

https://pan.baidu.com/s/1ik4azstF1kqnhBHVzXRdFg
仅供参考

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 136,264评论 19 139
  • <extension>123</extension><mime-type>application/vnd.lotu...
    张不二01阅读 4,960评论 0 0
  • 一. 说明 以下内容大部分引用Laravel China社区的文章 - 分享下团队的开发规范 ——《Laravel...
    knghlp508阅读 12,381评论 0 28
  • php+mysql+apache+centos 编译安装 领导要求先保证php环境稳定,然后再去考虑其他,例如性能...
    dnaEMx阅读 7,009评论 1 16
  • 静静的夏末夜晚,淡淡的一杯清茶 手捧一本书的懒散也没有影响了我的好心情 窗外细雨朦胧,打湿思绪也不会使时间怅然若梦...
    鹰叔阅读 1,630评论 8 6

友情链接更多精彩内容