where('name', 'like', '%'.$params['search'].'%', 'and') ->where('fee_code', 'like', '%'.$params['search'].'%', 'or' ); }); $list = $list->where('is_active','=',1); $sorting = $params['sorting']; if(count($sorting) > 0) { $list = $list->orderBy($sorting['field'],$sorting['sort_order']); } if($pagination == true){ return $list->paginate($params['page_size']); }else return $list->get(); } public function store($request) { $currentUser = CurrentUserHelper::get_currentAdmin(); $this->top_up = new TopUp; $uuid = new UuidHelper; $this->top_up->topup_uuid = $uuid->generate_uuid1(); $this->top_up->fee_code = $request->get('fee_code'); $this->top_up->name = $request->get('name'); $this->top_up->amount = $request->get('amount'); $this->top_up->type = $request->get('type'); if ($this->top_up->save()) { return $this->top_up->topup_id; } else { return false; } } public function update($request) { $this->top_up = TopUp::where([ ['topup_uuid',$request->topup_uuid] ])->first(); $this->top_up->amount = $request->amount; $this->top_up->type = $request->type; $this->top_up->name = $request->name; if ($this->top_up->save()) { return $this->top_up; } else { return false; } } public function check($id) { $this->top_up = TopUp::where([ ['topup_uuid',$id] ])->first(); return $this->top_up ? $this->top_up : false; } public function getByField($field,$value) { $this->top_up = TopUp::where($field,$value); return $this->top_up->get(); } public function delete($uuid) { $currentUser = CurrentUserHelper::get_currentAdmin(); if(is_array($uuid)) { $this->top_up = TopUp::whereIn('topup_uuid',$uuid) ->update([ 'is_active' => 0, 'updated_by' => $currentUser->admin_id ]); if($this->top_up) return true; else return false; } else { $this->top_up = TopUp::where('topup_uuid',$uuid)->first(); $this->top_up->updated_by = $currentUser->admin_id; $this->top_up->is_active = 0; if ($this->top_up->save()) return true; else return false; } } public function getDetailsWhereIn($field,$value,$relationship = null) { if($relationship) { $details = TopUp::with($relationship)->whereIn($field,$value)->get(); } else { $details = TopUp::whereIn($field,$value)->get(); } return $details->toArray(); } }