/** * Get items matching the names exactly * * @return array */ public function byName() { // Request data $items = $this->getInput('names'); if (!is_array($items)) { $items = explode(',', $items); } $items = array_values(array_unique($items)); $language = $this->requestedLanguage(); // Grab the item ids that match the query $ids = Item::whereIn(DB::raw('CAST(name_' . $language . ' AS BINARY)'), $items)->lists('id'); return $this->items($ids); }
/** * Delete item * * @param array $data * @return int */ public function deleteItem($data) { $deleted_item = Item::whereIn('id', $data)->delete(); // Return number of rows deleted return $deleted_item; }