/** * Sets a single slug attribute value. * @param string $slugAttribute Attribute to populate with the slug. * @param mixed $sourceAttributes Attribute(s) to generate the slug from. * Supports dotted notation for relations. * @param int $maxLength Maximum length for the slug not including the counter. * @return string The generated value. */ public function setSluggedValue($slugAttribute, $sourceAttributes, $maxLength = 240) { if (!isset($this->{$slugAttribute}) || !strlen($this->{$slugAttribute})) { if (!is_array($sourceAttributes)) { $sourceAttributes = [$sourceAttributes]; } $slugArr = []; foreach ($sourceAttributes as $attribute) { $slugArr[] = $this->getSluggableSourceAttributeValue($attribute); } $slug = implode(' ', $slugArr); $slug = substr($slug, 0, $maxLength); $slug = Str::slug($slug, $this->getSluggableSeparator()); } else { $slug = $this->{$slugAttribute}; } return $this->{$slugAttribute} = $this->getSluggableUniqueAttributeValue($slugAttribute, $slug); }
/** * Set current object url. * * @param string $pageName * @param Controller $controller */ public function setUrl($pageName, Controller $controller) { $params = ['event_id' => $this->id . '-' . Str::slug($this->name)]; return $this->url = $controller->pageUrl($pageName, $params); }
/** * Generate a URL friendly "slug" from a given string. * * @param string $title * @param string $separator * @return string * @static */ public static function slug($title, $separator = '-') { //Method inherited from \Illuminate\Support\Str return \October\Rain\Support\Str::slug($title, $separator); }