public function getValue($source) { $value = ''; if (array_key_exists('feature', $source)) { $values = Feature::where('id', '=', $source['feature']); if ($values->count()) { $value = $values->first()->feature; } } return $value; }
/** * post feature * * @return json */ public function postFeature() { $id = isset($_GET['id']) ? (int) $_GET['id'] : false; $features = Feature::where('module_id', '=', $id)->get(); $data = array(); foreach ($features as $key => $value) { $item = array("id" => $value->id, "name" => $value->name_feature); array_push($data, $item); } echo json_encode($data); }