/** * Display all items */ public function getIndex() { $items = $this->object->all(); $variable = String::plural($this->model); $variable = String::lower($variable); return View::make($this->page . '.index')->with($variable, $items); }
/** * Check if an array has a given key */ public static function has($array, $key) { // Generate unique string to use as marker $unfound = StringMethods::random(5); return static::get($array, $key, $unfound) !== $unfound; }
/** * Tries to find the right class to call * * @param string $callingClass The original class * @param string $method The method * @param array $arguments The arguments * * @return string The correct class */ protected static function computeClassToCall($callingClass, $method, $arguments) { if (!StringMethods::find($callingClass, 'Underscore\\Types')) { if (isset($arguments[0])) { $callingClass = Dispatch::toClass($arguments[0]); } else { $callingClass = Method::findInClasses($callingClass, $method); } } return $callingClass; }
/** * Add a plain image * * @param string $image */ protected function addPlainImage($image) { $image = $this->present($image); // Else just assume we were given an image path if (!String::contains($image, '<img')) { $image = HtmlImage::create($image); } return $this->nest(Element::create('li', $image)->addClass('thumbnail')); }
/** * Whether the link is special or not * * @return boolean */ public function isSpecialUrl() { foreach ($this->hidden as $hidden) { if (StringMethods::startsWith($this->href, $hidden)) { return true; } } return false; }
/** * Some shortcuts */ public function __call($method, $parameters) { // Resource verbs if (String::endsWith($method, 'Resource')) { $verb = String::remove($method, 'Resource'); $parameters = Arrays::prepend($parameters, $verb); return call_user_func_array(array($this, 'resource'), $parameters); } return parent::__call($method, $parameters); }