I am trying to show excerptsfrom blog posts. I can do this with phpand mysql. However, I am wondering if there is a more “friendly” way to do this within Laravel.
excerpts
php
mysql
Thanks!
You can do this using the method words
words
Default:
words($value,$words = 100, $end='...');
You can implement it this way
Str::words($post->body); Str::words($post->body,10); //will show first 10 words
You can easily use str_limit.
str_limit
Inside the PHP files:
str_limit($value, $limit = 100, $end = '...')
Inside Blade Templates files:
{{ str_limit($value, $limit = 100, $end = '...') }}
I saw that it is available from version 4.2 to 5.6
Link