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


PHP Str::limit方法代码示例

本文整理汇总了PHP中Illuminate\Support\Str::limit方法的典型用法代码示例。如果您正苦于以下问题:PHP Str::limit方法的具体用法?PHP Str::limit怎么用?PHP Str::limit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Support\Str的用法示例。


在下文中一共展示了Str::limit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: value

 public function value()
 {
     if ($this->entity->value === '0' || $this->entity->value === '1') {
         return $this->entity->value === '0' ? 'false' : 'true';
     }
     return Str::limit($this->entity->value, 20);
 }
开发者ID:NukaCode,项目名称:dasher,代码行数:7,代码来源:SettingPresenter.php

示例2: getDescriptionAttribute

 /**
  * @param $value
  * @return string
  */
 public function getDescriptionAttribute($value)
 {
     if ($value == '') {
         return Str::limit(strip_tags($this->attributes['content']), 130, '...');
     }
     return $value;
 }
开发者ID:darrengopower,项目名称:framework,代码行数:11,代码来源:Article.php

示例3: index

 public function index()
 {
     Str::limit('hello', 10);
     $data['posts'] = Post::getAll();
     $data['slides'] = [(object) ['src' => 'assets/img/gallery/slider-img-1.jpg', 'alt' => 'Slider', 'href' => 'gallery-single.htm', 'name' => 'test1'], (object) ['src' => 'assets/img/gallery/slider-img-2.jpg', 'alt' => 'Slider', 'href' => 'gallery-single.htm', 'name' => 'test1'], (object) ['src' => 'assets/img/gallery/slider-img-2.jpg', 'alt' => 'Slider', 'href' => 'gallery-single.htm', 'name' => 'test1'], (object) ['src' => 'assets/img/gallery/slider-img-1.jpg', 'alt' => 'Slider', 'href' => 'gallery-single.htm', 'name' => 'test1']];
     $data['post'] = Post::getLatest()->first();
     return view('home.index', $data);
 }
开发者ID:ravuthz,项目名称:cms-laravel5.1,代码行数:8,代码来源:ShowController.php

示例4: getTransactionLink

 /**
  * @param Currency $currency
  *
  * @return string
  */
 public function getTransactionLink(Currency $currency)
 {
     if ($this->category == 'move') {
         return '';
     }
     if ($currency->explorer) {
         return HTML::link(str_replace('%id', $this->txid, $currency->explorer), Str::limit($this->txid, 20), ['target' => '_blank']) . " <span class='fa fa-new-window'></span>";
     }
     return HTML::link('#', Str::limit($this->txid, 20), ['data-toggle' => 'tooltip', 'title' => $this->txid]);
 }
开发者ID:virtualvendors,项目名称:altwallets,代码行数:15,代码来源:Transaction.php

示例5: fire

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $dayBefore = Carbon::now()->subDay();
     $content = Content::where('created_at', '>', $dayBefore)->orderBy('uv', 'desc')->firstOrFail();
     $client = new Client(['base_url' => 'https://api.twitter.com/1.1/', 'defaults' => ['auth' => 'oauth']]);
     $oauth = new Oauth1(['consumer_key' => config('social.twitter.consumer_key'), 'consumer_secret' => config('social.twitter.consumer_secret'), 'token' => config('social.twitter.token'), 'token_secret' => config('social.twitter.token_secret')]);
     $client->getEmitter()->attach($oauth);
     $params = ['status' => Str::limit($content->title, 100) . ' https://strm.pl/c/' . $content->hashId()];
     $client->post('statuses/update.json', ['body' => $params]);
 }
开发者ID:vegax87,项目名称:Strimoid,代码行数:15,代码来源:TwitterPost.php

示例6: getItemUuiD

 /**
  * Generate Item uuid.
  *
  * @param $menuName
  * @param $itemURL
  *
  * @return string
  */
 public function getItemUuiD($menuItem)
 {
     $itemID = '';
     if (is_a($menuItem, MenuItem::class)) {
         $itemID = 'MenuItem' . $menuItem->getURL();
     }
     if (is_a($menuItem, MenuBuilder::class)) {
         $itemID = 'MenuBuilder' . $menuItem->getName();
     }
     return Str::limit(md5(Str::slug($itemID)), 12, null);
 }
开发者ID:SocietyCMS,项目名称:Menu,代码行数:19,代码来源:MenuRepository.php

示例7: render

 function render($instance, $key, $options)
 {
     if ($instance->{$key}) {
         $limit = 100;
         if ($options && intval($options)) {
             $limit = intval($options);
         }
         return Str::limit($instance->{$key}, $limit);
     }
     return null;
 }
开发者ID:dvlpp,项目名称:sharp,代码行数:11,代码来源:SharpCharLimitRenderer.php

示例8: createGroup

 function createGroup(Author $author)
 {
     $faker = $this->faker();
     $group = new Group();
     $group->title = join(' ', $faker->words(5));
     $group->link = $faker->boolean() ? '/' . $faker->slug(3) . '.html' : '';
     $group->inline = $faker->boolean();
     $group->annotation = Str::limit($faker->realText(), 250);
     $group->author()->associate($author);
     $group->save();
     return $group;
 }
开发者ID:ankhzet,项目名称:Ankh,代码行数:12,代码来源:GroupsTableSeeder.php

示例9: testStringLimit

 public function testStringLimit()
 {
     $str1 = 'Laravel is really awesome';
     $str2 = Str::limit($str1);
     $this->assertEquals($str2, 'Laravel is really awesome');
     $str1 = 'Laravel is really awesome';
     $str2 = Str::limit($str1, 7);
     $this->assertEquals($str2, 'Laravel...');
     $str1 = 'Laravel is really awesome';
     $str2 = Str::limit($str1, 7, '!!!');
     $this->assertEquals($str2, 'Laravel!!!');
 }
开发者ID:aapiro,项目名称:laravel-strings-examples,代码行数:12,代码来源:HelpersStringsTest.php

示例10: up

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::table('games', function(Blueprint $table)
		{
			$table->string('slug', 32);
		});
        $games = Game::all();
        foreach( $games as $item )
        {
            $item->slug = Str::limit( Str::slug( $item->title), 32, '');
            $item->save();
        }
	}
开发者ID:hungnt88,项目名称:5stars-1,代码行数:18,代码来源:2015_03_04_050600_add_slug_to_games.php

示例11: up

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::table('categories', function(Blueprint $table)
		{
			$table->string('icon')->nullable();
            $table->string('slug', 32);
            $table->string('type')->nullable();
		});
        $categories = Category::all();
        foreach( $categories as $item )
        {
            $item->slug = Str::limit( Str::slug( $item->name), 32, '');
            $item->save();
        }
	}
开发者ID:hungnt88,项目名称:5stars-1,代码行数:20,代码来源:2015_03_04_170811_add_fields_to_categories.php

示例12: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $authors = Author::all();
     $this->iterate(self::PAGES_TO_SEED / 2, self::PAGES_TO_SEED, function ($i) use($authors) {
         $author = $authors->random();
         do {
             $author = $authors->random();
         } while ($author->groups->isEmpty());
         $faker = $this->faker();
         $page = new Page();
         $page->title = $faker->sentence(5);
         $page->annotation = Str::limit(join(' ', $faker->sentences(5)), 250);
         $page->link = $faker->slug(3);
         $page->size = $faker->numberBetween(0, 9999);
         $page->author()->associate($author);
         $page->group()->associate($author->groups->random());
         $page->save();
     });
 }
开发者ID:ankhzet,项目名称:Ankh,代码行数:24,代码来源:PagesTableSeeder.php

示例13: limit

 /**
  * Limit the number of characters in the string.
  *
  * @param  int  $limit
  * @param  string  $end
  * @return static
  */
 public function limit($limit = 100, $end = '...')
 {
     return new static(Str::limit($this->string, $limit, $end));
 }
开发者ID:laraplus,项目名称:string,代码行数:11,代码来源:StringBuffer.php

示例14: getReleaseDate

 public function getReleaseDate()
 {
     if ($this->released_at !== null) {
         return $this->released_at;
     }
     if ($this->published_at !== null) {
         return Str::limit($this->published_at, 10, '');
     }
     return Str::limit($this->attributes['created_at'], 10, '');
 }
开发者ID:nsystem1,项目名称:Pony.fm,代码行数:10,代码来源:Track.php

示例15: limit

 /**
  * Limit the number of characters in a string.
  *
  * @param  string  $value
  * @param  int     $limit
  * @param  string  $end
  * @return string
  */
 public function limit($value, $limit = 12, $end = '')
 {
     return Str::limit($value, $limit, $end);
 }
开发者ID:vuongabc92,项目名称:ot,代码行数:12,代码来源:FileName.php


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