laravel 项目起步

  • 建表

    1
    php artisan make:migration create_users_table --create=users
  • 建立表的字段

    1
    php artisan make:migration add_votes_to_users_table --table=users #给users表增加votes字段
  • 建立模型

    1
    php artisan make:model name
  • 模型与user的互相绑定

    1
    写方法 hasmany belengsto......
  • 建立代理类

    1
    2
    make:repository
    make:bindings
  • 在controler里面设置代理类

    1
    2
    3
    4
    5
    6
    7
    public function (CourselistRepository $repository)
    {
    $this->repository = $repository;
    $this->middleware('auth',['except'=>['index','show']]);
    # code...
    }
  • index 显示 然后跳转到 create ceate里面会传递一些需要的东西

  • creat 会跳转到 store
  • 设置 request 设置验证用户的输入条件
    1
    php artisan make:request