public function getSearch() { $categoryId = Input::get('categoryid'); $search = Input::get('query'); $objects = null; if ($categoryId) { // Category Image if ($featuredImageId = ObjectMeta::getValue($categoryId, '_featured_image')) { $featuredImageUrl = getImageSrc($featuredImageId, 'thumbnail'); } // Get objects where in category $objects = Object::Where('type', 'object_type')->whereExists(function ($query) use($categoryId) { $query->select(DB::raw(1))->from('object_meta')->whereRaw(DB::getTablePrefix() . 'object_meta.object_id = ' . DB::getTablePrefix() . 'objects.id')->where('meta_key', '_category_id')->where('meta_value', $categoryId); })->select(DB::raw('substr(name, 14) as field_name'))->get()->toArray(); $types = array_map(function ($v) { return $v['field_name']; }, $objects); if (!empty($types)) { $objects = Object::whereIn('type', $types); } } if ($objects) { $objects = $objects->select(array('objects.id', DB::raw('"/uploads/' . $featuredImageUrl . '"' . ' as featured_image'), 'objects.name', 'objects.title', 'objects.excerpt'))->get(); } return $objects; }
} echo '</tbody>'; echo '<table>'; echo '<style>td{padding: 2px 5px;}</style><pre>'; break; case 'coordinates': $coordinates = array(); foreach ($items as $k => $item) { if (!isset($item['_field_address-location-k']['value']) || !trim($item['_field_address-location-k']['value']) || !isset($item['_field_address-location-g']['value']) || !trim($item['_field_address-location-g']['value'])) { $coordinates[] = $k; } } if (empty($coordinates)) { die('No address error!'); } $items = \App\Object::whereIn('id', $coordinates)->select('id', 'title', 'type')->get()->toArray(); echo '<h2>' . count($items) . ' Objects without coordinates:</h2>'; echo '<table style="border-color: #048108 !important;border-spacing: 0;" border="1" cellpadding="0">'; echo '<thead style="background: #048108; color: white; font-weight: bold;">'; echo '<tr>'; echo '<td style="text-align: center">#</td>'; echo '<td>Type</td>'; echo '<td>Title</td>'; echo '<td>Object ID</td>'; echo '</tr>'; echo '</thead>'; echo '<tbody>'; foreach ($items as $k => $item) { echo '<tr>'; echo '<td style="text-align: center">' . ($k + 1) . '</td>'; echo '<td>' . $item['type'] . '</td>';