本文整理汇总了PHP中Slug::build方法的典型用法代码示例。如果您正苦于以下问题:PHP Slug::build方法的具体用法?PHP Slug::build怎么用?PHP Slug::build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Slug
的用法示例。
在下文中一共展示了Slug::build方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testBuildMethodThroughFacade
public function testBuildMethodThroughFacade()
{
$this->assertEquals('the_show_must_go_on', Slug::build('The Show Must Go On', '_'));
$this->assertEquals('ничего_на_свете_лучше_нету', Slug::build('Ничего на свете лучше нету', '_', 1, false));
$this->assertEquals('чем-бродить-друзьям-по-белу-свету', Slug::build('Чем бродить друзьям по белу свету', '-', 1, false));
$this->assertEquals('Тем_кто_дружен', Slug::build('Тем, кто дружен', '_', 1, true));
$this->assertEquals('Ne-strashny-trevogi', Slug::build('Не страшны тревоги...', '-', 2, true));
$this->assertEquals('nam_lyubye_dorogi_dorogi', Slug::build('Нам любые дороги дороги!', '_', 2, false));
}
示例2: reslug
/**
* Create or recreate slugs in a column.
*
* @param $fromColumn Column to work with. String from this column will be converted to a slug.
* @param bool $force When true, forces recreation of a slug, even if it exists.
* @return $this
*/
public function reslug($fromColumn = false, $force = false)
{
$slugColumn = config('seoslug.slugColumnName');
if ($fromColumn === false) {
$fromColumn = $this->slugFrom;
}
// If slug needs to be created or recreated
if (empty($this->{$slugColumn}) || $force) {
$this->{$slugColumn} = \Slug::build($this->{$fromColumn});
}
return $this;
}
示例3: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$table = $this->argument('table');
$column = $this->argument('column');
try {
$allRows = \DB::table($table)->select($column)->get();
foreach ($allRows as $row) {
\DB::table($table)->where($column, $row->{$column})->update([config('seoslug.slugColumnName') => \Slug::build($row->{$column})]);
}
} catch (Exception $e) {
$this->error($e->getMessage());
}
$this->info('Table ' . $table . 'has been reslugged successfully');
}