本文整理汇总了PHP中Slug::make方法的典型用法代码示例。如果您正苦于以下问题:PHP Slug::make方法的具体用法?PHP Slug::make怎么用?PHP Slug::make使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Slug
的用法示例。
在下文中一共展示了Slug::make方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: go
public function go()
{
//$feed = file_get_contents($_SERVER['DOCUMENT_ROOT'].'/_add-ons/wordpress/wp_posts.xml');
//$items = simplexml_load_string($feed);
$posts_object = simplexml_load_file($_SERVER['DOCUMENT_ROOT'] . '/_add-ons/wordpress/roobottom_old_posts.xml');
$posts = object_to_array($posts_object);
$yaml_path = $_SERVER['DOCUMENT_ROOT'] . '/_content/01-blog/';
foreach ($posts['table'] as $post) {
if ($post['column'][8] == "publish") {
$slug = Slug::make($post['column'][5]);
$slug = preg_replace('/[^a-z\\d]+/i', '-', $slug);
if (substr($slug, -1) == '-') {
$slug = substr($slug, 0, -1);
}
$date = date('Y-m-d-Hi', strtotime($post['column'][3]));
$file = $date . "-" . $slug . ".md";
if (!File::exists($yaml_path . $file)) {
$yaml = [];
$yaml['title'] = $post['column'][5];
$content = $post['column'][4];
$markdown = new HTML_To_Markdown($content, array('header_style' => 'atx'));
File::put($yaml_path . $file, YAML::dump($yaml) . '---' . "\n" . $markdown);
}
echo $slug . "-" . $date;
echo "<br/><hr/><br/>";
}
}
return "ok";
}
示例2: generateMarkerSlug
public function generateMarkerSlug()
{
$markers = Marker::all();
foreach ($markers as $marker) {
$marker->slug = \Slug::make($marker->name);
$marker->save();
}
}
示例3: getURL
/**
* Returns the URL for a given $taxonomy and $taxonomy_slug
*
* @param string $folder Folder to use
* @param string $taxonomy Taxonomy to use
* @param string $taxonomy_slug Taxonomy slug to use
* @return string
*/
public static function getURL($folder, $taxonomy, $taxonomy_slug)
{
$url = Config::getSiteRoot() . '/' . $folder . '/' . $taxonomy . '/';
$url .= Config::getTaxonomySlugify() ? Slug::make($taxonomy_slug) : $taxonomy_slug;
// if taxonomies are not case-sensitive, make it lowercase
if (!Config::getTaxonomyCaseSensitive()) {
$url = strtolower($url);
}
return Path::tidy($url);
}
示例4: run
public function run()
{
Category::create(['title' => 'Офисная бумага', 'alias' => Slug::make('Офисная бумага', '-'), 'image' => 'https://placeimg.com/640/480/tech', 'description' => 'бумага бумага бумага бумага ']);
Category::create(['title' => 'Ризография', 'alias' => Slug::make('Ризография', '-'), 'image' => 'https://placeimg.com/640/480/tech', 'description' => 'ручки ручки ручки ручки ручки ручки ручки ']);
Category::create(['title' => 'Картрижди', 'alias' => Slug::make('Картрижди', '-'), 'image' => 'https://placeimg.com/640/480/tech', 'description' => ' техника техника техника техника']);
$category = Category::create(['title' => 'Канцтовары', 'alias' => Slug::make('Канцтовары', '-'), 'image' => 'https://placeimg.com/640/480/tech', 'description' => ' техника техника техника техника']);
Category::create(['title' => 'Бумага для заметок', 'alias' => Slug::make('Бумага для заметок', '-'), 'image' => 'https://placeimg.com/640/480/tech', 'description' => ' техника техника техника техника', 'parent_id' => $category->id]);
Category::create(['title' => 'Дыроколы', 'alias' => Slug::make('Дыроколы', '-'), 'image' => 'https://placeimg.com/640/480/tech', 'description' => ' техника техника техника техника', 'parent_id' => $category->id]);
Category::create(['title' => 'Ежедневники', 'alias' => Slug::make('Ежедневники', '-'), 'image' => 'https://placeimg.com/640/480/tech', 'description' => ' техника техника техника техника', 'parent_id' => $category->id]);
Category::create(['title' => 'Полиграфические материалы', 'alias' => Slug::make('Полиграфические материалы', '-'), 'image' => 'https://placeimg.com/640/480/tech', 'description' => ' техника техника техника техника']);
Category::create(['title' => 'Офисная техника', 'alias' => Slug::make('Офисная техника', '-'), 'image' => 'https://placeimg.com/640/480/tech', 'description' => ' техника техника техника техника']);
}
示例5: update
public function update($id)
{
$category = $this->category->find($id);
if (Input::get('slug') === "") {
Input::merge(['slug' => \Slug::make(Input::get('name'))]);
}
$category->fill(Input::all());
if ($category->updateUniques()) {
return Redirect::route('admin.works.categories.index')->with('success', Lang::get('admin/blogs/messages.create.success'));
} else {
return Redirect::back()->withInput(['only' => []])->withErrors($category->errors());
}
}
示例6: update
public function update($id)
{
$news = $this->news->find($id);
if (Input::get('slug') === "") {
Input::merge(['slug' => \Slug::make(Input::get('title'))]);
}
$news->fill(Input::all());
if ($news->updateUniques()) {
return Redirect::route('admin.news.edit', $news->id)->with('success', Lang::get('admin/news/messages.create.success'));
} else {
return Redirect::back()->withInput()->withErrors($news->errors());
}
}
示例7: setForObject
public static function setForObject($object)
{
$slug_source = Slug::source($object->id);
$instances = DB::table($object->name)->get();
$slugs = [];
foreach ($instances as $instance) {
if ($slug_source === null) {
$slug = Slug::make($instance->created_at->format('Y-m-d'), $slugs);
} else {
$slug = Slug::make($instance->{$slug_source}, $slugs);
}
DB::table($object->name)->where('id', $instance->id)->update(['slug' => $slug]);
$slugs[] = $slug;
}
}
示例8: postCreate
/**
* Заносим в БД новую категорию, после проверки ввода
* @param AdminCategoryRequest $request
* @return \Illuminate\Http\RedirectResponse
*/
public function postCreate(AdminCategoryRequest $request)
{
$data = $request->all();
//Если алиас не задан, то генерируем его
if (!$request->has('alias')) {
$data['alias'] = \Slug::make($request->input('title'));
}
//Проверяем есть ли такой же алиас в БД
if ($this->model->where('alias', '=', $data['alias'])->first()) {
//Алиас такой существует, выводим ошибку
return redirect()->back()->with('error', 'Такой алиас существует!!!');
}
//Создаем новую запись в БД
$this->model->create($data);
return redirect()->route('admin.category.index')->with('success', 'Категория создана!');
}
示例9: update
public function update($id)
{
$work = $this->work->find($id);
if (Input::get('slug') === "") {
Input::merge(['slug' => \Slug::make(Input::get('title'))]);
}
$work->fill(Input::all());
$work->need_big_preview = Input::get('need_big_preview');
if ($work->updateUniques()) {
if (Input::get('categories')) {
$work->categories()->sync(Input::get('categories'));
}
return Redirect::route('admin.works.edit', $work->id)->with('success', Lang::get('admin/works/messages.create.success'));
} else {
return Redirect::back()->withInput()->withErrors($work->errors());
}
}
示例10: postCreate
/**
* Обработка данных из формы и сохранение в БД
* @param AdminArticleRequest $request
* @return \Illuminate\Http\RedirectResponse
*/
public function postCreate(AdminArticleRequest $request)
{
$data = $request->all();
//Если алиас не задан, то генерируем его
if (!$request->has('alias')) {
$data['alias'] = \Slug::make($request->input('title'));
//Проверяем есть ли такой же алиас в БД
if ($this->model->where('alias', '=', $data['alias'])->first()) {
//Алиас такой существует, выводим ошибку
return redirect()->back()->with('error', 'Такой алиас существует!!!');
}
}
$data['user_id'] = $request->user()->id;
//Создаем запись в БД
$this->model->create($data);
return redirect()->route('admin.article.index')->with('success', 'Материал добавлен!');
}
示例11: update
public function update($id)
{
$post = $this->post->find($id);
if (Input::get('slug') === "") {
Input::merge(['slug' => \Slug::make(Input::get('title'))]);
}
$post->fill(Input::all());
if ($post->updateUniques()) {
if (Input::get('rubrics')) {
$post->rubrics()->sync(Input::get('rubrics'));
}
if (Input::get('tags')) {
$post->retag(explode(",", Input::get('tags')));
}
return Redirect::route('admin.blogs.edit', $post->id)->with('success', Lang::get('admin/blogs/messages.create.success'));
} else {
return Redirect::back()->withInput()->withErrors($post->errors());
}
}
示例12: run
public function run()
{
$faker = Faker::create();
$title = $faker->sentence();
News::create(['created_at' => $faker->date($format = 'Y-m-d', $max = 'now'), 'title' => $title, 'alias' => Slug::make($title, '-'), 'body' => $faker->text($maxNbChars = 800), 'image' => '/public/files/Фото для сайта/Фото на новости/thumb-up.jpeg']);
foreach (range(1, 22) as $index) {
$title = $faker->sentence();
News::create(['created_at' => $faker->date($format = 'Y-m-d', $max = 'now'), 'title' => $title, 'alias' => Slug::make($title, '-'), 'body' => $faker->text($maxNbChars = 800), 'image' => $faker->imageUrl($width = 640, $height = 480)]);
// foreach(range(1, 10) as $cindex)
// {
// Comment::create([
// 'created_at' => $faker->date($format = 'Y-m-d', $max = 'now'),
// 'author' => $faker->name,
// 'body' => $faker->text($maxNbChars = 200),
// 'news_id' => $index,
// ]);
// }
}
}
示例13: cleanFilename
/**
* Cleans up a file name
*
* @param string $path Path and file name to clean up
* @return string
*/
public static function cleanFilename($path)
{
$extension = self::getExtension($path);
$path = str_replace('.' . $extension, '', $path);
return Slug::make($path) . '.' . $extension;
}
示例14: function
Route::get('/import/import/{table}', 'ImportController@import');
Route::get('/import/drop/{table}', 'ImportController@drop');
});
# All authenticated users
Route::group(array('before' => 'user'), function () {
Route::get('/', array('as' => 'home', 'uses' => 'ObjectController@index'));
Route::get('/logout', 'LoginController@getLogout');
Route::post('/upload/image', 'FileController@image');
# Test routes
Route::get('/schema/save', 'ObjectController@saveSchema');
Route::get('/schema/load', 'ObjectController@loadSchema');
Route::get('/image/test', 'FileController@test');
Route::get('/slug/test', function () {
$phrases = ['', 'and', 'this is a normal test', 'this is a really really really long test because it\'s amazing and great and am i at 50 YET???'];
foreach ($phrases as $phrase) {
echo '<p>' . $phrase . ' becomes <em>' . Slug::make($phrase, ['', 'normal-test', 'normal-test-1']) . '</em></p>';
}
});
Route::get('/slug/object/{object_id}', function ($object_id) {
$object = DB::table(DB_OBJECTS)->find($object_id);
Slug::setForObject($object);
die('object was ' . $object->name);
});
Route::get('cleanup', function () {
FieldController::cleanup();
FileController::findOrphans();
FileController::cleanup();
});
# Complex instance routing, optionally with linked_id for related objects
Route::get('/{object_name}/delete/{instance_id}', 'InstanceController@delete');
Route::get('/{object_name}', 'InstanceController@index');
示例15: showRecipiesByMarkerBySlug
public function showRecipiesByMarkerBySlug($slug)
{
if ($marker = Marker::where('slug', '=', $slug)->first()) {
$recipies = $marker->recipies;
$recipies = $recipies->filter(function ($item) {
return $item->postStatus_id == 3;
});
$title = CmsOption::getValue('Название сайта') . ' | ' . $marker->name;
$metaOptions = ['marker' => $marker];
Session::put('recipies', $recipies);
Session::put('marker', $marker);
Session::put('typepage', 'bymarker');
if ($marker->slug == '') {
$markerslug = \Slug::make($marker->name);
} else {
$markerslug = $marker->slug;
}
return view('recipieGrid', ['recipies' => $recipies, 'title' => $title, 'page_title' => $marker->name, 'metaOptions' => $metaOptions]);
}
}