示例#1
0
 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);
 }
示例#2
0
 /**
  * @param $value
  * @return string
  */
 public function getDescriptionAttribute($value)
 {
     if ($value == '') {
         return Str::limit(strip_tags($this->attributes['content']), 130, '...');
     }
     return $value;
 }
示例#3
0
 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);
 }
示例#4
0
 /**
  * @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]);
 }
示例#5
0
 /**
  * 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]);
 }
示例#6
0
 /**
  * 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);
 }
示例#7
0
 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;
 }
示例#8
0
 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;
 }
 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!!!');
 }
	/**
	 * 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();
        }
	}
	/**
	 * 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();
        }
	}
示例#12
0
 /**
  * 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();
     });
 }
示例#13
0
 /**
  * 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));
 }
示例#14
0
 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, '');
 }
示例#15
0
 /**
  * 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);
 }
示例#16
0
 public static function limitMarkdownText($str, $limit, $ignored_tags = false)
 {
     // Remove content in $ignored_tags
     if ($ignored_tags) {
         $str = Thinker::removeTagsFromString($str, $ignored_tags);
     }
     // Shorten Markdown
     $str = preg_replace("/\r|\n/", " ", strip_tags($str));
     $str_limited = Str::limit($str, $limit);
     // Text < Limit
     if (strlen($str) == strlen($str_limited)) {
         return $str;
     }
     // Text > Limit
     $str_limited_words = explode(" ", $str_limited);
     array_pop($str_limited_words);
     $str_limited = join($str_limited_words, " ") . '…';
     return $str_limited;
 }
示例#17
0
 /**
  * @param int $limit
  * @return string
  */
 public function getDescription($limit = 130)
 {
     return Str::limit(strip_tags($this->model->getAttribute('content')), $limit, '...');
 }
示例#18
0
 /**
  * Prepare the title output.
  *
  * @param  string  $output
  *
  * @return string
  */
 private function prepareTitleOutput($output)
 {
     return htmlspecialchars(Str::limit(strip_tags($output), $this->getMax()), ENT_QUOTES, 'UTF-8', false);
 }
示例#19
0
 /**
  * When title change then slug will change.
  * @param $name
  * @internal param $title
  */
 public function setNameAttribute($name)
 {
     $this->attributes['name'] = $name;
     $this->attributes['slug'] =  Str::limit( Str::slug($name), 32, '');
 }
示例#20
0
 /**
  * Returns a summary of the guide by limiting the description attribute.
  *
  * @return string
  */
 public function getSummaryAttribute()
 {
     return Str::limit($this->description, 25);
 }
示例#21
0
 private function getHash()
 {
     $hash = md5($this->image_source);
     return '-' . Str::limit($hash, 5, '');
 }
示例#22
0
 /**
  * Sanitize the username.
  *
  * @param  array  $inputs
  *
  * @return string
  */
 protected function sanitizeUsername(array $inputs)
 {
     $username = $this->has('username') ? $inputs['username'] : Str::limit($inputs['first_name'], 1, '.') . ' ' . $inputs['last_name'];
     return Str::slug($username, config('arcanesoft.auth.slug-separator', '.'));
 }
示例#23
0
 /**
  * When title change then slug will change.
  * @param $title
  */
 public function setTitleAttribute($title)
 {
    $this->attributes['title'] = $title;
    $this->attributes['slug'] =  Str::limit( Str::slug($title), 32, '');
 }
示例#24
0
文件: Post.php 项目: Aglok/upbrain
 public function getCutAttribute()
 {
     return Str::limit($this->attributes['article'], 120);
     //ограничивает по количеству символов
 }
示例#25
0
 public function draw($id = 'untitled')
 {
     //start up
     if ($this->draggable) {
         array_unshift($this->columns, ['label' => '', 'type' => 'draggy', 'name' => 'draggy']);
     }
     if ($this->deletable) {
         self::column('delete', 'delete', '');
     }
     if ($this->grouped) {
         $last_group = '';
     }
     $colspan = count($this->columns);
     $rowspan = count($this->rows);
     //build <thead>
     $columns = [];
     foreach ($this->columns as $column) {
         $columns[] = '<th class="type-' . $column['type'] . ' ' . $column['name'] . '">' . $column['label'] . '</th>';
     }
     $head = '<thead><tr>' . implode($columns) . '</tr></thead>';
     //build rows
     $bodies = $rows = [];
     foreach ($this->rows as $row) {
         $columns = [];
         $link = true;
         foreach ($this->columns as $column) {
             //handle groupings
             if ($this->grouped && $last_group != $row->{$this->grouped}) {
                 $last_group = $row->{$this->grouped};
                 if (count($rows)) {
                     $bodies[] = '<tbody>' . implode($rows) . '</tbody>';
                 }
                 $bodies[] = '<tr class="group"><td colspan=' . $colspan . '">' . $last_group . '</td></tr>';
                 $rows = [];
             }
             //process value if necessary
             if ($column['type'] == 'draggy') {
                 $value = config('center.icons.drag');
             } elseif ($column['type'] == 'delete') {
                 $value = '<a href="' . $row->delete . '">' . ($row->deleted_at ? config('center.icons.deleted') : config('center.icons.undeleted')) . '</a>';
             } elseif ($column['type'] == 'image') {
                 $value = '<img src="' . $row->{$column['name'] . '_url'} . '" width="' . $column['width'] . '" height="' . $column['height'] . '">';
                 if (isset($row->link)) {
                     $value = '<a href="' . $row->link . '">' . $value . '</a>';
                 }
             } elseif ($column['type'] == 'stripe_charge') {
                 $value = $row->{$column['name']} ? '<a href="https://dashboard.stripe.com/payments/' . $row->{$column['name']} . '" target="_blank">' . config('center.icons.new_window') . ' ' . trans('center::site.stripe_open') . '</a>' : '';
             } else {
                 $value = Str::limit(strip_tags($row->{$column['name']}));
                 if ($column['type'] == 'updated_at') {
                     $value = Dates::relative($value);
                 } elseif ($column['type'] == 'time') {
                     $value = Dates::time($value);
                 } elseif ($column['type'] == 'date') {
                     $value = Dates::absolute($value);
                 } elseif ($column['type'] == 'date-relative') {
                     $value = Dates::relative($value);
                 } elseif (in_array($column['type'], ['datetime', 'timestamp'])) {
                     $value = Dates::absolute($value);
                 } elseif ($column['type'] == 'checkbox') {
                     $value = $value ? trans('center::site.yes') : trans('center::site.no');
                 } elseif ($column['type'] == 'money') {
                     $value = '$' . number_format($value, 2);
                 }
                 if (isset($row->link) && $link) {
                     if ($column['type'] == 'color') {
                         $value = '<a href="' . $row->link . '" style="background-color: ' . $value . '"></a>';
                     } else {
                         if ($value == '') {
                             $value = '&hellip;';
                         }
                         $value = '<a href="' . $row->link . '">' . $value . '</a>';
                         $link = false;
                     }
                 }
             }
             //create cell
             $columns[] = '<td class="type-' . $column['type'] . ' ' . $column['name'] . '">' . $value . '</td>';
         }
         //create row
         $rows[] = '<tr' . (empty($row->id) ? '' : ' id="' . $row->id . '"') . ($this->deletable && $row->deleted_at ? ' class="inactive"' : '') . '>' . implode($columns) . '</tr>';
     }
     $bodies[] = '<tbody>' . implode($rows) . '</tbody>';
     //output
     return '<table id="' . $id . '" class="table table-condensed' . ($this->draggable ? ' draggable" data-draggable-url="' . $this->draggable : '') . '" data-csrf-token="' . Session::token() . '">' . $head . implode($bodies) . '</table>';
 }
示例#26
0
 public function subject()
 {
     $prefix = $this->versionSubjectPrefix();
     $subject = Str::limit($this->getWrappedObject()->subject, 80);
     return $prefix ? $prefix . ' ' . $subject : $subject;
 }
示例#27
0
文件: Ticker.php 项目: apolune/news
 /**
  * Retrieve the ticker excerpt.
  *
  * @param  integer  $limit  58
  * @param  string  $end  ...
  * @return string
  */
 public function excerpt($limit = 58, $end = ' ...')
 {
     return Str::limit($this->content(), $limit, $end);
 }
示例#28
0
 /**
  * limit
  **/
 public function limit($limit = 100, $end = '...')
 {
     $this->value = Str::limit($this->value, $limit, $end);
     return $this;
 }
示例#29
0
文件: helpers.php 项目: saj696/pipe
 /**
  * Limit the number of characters in a string.
  *
  * @param  string $value
  * @param  int $limit
  * @param  string $end
  * @return string
  */
 function str_limit($value, $limit = 100, $end = '...')
 {
     return Str::limit($value, $limit, $end);
 }
示例#30
0
 public function textarea()
 {
     $this->column_html .= Str::limit($this->value, 50) . PHP_EOL;
     $this->column_html .= '</td>' . PHP_EOL;
     return $this->column_html;
 }