public function saveLocations($groupId, $locations)
 {
     Rule::where('group_id', '=', $groupId)->delete();
     if (count($locations)) {
         foreach ($locations as $location) {
             $ruleModel = new Rule();
             $strResult = json_encode($location);
             $ruleModel->group_id = $groupId;
             $ruleModel->rule = $strResult;
             $ruleModel->save();
         }
     }
 }
Exemple #2
0
 /**
  * Get GroupFields base on rule.
  *
  * @param $options
  *
  * @return array
  */
 public function getGroupByRule($options)
 {
     $arrResult = array();
     $rules = Rule::all();
     foreach ($rules as $rule) {
         $params = (array) json_decode($rule->rule);
         $defaultMatch = true;
         foreach ($params as $item) {
             $match = $this->matchRule((array) $item, $options);
             $defaultMatch = $defaultMatch && $match;
         }
         if ($defaultMatch) {
             $arrResult[$rule->group_id] = $rule->group_id;
         }
     }
     return $arrResult;
 }
 /**
  * @param Group $group
  *
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function edit(Group $group)
 {
     $fields = $group->getListFields();
     $locations = Rule::where('group_id', '=', $group->id)->get();
     return view('dynamicfield::admin.group.edit', compact('group', 'fields', 'locations'));
 }