![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
laravel5.6
Cheryl71
这个作者很懒,什么都没留下…
展开
-
php使用foreach返回数据时新增key, value
public function getNavItem(Request $request){ $arr = TasksData::selectRaw('year, season') ->distinct() ->orderBy('season', 'DESC') ->orderBy('year', 'ASC') ->get() ->toArra.原创 2021-05-24 16:52:38 · 383 阅读 · 0 评论 -
前后台实现编辑操作
前端 js后端 php+laravel5.6点击编辑按钮,跳出弹框<template> <b-modal ref="editModalRef" centered @ok="handleEditOk" title="案例修改" ok-title="提交" cancel-title="取消" ok-variant="primary" > <div class="form-group ro原创 2021-05-12 10:02:25 · 196 阅读 · 0 评论 -
前后台上传数据至数据库
如图,在input框内输入内容后,点击确认录入,传递数据给后台,后台接收后上传到数据库。前端代码<b-modal id="modal-add-task" ref="modal" title="案例录入" @ok="handleOk" @hidden="resetModal" ok-title="确认录入" cancel-title="取消"> <form ref="form" @submit.stop.prevent="handleSubmit"> &.原创 2021-05-10 18:01:38 · 701 阅读 · 0 评论 -
array_column()返回输入数组中某个单一列的值
array_column() 返回输入数组中某个单一列的值。语法:array_column(array,column_key,index_key)keydescriptionarray必需。规定要使用的多维数组(记录集)。可以是索引数组的列的整数索引,或者是关联数组的列的字符串键值。该参数也可以是 NULL,此时将返回整个数组(配合 index_key 参数来重置数组键的时候,非常有用)。column_key必需。需要返回值的列。index_key可选。用作返回.原创 2021-02-04 10:11:59 · 437 阅读 · 0 评论 -
封装方法groupedData($query1, $query2, $matchKeys)来筛选数据
/* * 功能:将两个key-value数组按给定keys匹配,并将匹配到的值拼接 用于数据对比 * $query1,key-value数组1 * $query2,key-value数组2 * $matchKeys,需要匹配的keys * 返回值,返回拼接后的数组 *///逻辑:遍历$query1, $query2,匹配$query1, $query2的键值,匹配$matchKeys中的键值,默认匹配失败。如果每一项都相等,则匹配成功。返回需要数据p原创 2021-02-04 10:04:56 · 100 阅读 · 0 评论 -
laravel报错:ErrorException(code: 0): Undefined offset: 2 at
发现是由于$matchKeys 的类型写错,导致数组下标未定义$matchKeys = [ 'device_model' => $device, 'map_id' => $map,];这种写法返回的是对象[object],期待的是数组array,写法:$matchKeys = ['device_model', 'map_id'];// array...原创 2021-02-04 10:00:34 · 1150 阅读 · 1 评论 -
使用前端传all,laravel怎么返回全部数据?
参考官方文档当满足条件 $sortBy 时,调用函数 function ($query, $sortBy) 返回数据$query = Byp::where('plat', '=', $plat) ->where('date', '=', $date) ->when($p_id!="all", function ($query) use ($p_id) { return $query->where("p_id", '=', $p_id); })原创 2021-02-04 09:53:11 · 245 阅读 · 0 评论