Laravel 8 limit {#collection-method}
limit
方法用于将指定字符串切割为指定长度:
use Illuminate\Support\Str;
$truncated = Str::of('The quick brown fox jumps over the lazy dog')->limit(20);
// The quick brown fox...
您亦可通过第二个参数来改变追加到末尾的字符串:
use Illuminate\Support\Str;
$truncated = Str::of('The quick brown fox jumps over the lazy dog')->limit(20, ' (...)');
// The quick brown fox (...)