• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Systasis Computer Systems

Systasis Computer Systems

The Infusionsoft Medics – We get it working right!

  • +1 520.399.8886
  • Keap
    • Infusionsoft by Keap
  • Gravity Forms Infusionsoft Feed
    • About
    • Gravity Forms Infusionsoft Feed Configuration
  • Services
    • Software Development
      • Infusionsoft
      • Gravity Forms
  • About
  • Messages
You are here: Home / laravel lumen / Use a view composer to invoke a function in Blade.

Use a view composer to invoke a function in Blade.

September 29, 2019 by Jeff Chimene

Here’s an interesting use of  a view composer that’s useful for invoking functions in blade. Create and register a service provider…
php artisan make:provider Composer

In its boot() method…

public function boot()

for all blade instances…

view()->composer('*', function ($view) {

declare a function…

$view->with('briefTime', function ($x)
return strrev(substr(strrev($x), 3));
}); }); }

This example defines a way to quickly remove seconds from SQL datetime.

to support the following blade syntax…

<div class="pr-5">{{$briefTime($survey['started_at'])}}</div>

Filed Under: laravel lumen Tagged With: valet

Primary Sidebar

Recent Posts

  • Upcoming 2.4 release
  • Backup your Gravity Forms feed settings
  • 2.3.5 released today
  • Reader questions
  • While you’ve been f%!?*-ing off

Purchase Our Services

We’ve discussed your project, now it’s time to get your project started.
Purchase time by the hour. When you purchase eight or more hours, you’ll save 20%.

Contact Us

Systasis Computer Systems, Inc.
Sonoita, Arizona  85637-0778
USA
+1 520.399.8886

© 2023 · Built on the Genesis Framework