when($params['search'], function ($query) use ($params) { return $query->where('title', 'like', '%'.$params['search'].'%', 'and') ->where('details', 'like', '%'.$params['search'].'%', 'or' ); }); $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->terms_and_privacy = new TermsAndPrivacy; $uuid = new UuidHelper; $this->terms_and_privacy->tp_uuid = $uuid->generate_uuid1(); $this->terms_and_privacy->title = $request->get('title'); $this->terms_and_privacy->details = $request->get('details'); $this->terms_and_privacy->type = $request->get('type'); $this->terms_and_privacy->created_by = $currentUser->admin_id; if ($this->terms_and_privacy->save()) { return $this->terms_and_privacy->tp_id; } else { return false; } } public function update($request) { $currentUser = CurrentUserHelper::get_currentAdmin(); $this->terms_and_privacy = TermsAndPrivacy::where([ ['tp_uuid',$request->tp_uuid] ])->first(); $this->terms_and_privacy->title = $request->title; $this->terms_and_privacy->details = $request->details; $this->terms_and_privacy->type = $request->type; $this->terms_and_privacy->updated_by = $currentUser->admin_id; if ($this->terms_and_privacy->save()) { return $this->terms_and_privacy; } else { return false; } } public function getByField($field,$value) { $this->terms_and_privacy = TermsAndPrivacy::where($field,$value); return $this->terms_and_privacy->get(); } public function delete($uuid) { $currentUser = CurrentUserHelper::get_currentAdmin(); if(is_array($uuid)) { $this->terms_and_privacy = TermsAndPrivacy::whereIn('tp_uuid',$uuid) ->update([ 'is_active' => 0, 'updated_by' => $currentUser->admin_id ]); if($this->terms_and_privacy) return true; else return false; } else { $this->terms_and_privacy = TermsAndPrivacy::where('tp_uuid',$uuid)->first(); $this->terms_and_privacy->updated_by = $currentUser->admin_id; $this->terms_and_privacy->is_active = 0; if ($this->terms_and_privacy->save()) return true; else return false; } } public function getDetailsWhereIn($field,$value,$relationship = null) { if($relationship) { $details = TermsAndPrivacy::with($relationship)->whereIn($field,$value)->get(); } else { $details = TermsAndPrivacy::whereIn($field,$value)->get(); } return $details->toArray(); } public function check($id) { $this->terms_and_privacy = TermsAndPrivacy::where([ ['tp_uuid',$id] ])->first(); return $this->terms_and_privacy ? $this->terms_and_privacy : false; } public function getAllActive() { $return1 = "
"; $return2 = ""; $lastPart = ""; $this->terms_and_privacy = TermsAndPrivacy::where("is_active",1)->get(); foreach ($this->terms_and_privacy as $key => $value) { if ($value->type == 1){ $return1 .= "$value->title
$value->details
"; }else{ $return2 .= "$value->title
$value->details
"; } } return $return1.$return2.$lastPart; } }