/** * Let's do this ... * @param $template string The path or url to a tasty cheesecake template * @param $params array Optional parameters that are merged with existing * params from a cheesecake.json file :O * @param $options array Options */ public function __construct($template, array $params = [], array $options = []) { $this->template = $template; $this->templateType = $this->detectTemplateType($template); $this->params = $params; $this->output = $this->getoa($options, self::OPT_OUTPUT, '.'); $this->noInteraction = $this->getoa($options, self::OPT_NO_INTERACTION, false); $options = ['pragmas' => [\Mustache_Engine::PRAGMA_FILTERS]]; $this->mustache = new \Mustache_Engine($options); $this->mustache->addHelper('string', ['toLowerCase' => function ($value) { return Stringy::toLowerCase($value); }, 'toUpperCase' => function ($value) { return Stringy::toUpperCase($value); }, 'upperCaseFirst' => function ($value) { return Stringy::upperCaseFirst($value); }, 'lowerCaseFirst' => function ($value) { return Stringy::lowerCaseFirst($value); }, 'humanize' => function ($value) { return Stringy::humanize($value); }, 'camelize' => function ($value) { return Stringy::camelize($value); }, 'upperCamelize' => function ($value) { return Stringy::upperCamelize($value); }, 'slugify' => function ($value) { return Stringy::slugify($value); }]); $this->fs = new Filesystem(); }
public function getSlugAttribute($value) { if (!$value) { $value = S::slugify($this->name); $nodes = Node::where('slug', $value); if ($nodes->count() > 0) { $value = $this->id . '-' . $value; $this->slug = $value; $this->save(); return $value; } else { $this->slug = $value; $this->save(); return $value; } } else { return $value; } }
public static function bootHasSlug() { static::saving(function ($model) { $model->{static::$slugColumn} = StaticStringy::slugify($model->{static::$slugField}); }); }
public static function findByName($name) { return static::where('slug', S::slugify($name))->first(); }
/** * @dataProvider slugifyProvider() */ public function testSlugify($expected, $str, $replacement = '-') { $result = S::slugify($str, $replacement); $this->assertInternalType('string', $result); $this->assertEquals($expected, $result); }
public function slugify($string, $replacement = '-') { return Stringy::slugify($string, $replacement); }
public function postChangeUsername(ChangeUsername $request) { $username = $request->input('username'); Auth::user()->update(['username' => $username, 'slug' => S::slugify($username), 'name_changes' => 1]); flash()->success('Vartotojo vardas sėkmingai pakeistas!'); return redirect('/'); }
public function setSlugAttribute($value) { $this->attributes['slug'] = StaticStringy::slugify($value); }
/** * Display robot name * * @return string|array */ public function robotName() { $output = $this->data['robot_name']; // Fetch tag parameter $options = $this->get('slugify'); // Check for slugify option if ($options === 'true') { return Stringy::slugify($output); } else { return $output; } }
private function getRole($role) { switch (S::slugify($role)) { case 'rezie': return Entities\Author::DIRECTOR; case 'scenar': return Entities\Author::WRITER; case 'hudba': return Entities\Author::COMPOSER; case 'kamera': return Entities\Author::CAMERA; case 'hraji': return Entities\Author::ACTOR; } throw new InternalException("Author role {$role} undefined."); }
public function getSlugAttribute($value) { if (!$value) { $value = S::slugify($this->username); $nodes = User::where('slug', $value); if ($nodes->count() > 0) { $value = $this->id . '-' . $value; $this->slug = $value; $this->save(); return $value; } else { $this->slug = $value; $this->save(); return $value; } } else { $slugs = User::where('slug', $value)->count(); $slug = $value; if ($slugs > 0) { $slug = S::slugify($this->username) . $this->id; $this->slug = $slug; $this->save(); } return $slug; } }
/** Создание имени для миграции */ public function makeMigrationName($name, $num = null) { return ($num ?: date('YmdHis')) . '_' . StaticStringy::slugify($name, '_') . '.php'; }