$xk_whitelist = DB::table('mld_xk_whitelist')->where(['kh_type'=>1,'cstm_id'=> $member_info->cstm_id])->orderByRaw(DB::raw('FIELD(type, 2,3,0,1) asc'))->get()->toArray();
使用with查询某个订单号及其的状态 GoodsOrder::where($where) ->select('uid','userinfo_id','platform_type','order_id','account_uid','order_time','goods_id','goods_name','pict_url','pay_money','num','commission_rate','commission','rights_cash','calculate_time') ->orderBy('order_ti...
用orderByRaw 来实现 ->orderByRaw(\DB::raw("FIELD(字段, 3)")最后得到的sql就会是 select * from 表 where 条件 order by FIELD(字段,3)
// 排序索引 $column=$orderArr['column']; // 排序类型 升还是降 $dir=$orderArr['dir']; // 排序字段 $orderField=$request->get('columns')[$column]['data']; $data= \App\Models\Show::where('name','like',"%$search%")->offset($start)->limit($length) ->orderBy($orderField,$dir...
The field under validation must be a value after a given date. The dates will be passed into the strtotime PHP function:1'start_date' => 'required|date|after:tomorrow'Instead of passing a date string to be evaluated by strtotime, you may specify another field to compare against the date:...
$builder= $model->orderBy('id','desc'); $input=Input::all();foreach($inputas$field =>$value) {if(empty($value)) {continue; }if(!isset($this->fields_all[$field])) {continue; } $search= $this->fields_all[$field]; $builder->whereRaw($search['search'], [$value]); ...
In this example, the post_id field will automatically be set on the inserted comment.If you need to save multiple related models:1$comments = array( 2 new Comment(array('message' => 'A new comment.')), 3 new Comment(array('message' => 'Another comment.')), 4 new Comment(array('...
In last version of laravel im using two models: contact document, which belongsTo contact by contact_id field For order by relation field (for example last_name) im using (may be isnt correct , but not anything about it in documentation)...
findWhereBetween($field, array $where, $columns = [*]) create(array $attributes) update(array $attributes, $id) updateOrCreate(array $attributes, array $values = []) delete($id) deleteWhere(array $where) orderBy($column, $direction = 'asc'); with(array $relations); has(string $relat...
}else{$query->where(function($query)use($keyword) {foreach(['archives.title', 'archives.title_pinyin']as$field) {$query->orWhere($field, 'regexp',$keyword); } }); } }if($sort&&$order) {$query->orderBy($sort,$order);