当前位置: 首页>>代码示例>>PHP>>正文


PHP Slug::make方法代码示例

本文整理汇总了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";
 }
开发者ID:roobottom,项目名称:roobottom-statamic,代码行数:29,代码来源:pi.wordpress.php

示例2: generateMarkerSlug

 public function generateMarkerSlug()
 {
     $markers = Marker::all();
     foreach ($markers as $marker) {
         $marker->slug = \Slug::make($marker->name);
         $marker->save();
     }
 }
开发者ID:AngryGantz,项目名称:cms-cookbook,代码行数:8,代码来源:SitemapsController.php

示例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);
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:18,代码来源:taxonomy.php

示例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' => ' техника техника техника техника']);
 }
开发者ID:VerticalHorizon,项目名称:Bumagi,代码行数:12,代码来源:CategoriesTableSeeder.php

示例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());
     }
 }
开发者ID:Khelek,项目名称:ipsol,代码行数:13,代码来源:CategoriesController.php

示例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());
     }
 }
开发者ID:Khelek,项目名称:ipsol,代码行数:13,代码来源:NewsController.php

示例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;
     }
 }
开发者ID:joshreisner,项目名称:avalon,代码行数:15,代码来源:Slug.php

示例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', 'Категория создана!');
 }
开发者ID:alexusmai,项目名称:admin,代码行数:21,代码来源:AdminCategoryController.php

示例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());
     }
 }
开发者ID:Khelek,项目名称:ipsol,代码行数:17,代码来源:WorksController.php

示例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', 'Материал добавлен!');
 }
开发者ID:alexusmai,项目名称:admin,代码行数:22,代码来源:AdminArticleController.php

示例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());
     }
 }
开发者ID:Khelek,项目名称:ipsol,代码行数:19,代码来源:BlogsController.php

示例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,
         //     ]);
         // }
     }
 }
开发者ID:VerticalHorizon,项目名称:Bumagi,代码行数:19,代码来源:NewsTableSeeder.php

示例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;
 }
开发者ID:zane-insight,项目名称:WhiteLaceInn,代码行数:12,代码来源:file.php

示例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');
开发者ID:joshreisner,项目名称:avalon,代码行数:31,代码来源:routes.php

示例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]);
     }
 }
开发者ID:AngryGantz,项目名称:cms-cookbook,代码行数:20,代码来源:PostController.php


注:本文中的Slug::make方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。