Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel blade excerpt from body

<?php
// php artisan make:provider BladeServiceProvider
// import into config/app.php -> providers[]
use IlluminateSupportFacadesBlade;

/**
 * Bootstrap services.
 *
 * @return void
*/
public function boot()
{
    Blade::directive('excerpt', function ($text) {
        return "<?php echo Str::limit($text, 100); ?>";
    });
}

// in view: <p>@excerpt($post->body)</p>
Comment

PREVIOUS NEXT
Code Example
Php :: php initialize two dimensional array dynamically 
Php :: required_unless laravel 
Php :: magento 2 remove order 
Php :: @admin @endadmin 
Php :: phpmailer doesnt work 
Php :: generate report daily weekly monthly php mysql 
Php :: laravel check if model has relation 
Php :: laravel reroute 419 
Php :: smtp_port" setting in php.ini or use ini_set() 
Php :: php dar echo em um stdClass 
Php :: php substr_replace 
Php :: get attachment by id wordpress 
Php :: laravel translation parameter send 
Php :: woocommerce order get product weight 
Php :: Laravel get all parent categories for each category 
Php :: Allowed memory size of 33554432 bytes exhausted (tried to allocate 8192 bytes) 
Php :: drupal form show description 
Php :: laravel filesystem 
Php :: workpress change page title from shortcode 
Php :: php dump to page 
Php :: php slice string by character 
Php :: update to php 7.4 
Php :: PHP multidimensional array merge recursive 
Php :: check the existing image in s3 laravel 
Php :: php RFC3339 
Php :: nested loop in php 
Php :: base64_img 
Php :: Call to undefined method IlluminateDatabaseEloquentRelationsHasMany::attach() 
Php :: spatie/laravel-activitylog display only changed data 
Php :: what is isset in php 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =