• Stars
    star
    858
  • Rank 53,134 (Top 2 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A collection of nice Laravel Blade directives

Laravel Blade Directives

Latest Version on Packagist Total Downloads Software License Build Status

A collection of nice Laravel Blade directives.

Installation

You can install the package via composer:

composer require appstract/laravel-blade-directives

Usage

@istrue

Only show when $variable isset and true.

@istrue($variable)
   This will be echoed
@endistrue

Or when you would like to quickly echo

@istrue($variable, 'This will be echoed')

@isfalse

Same as @istrue but checks for isset and false.

@isfalse($variable)
   This will be echoed
@endisfalse

@isnull

Only show when $variable is null.

@isnull($variable)
   This will be echoed
@endisnull

@isnotnull

Same as @isnull but one shows when $variable is not null.

@isnotnull($variable)
   This will be echoed
@endisnotnull

@dump and @dd

@dump($var)

@dd($var)

@mix

Create a HTML element to your Laravel-Mix css or js.

@mix('/css/app.css')
@mix('/js/app.js')

Output:

<link rel="stylesheet" href="{{ mix('/css/app.css') }}">
<script src="{{ mix('/js/app.js') }}"></script>

@style

Create a <style> element or <link> element with a css path.

@style
    body { background: black }
@endstyle


@style('/css/app.css')

@script

Create a <script> element with or without a js path.

@script
    alert('hello world')
@endscript


@script('/js/app.js')

@inline

Load the contents of a css or js file inline in your view.

@inline('/js/manifest.js')

@pushonce

Same as @push but will include content one time only. Useful for repeatable blocks.

First parameter must follow the syntax stack-name:group-name.

@pushonce('js:foobar')
    <script src="{{ asset('/js/foobar.js') }}"></script>
@endpushonce

Include pushes with standard @stack directive:

@stack('js')

@routeis

Checks if the current route name is equal to the given parameter. You can use a wildcard like blog.post.*.

@routeis('webshop.checkout')
    Do something only on the checkout
@endrouteis

@routeisnot

Checks if the current route name is not equal to the given parameter. You can use a wildcard like blog.post.*

@routeisnot('webshop.checkout')
    Do something only if this is not the checkout
@endrouteisnot

@instanceof

Checks if the first parameter is an instance of the second parameter.

@instanceof($user, 'App\User')
    User is an instance of App\User
@endinstanceof

@typeof

Checks if the parameter is of a certain type.

@typeof($text, 'string')
    Text is a string
@endtypeof

@repeat

Repeat something a specified amount of times.

@repeat(3)
    Iteration #{{ $iteration }}
@endrepeat

@fa, @fas, @far, @fal, @fab, @fad, @mdi, @glyph

Quickly output an icon with Font Awesome, Material Design Icons or Glyphicon.

@fa('address-book', 'optional-extra-class')

// for Font Awesome 5 (solid, regular, light, brand, duotone):
@fas('address-book', 'optional-extra-class')
@far('address-book', 'optional-extra-class')
@fal('address-book', 'optional-extra-class')
@fab('address-book', 'optional-extra-class')
@fad('address-book', 'optional-extra-class')

// for Material Design Icons
@mdi('account', 'optional-extra-class')

// for Glyphicons
@glyph('glass', 'optional-extra-class')

@data

Output data-attributes from an array.

@data(['testing' => 123])

@haserror

Quickly output for classical $errors->has('input_name') to determine if any error messages exist for a given field.

@haserror('input_name')
    This input has an error
@endhaserror

@count

Output number of entries.

@count([1,2,3])

@nl2br

Replaces \n into <br>.

@nl2br('foo\n bar\n baz\n')

@snake, @kebab, @camel

Output formatted string (uses Laravel Helpers).

@snake('fooBar')
// output: 'foo_bar'

@kebab('fooBar')
// output: 'foo-bar'

@camel('foo bar')
// output: 'fooBar'

Testing

composer test

Contributing

Contributions are welcome, thanks to y'all :)

About Appstract

Appstract is a small team from The Netherlands. We create (open source) tools for Web Developers and write about related subjects on Medium. You can follow us on Twitter, buy us a beer or support us on Patreon.

License

The MIT License (MIT). Please see License File for more information.

More Repositories

1

laravel-opcache

Laravel Package for OPcache
PHP
1,327
star
2

laravel-options

Global key-value store in the database
PHP
722
star
3

laravel-stock

Keep stock for Eloquent models
PHP
287
star
4

laravel-multisite

Multiple sites on one codebase
PHP
216
star
5

laravel-bootstrap-components

Bootstrap components as Laravel components
HTML
192
star
6

laravel-meta

Metadata for Eloquent model
PHP
129
star
7

laravel-tracer

Shows the path of each blade file loaded in a template
PHP
98
star
8

nova-horizon

Horizon statistics in Nova
Vue
79
star
9

lush-http

Smart Http Client for PHP
PHP
63
star
10

dd.js

Laravel dd() in JS
JavaScript
53
star
11

laravel-elixir-env

Use .env variables in Javascript with Laravel Elixir
JavaScript
39
star
12

laravel-response-macros

Extra response macro's for Laravel
PHP
33
star
13

laravel-referer-redirector

Manage redirects based on referers
PHP
32
star
14

nova-opcache

OPcache Tool for Laravel Nova
Vue
19
star
15

php-hostsfile

Read & Write HostsFile Entries with PHP
PHP
13
star
16

laravel-artisan-scan

[WIP] Scan for multiple improvement points
PHP
11
star
17

laravel-crawl-render

Pre-render Javascript sites for web crawlers
PHP
11
star
18

laravel-dusk-safari

Run Dusk tests in Safari
PHP
11
star
19

skeleton-php

Skeleton for PHP packages
PHP
11
star
20

vue-validate

[DEPRECATED] Input validation for Vue
JavaScript
10
star
21

laravel-moneybird

Laravel package for Moneybird
PHP
9
star
22

laravel-dusk-opera

Run Dusk tests in Opera
PHP
8
star
23

nova-signature-field

Signature Pad as a Nova Field
Vue
7
star
24

pakketpartner-php-client

PHP Client for the Pakketpartner API
PHP
7
star
25

laravel-pakketpartner

Wrapper for the Pakketpartner PHP Client
PHP
4
star
26

laravel-bol-retailer

Wrapper package for Bol.com Retailer API
PHP
2
star
27

laravel-twikey

PHP
2
star