Helpers

Helpers

table()

Looks for a data table by its slug. Returns an Eloquent query builder, on which you can chain to fetch what you need:

table('products')->where('published', 1)->orderBy('title')->get();

page()

Looks for a page by its slug, or returns the current page when the slug is omitted:

// Current page
page();

// Home page
page('home');

pages()

Returns an Eloquent query builder for the page table:

pages()->whereIn('slug', ['home', 'about', 'contact'])->get();

globals()

Looks for a global set by its slug. Returns an object to access the global values:

globals('general')->website_title;

languages()

Returns a collection of the languages of the project:

@foreach (languages() as $language)
    <a href="{{ $language->url() }}">{{ $language->name }}</a>
@endforeach

language()

Looks for a language by its slug, or returns the current language when the slug is omitted:

// Current language
language();

// Dutch language
language('nl');

Returns a list of items, representing the breadcrumb path of the current page. Also works with dynamic pages:

@foreach (breadcrumbs() as $breadcrumb)
    <a href="{{ $breadcrumb->url() }}">{{ $breadcrumb->title() }}</a>
@endforeach

entry()

Returns the data entry corresponding with the current URL. This only works on dynamic pages and will return null on non-dynamic pages.

<h1>{{ entry()->title }}</h1>

mail()

Looks for a mail by its slug, to use in Livewire components. Several methods are available:

mail('subscription')
    ->to('name@example.com')
    ->cc('info@devisto.com')
    ->bcc('klaas@devisto.com')
    ->replyTo('klaas@devisto.com')
    ->parameter('name', $this->name)
    ->parameters(['name' => $this->name])
    ->send();

For more information on mails, take a look at the Mails section.

asset()

Looks for an asset by its path:

asset('path/to/test.jpg');

For more information on assets, take a look at the Assets section.

meta()

Helper method to register meta data. See Meta Data for more information.

unsplash()

Generates an Unsplash URL to get random free images for testing:

<img src="{{ unsplash()->search('nature')->size(400, 300) }}">
<img src="{{ unsplash()->user('User Name') }}">
<img src="{{ unsplash()->collection('Collection Name') }}">
<img src="{{ unsplash()->id('abc123') }}">

faker()

Returns a Faker instance to generate fake values for testing:

// Current language
faker()->firstName();

// Other Faker language
faker('nl_BE')->firstName();

The available methods are auto-suggested in the editor.

embed()

Generates the HTML to embed any service, just by giving it a URL:

{{ embed('https://twitter.com/devistoapp/status/1366841828696293380') }}
{{ embed('https://www.youtube.com/watch?v=A2Rxz8rR2Fk') }}

icon()

Generates the HTML code for an Fontawesome icon:

{{ icon('facebook') }}
{{ icon('facebook')->light() }}
{{ icon('facebook')->duotone() }}

The available icons are auto-suggested in the editor.

share()

Generates a URL to share a URL on several services:

// Current URL
share()->facebook();

// Other URL
share('https://...')->facebook();

// Available services
share()->facebook();
share()->twitter();
share()->linkedin();
share()->email()->subject('This is interesting');

str()

Returns a Laravel Stringable object, equivalant to Str::of() in Laravel:

// Chain methods
str('My Name')->snake()->upper(); // MY_NAME

// Omit the parameter to call 'Str' methods that don't expect a parameter
str()->random();

Laravel Helpers

Of course, all default Laravel helpers are also available in Devisto, for example:

// Dates
now()->format('d/m/Y H:i:s');
today()->addDays(2)->format('d/m/Y');

// Debugging
dump('foo');
dd('foo');

// Getting data from the query string
request('foo', 'default');

// Make a collection
collect(['foo' => 'bar']);

Blade Directives

@styles

Renders all the CSS needed to make your project work:

  • All your own CSS you write in app.css
  • All styles you pushed to the stack with @push('styles')
  • Livewire styles to make Livewire components work

@scripts

Renders all the JavaScript needed to make your project work:

  • All your own JS you write in app.js
  • All scripts you pushed to the stack with @push('scripts')
  • Livewire scripts to make Livewire components work
  • Fontawesome scripts to make the icon() helper work
  • The instant.page script for faster page loads
  • The lazysizes script for faster image loading

@meta

Renders all data that was registered with the meta() helper. See Meta Data for more information.

Previous topic
← JS
Next topic
Meta Data →