public static function get_($feed_id) { return FeedField::join(FeedRel::getTableName(), FeedRel::getField('feed_field_id'), '=', FeedField::getField('id'))->where(FeedRel::getField('feed_id'), $feed_id)->select(FeedField::getField('*'))->distinct()->get(); }
public function postDeletefeed() { $id = Input::get('id'); Feed::where('id', $id)->delete(); FeedPost::where('feed_id', $id)->delete(); FeedRel::where('feed_id', $id)->delete(); return Redirect::to('feed'); }
public static function withDinamicFields($post) { $values_SQL = "(SELECT * FROM " . FeedFieldValue::getTableName() . " WHERE " . FeedFieldValue::getField("lang_id") . " IN (0," . WebAPL\Language::getId() . ") AND " . FeedFieldValue::getField("post_id") . " = {$post->id}) as sb"; $fields = FeedField::leftJoin(DB::raw($values_SQL), "sb.feed_field_id", "=", FeedField::getField("id"))->select(FeedField::getField("fkey"), "sb.value", FeedField::getField("get_filter"))->join(FeedRel::getTableName(), FeedRel::getField('feed_field_id'), '=', FeedField::getField('id'))->join(FeedPost::getTableName(), FeedPost::getField('feed_id'), '=', FeedRel::getField('feed_id'))->where(FeedPost::getField('post_id'), '=', $post->id)->remember(SettingsModel::one('cachelife'))->get(); foreach ($fields as $field) { if ($field->get_filter && method_exists('DinamicFields', $field->get_filter)) { $post[$field->fkey] = call_user_func(array('DinamicFields', $field->get_filter), $field, $post); } else { $post[$field->fkey] = $field->value; } } return $post; }