【Laravel】laravel之个人学习文档

laravel之个人学习文档

 

Artisan 命令

 

命令说明
php artisan key:generate生成 App Key
php artisan make:controller生成控制器
php artisan make:model生成模型
php artisan make:policy生成授权策略
php artisan make:middleware生成中间件
php artisan make:seeder生成 Seeder 文件
php artisan migrate执行迁移
php artisan migrate:rollback回滚迁移
php artisan migrate:refresh重置数据库
php artisan db:seed填充数据库
php artisan tinker进入 tinker 环境
php artisan route:list查看路由列表
php artisan list查看所有artisan命令列表

 

在blade模板打印变量信息

{{ dump('test') }}

 

 

# 生成资源控制器命令
php artisan make:controller PhotoController --resource

# 生成 console 命令
php artisan make:console consoleName
#如果需要指定路径 例如 放在Web目录下
php artisan make:console Web\consoleName

# console 命令执行
php artisan $signature

 

Laravel 数据库查询篇

  场景:查询某一字段内容的集合,例:查询性别为男性的所有姓名

$users = Users::where('sex', 1)->pluck('username');

 得到的结果为:

array(
    '1' => '张三'
    '2' => '李四'
    '3' => '王五'
    '4' => '李小六'
    '5' => '赵五'
)

 

Laravel分页方法:

$tests->count()   //当前页显示个数
$tests->currentPage() //当前页数
$tests->hasMorePages()  //判断是不是还有更多页,比如最后一页她就不显示,不然就显示1
$tests->lastPage() //最后一页,也是总页数(在 simplePaginate 中无法使用)
$tests->nextPageUrl() //下一页的连接
$tests->perPage()  //定义的每页个数
$tests->previousPageUrl() //上一页连接
$tests->total() //总数据量,就是总记录数(在 simplePaginate 中无法使用)
$tests->url($page)  //$page是你想跳转到的页数,你也可以同时用获取总页数,然后用url定义到最后一页

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值