1、php artisan 查看命令列表

2、php artisan make:controller ArticleController 命令 创建控制器

3、创建数据库迁移表

创建文章表

php artisan make:migration create_articles_table

Schema::create('articles', function (Blueprint $table) {
$table->increments('id');
$table->string('title',100)->default('');
$table->text('content');
$table->integer('user_id')->default(0);
$table->timestamps();
});
 
开始迁移 如果migration表里面有 就执行迁移没有的 
 php artisan migrate  
如果报错 去config/database  utf8mb4改为utf8
 
4、php artisan make:model Article
 
Article 模块
// 默认对应articles表
class Article extends Model
{
//
protected $table = "article";
}
 
5、tinker  php artisan tinker
设置时区
config app.php
'timezone' => 'UTC'
添加
$art = new \App\Article()
$art->title = "this is title"
$art->content = "this is content"
$art->save()
查看 通过id where
\App\Article::find(2)
\App\Article::where('title','gg')->first()
/*先查找 在修改*/
$art->title = 'gg2'
$art->save()
 
$art = \App\Article::find(2)
$art->delete()
 
\App\Article::where('title','gg')->get()
 
 

public function list() {
//模型查找
$art = \App\Article::orderBy('created_at', 'desc')->get();
return response()->json(['status'=>1,'msg'=>'success','data'=>$art]);
}
 
  
 
 

laravel 命令行创建controller 创建数据库表迁移 创建module的更多相关文章

  1. 使用CMD命令行来对MySQL数据库执行迁移、备份、恢复

    1. 导出数据库数据   "C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqldump.exe" -u root -p123abc ...

  2. MySQL命令行导出、导入数据库,备份数据库表

    MySQL导出数据库/数据表 1.首先,将你MySQL安装目录,例如C:\Program Files\MySQL\MySQL Server 5.7\bin添加到你的系统环境变量PATH中: 2.导出数 ...

  3. (喷血分享)利用.NET生成数据库表的创建脚本,类似SqlServer编写表的CREATE语句

    (喷血分享)利用.NET生成数据库表的创建脚本,类似SqlServer编写表的CREATE语句 在我们RDIFramework.NET代码生成器中,有这样一个应用,就是通过数据库表自动生成表的CREA ...

  4. 利用.NET生成数据库表的创建脚本,类似SqlServer编写表的CREATE语句

    利用.NET生成数据库表的创建脚本,类似SqlServer编写表的CREATE语句 (喷血分享)利用.NET生成数据库表的创建脚本,类似SqlServer编写表的CREATE语句 在我们RDIFram ...

  5. 修改SQL Server数据库表的创建时间最简单最直接有效的方法

    说明:这篇文章是几年前我发布在网易博客当中的原创文章,但由于网易博客现在要停止运营了,所以我就把这篇文章搬了过来,因为这种操作方式是通用的,即使是对现在最新的SQL Server数据库里面的操作也是一 ...

  6. EF 学习系列二 数据库表的创建和表关系配置(Fluent API、Data Annotations、约定)

    上一篇写了<Entity Farmework领域建模方式 3种编程方式>,现在就Code First 继续学习 1.数据库表的创建 新建一个MVC的项目,在引用右击管理NuGet程序包,点 ...

  7. Mysql命令行备份与还原数据库操作实例

    无论是Windows还是Linux,都可以通过如下命令行形式备份Mysql数据库 备份命令: 在windows的DOS窗口命令行或linux的shell命令行,假设需要备份的数据库是advanced: ...

  8. 命令行客户端操作pg数据库常用操作

    登录 # su - postgres -c "psql" 或者 $psql -U user_name -d database_name -h serverhost psql (10 ...

  9. Oracle安装完成后,如何用命令行启动和关闭数据库?

    Oracle安装完成后,如何用命令行启动和关闭数据库? 解答: 打开:STARTUP [FORCE] [RESTRICT] [PFILE= filename] [OPEN [RECOVER][ dat ...

随机推荐

  1. 十二省NOI“省选”联考模测(第二场)A抽卡大赛

    /* dp维护整体的概率, 每次相当于回退一格然后重新dp一格 */ #include<cstdio> #include<algorithm> #include<iost ...

  2. css实现三角形标

    .iszb{ position: absolute;top: -75px;right:-75px;text-align: center;color: red; width: 150px;height: ...

  3. win10安装tomcat9

    环境:win10 64bit.tomcat 时间:2016年9月6日 15:11:47 一.下载tomcat 用浏览器打开tomcat官网:http://tomcat.apache.org/ 在左侧的 ...

  4. 关于CSS3属性transition的触发

    关于怎么触发transition的效果,前面有篇文章说过一次,<关于transition和animation>,而且在实际的项目生产中,也是一直这么使用的,因为明明知道直接添加class是 ...

  5. tomcat的一次请求过程

    Tomcat处理一个HTTP请求的过程 假设来自客户的请求为: http://tomcat.com/yy/index.jsp 首先 dns 解析tomcat.com机器,一般是ng服务器ip地址 然后 ...

  6. 使用swagger 生成 Flask RESTful API

    使用swagger 生成 Flask RESTful API http://www.voidcn.com/article/p-rcvzjvpf-e.html swagger官网 https://swa ...

  7. idea 控制台行数限制

    在本地进行测试时,会出现报错太多idea控制台被限制打印出来的日志被清楚的现象: idea改变控制台打印log限制的方法: 1. 点击 File ->Settings ->editor - ...

  8. 从一个异常探索spring autowired 的原理

    从一个异常探索autowired 的原理. 首先环境是这样的: public class Boss { @Autowired private Car car; } //@Component 加上这个注 ...

  9. idea 添加代码自动提示支持,已PHP扩展 swoole 为例

    1,下载代码支持包 => swoole-ide-helper-en => https://github.com/eaglewu/swoole-ide-helper.git 2,如果安装了 ...

  10. Asp.Net前台调用后台变量

    1.Asp.Net中几种相似的标记符号: < %=...%>< %#... %>< % %>< %@ %>解释及用法 答: < %#... %&g ...