PHPackages                             cssjockey/laravel-directives - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. cssjockey/laravel-directives

AbandonedArchivedLibrary[Templating &amp; Views](/categories/templating)

cssjockey/laravel-directives
============================

This package provides a collection of useful laravel blade directives.

1.0.0(4y ago)012MITPHP

Since Jul 14Pushed 4y ago1 watchersCompare

[ Source](https://github.com/cssjockey/laravel-directives)[ Packagist](https://packagist.org/packages/cssjockey/laravel-directives)[ Docs](https://github.com/cssjockey/laravel-directives)[ RSS](/packages/cssjockey-laravel-directives/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

Laravel Blade Directives
========================

[](#laravel-blade-directives)

This package provides a collection of useful laravel blade directives.

Installation
------------

[](#installation)

You can install the package via composer:

```
$ composer require cssjockey/laravel-directives
```

**Optional:** The service provider will automatically get registered. Or you may manually add the service provider in your config/app.php file:

```
'providers' => [
    // ...
    CSSJockey\LaravelDirectives\LaravelDirectivesServiceProvider::class,
];
```

Usage
-----

[](#usage)

### @modeldata

[](#modeldata)

Fetch any model by ID to display any data from result.

```
@modeldata('App\Models\User'|1|"email")
```

This will fetch the `User` with ID 1 and renders the email address.

### @arraydata

[](#arraydata)

Renders the value of an array and supports array dot notation.

```
@arraydata($array|$variable)
```

**example with simple array:**

```
@arraydata(['key1' => 'value1', 'key2' => 'value2']|'key1')

Output: value1
```

```
@arraydata(['key1' => 'value1', 'key2' => 'value2']|'key2')

Output: value2
```

**example with multi-dimensional array:**

```
$data = [
    'parent' => [
        'child' => 'child value',
        'child2' => [
            'key' => 'child2 key value'
        ],
    ]
];
```

```
@arraydata($data|'parent')

Output: {"child":"child value","child2":{"key":"child2 key value"}}
```

This will return JSON string as the values is array.

**Supports dot notation.**

```
@arraydata($data|'parent.child')

Output (String): child value
```

```
@arraydata($data|'parent.child2.key')

Output (String): child2 key value
```

### @code | @code ... @endcode

[](#code--code--endcode)

Renders the content in `` tag.

**example of inline code**

```
@code('Hello world')

Output: hello world
```

**example with multi-line code block**

```
@code

    Click me

@endcode

Output: is wrapped in  tag

    Click me

```

### @dd

[](#dd)

Die and dump, renders only if **APP\_ENV** is set to **local**.

**example**

```
@dd('die and dump here')

Output: "die and dump here"
```

### @ddd

[](#ddd)

Dump, die and debug, renders only if **APP\_ENV** is set to **local**.

**example**

```
@ddd("Dump, Die, Debug")
```

### @dump

[](#dump)

Inline dump, renders only if **APP\_ENV** is set to **local**.

**example**

```
@ddd("Dump this inline")
```

### @haserror | @haserror ... @endhaserror

[](#haserror--haserror--endhaserror)

Output content for `$errors->has('input_name')` to determine if any error message found for the given input field.

```
@haserror('name'|"Message or class name goes here.")

Output (String): Message or class name goes here.
```

```
@haserror('name')
You can display any text or html here if any error message exists for input field name.
@endhaserror()
```

### @instanceof ... @endinstanceof

[](#instanceof--endinstanceof)

Quickly check if first parameter is an instance of second parameter.

```
@instanceof($user|'\App\Models\User')
Yes $user is an instance of '\App\Models\User'
@endinstanceof
```

### @typeof ... @endtypeof

[](#typeof--endtypeof)

Quickly check if the parameter is a specific type.

```
$variable = 'a valid string';

@typeof($variable|'string')
Yes $variable type is string.
@endtypeof

$variable = ['valid' => 'array'];

@typeof($variable|'array')
Yes $variable type is array.
@endtypeof
```

### @istrue | @istrue ... @endistrue

[](#istrue--istrue--endistrue)

Display content if variable of condition is true.

```
$var1 = 'one';
$var2 = 'one';
$true = ($var1 === $var2);
```

```
@istrue($true|"Display this content")
@istrue($var1 === $var2|"Yes it is")
```

```
@istrue($true)
Display this line
@endistrue

@istrue($var1 === $var2)
Yes the condition is true
@endistrue
```

### @isfalse | @isfalse ... @endisfalse

[](#isfalse--isfalse--endisfalse)

Display content if variable of condition is false.

```
$var1 = 'one';
$var2 = 'two';
$false = ($var1 === $var2);
```

```
@isfalse($false|"Display this content")
@isfalse($var1 === $var2|"No it is not")
```

```
@isfalse($false)
Display this line
@endisfalse

@isfalse($var1 === $var2)
No the condition is not true
@endisfalse
```

### @isnull | @isnull ... @endisnull

[](#isnull--isnull--endisnull)

Display content only if variable is NULL.

```
$variable = null;

```

```
@isnull($null_variable|"yes it is null")

@isnull($null_variable)
Yes variable is null
@endisnull
```

### @isnotnull | @isnotnull ... @endisnotnull

[](#isnotnull--isnotnull--endisnotnull)

Display content only if variable is NOT NULL.

```
$variable = 'something other than null';

```

```
@isnotnull($variable|"yes variable is not null")

@isnotnull($variable)
Yes variable is not null
@endisnotnull
```

### @isuser | @isuser ... @endisuser

[](#isuser--isuser--endisuser)

Display content only if the user is logged in.

```
@isuser("Yes user is logged in!")

@isuser
Yes user is logged in!
@endisuser
```

### @isguest | @isguest ... @endisguest

[](#isguest--isguest--endisguest)

Display content only if the user is **not** logged in.

```
@isguest("Show this line to the guest!")

@isguest
Show this content to the guest!
@endisguest
```

### @routeis | @routeis ... @endrouteis

[](#routeis--routeis--endrouteis)

Show content only if current route matches the first parameter.

```
@routeis("route.name.here"|"show this content")

@routeis("route.name.here")
show this content
@endrouteis
```

### @routeisnot | @routeisnot ... @endrouteisnot

[](#routeisnot--routeisnot--endrouteisnot)

Show content only if current route does not match the first parameter.

```
@routeisnot("route.name.here"|"show this content")

@routeisnot("route.name.here")
show this content
@endrouteisnot
```

### @repeat ... @endrepeat

[](#repeat--endrepeat)

Repeat any content specified number of times.

```
@repeat(10)
Repeat this content
@endrepeat
```

### @script | @script ... @endscript

[](#script--script--endscript)

Create a `script` element or include a javascript file.

```
@script('public/url/to/script.js')

@script
console.log('I run from this directive')
@endscript
```

### @style | @style ... @endstyle

[](#style--style--endstyle)

Create a `style` element or include a javastyle file.

```
@style('public/url/to/style.css')

@style
body{ overflow: hidden }
@endstyle
```

### @tagattributes

[](#tagattributes)

Bind attributes to any html tag.

```
 'some-id', 'class' => 'css-class', 'data-item' => 'value'])>
content goes here.

Output:

    content goes here.

```

Changelog
---------

[](#changelog)

Please see the changelog for more information on what has changed recently.

Todo:
-----

[](#todo)

- Add more free icons to the package.
- Create an artisan command to optimize all the SVG files.

Contributing
------------

[](#contributing)

Please see contributing for details.

Security
--------

[](#security)

If you discover any security-related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

Mohit Aneja All Contributors

License
-------

[](#license)

MIT Please see the license for more information.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1763d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5541a1a071762f2e5261769b015802a4f5c8c01b4655e8ffc87c6ff0f3e6db9e?d=identicon)[cssjockey](/maintainers/cssjockey)

---

Top Contributors

[![maneja81](https://avatars.githubusercontent.com/u/1508283?v=4)](https://github.com/maneja81 "maneja81 (11 commits)")

---

Tags

bladedirectiveslaravelutilitieslaravelLaravelDirectives

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cssjockey-laravel-directives/health.svg)

```
[![Health](https://phpackages.com/badges/cssjockey-laravel-directives/health.svg)](https://phpackages.com/packages/cssjockey-laravel-directives)
```

###  Alternatives

[robsontenorio/mary

Gorgeous UI components for Livewire powered by daisyUI and Tailwind

1.5k454.7k15](/packages/robsontenorio-mary)[stijnvanouplines/blade-country-flags

A package to easily make use of country flags in your Laravel Blade views.

26307.2k6](/packages/stijnvanouplines-blade-country-flags)[technikermathe/blade-lucide-icons

A package to easily make use of Lucide icons in your Laravel Blade views.

18299.2k7](/packages/technikermathe-blade-lucide-icons)[saade/blade-iconsax

A package to easily make use of Iconsax in your Laravel Blade views.

21138.5k](/packages/saade-blade-iconsax)[mckenziearts/blade-untitledui-icons

A package to easily make use of UntitledUI icons in your Laravel Blade views.

16104.9k5](/packages/mckenziearts-blade-untitledui-icons)[webup/laravel-form

A Laravel package to help build forms.

147.2k1](/packages/webup-laravel-form)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
