Skip to content

Commit

Permalink
Autocomplete all Blade directives via Laravel Idea plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenpaauw committed Oct 22, 2022
1 parent cbd19cf commit cdf7302
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 10 deletions.
43 changes: 33 additions & 10 deletions docs/advanced-usage/phpstorm.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ weight: 8

# Extending PhpStorm

> **Note**
> When using Laravel Idea plugin all directives are automatically added.
You may wish to extend PhpStorm to support Blade Directives of this package.

1. In PhpStorm, open Preferences, and navigate to **Languages and Frameworks -> PHP -> Blade**
Expand All @@ -16,11 +19,17 @@ You may wish to extend PhpStorm to support Blade Directives of this package.
**role**

- has parameter = YES
- Prefix: `<?php if(auth()->check() && auth()->user()->hasRole(`
- Suffix: `)); ?>`
- Prefix: `<?php if(\\Spatie\\Permission\\PermissionServiceProvider::bladeMethodWrapper('hasRole', {`
- Suffix: `})): ?>`

--

**elserole**

- has parameter = YES
- Prefix: `<?php elseif(\\Spatie\\Permission\\PermissionServiceProvider::bladeMethodWrapper('hasRole', {`
- Suffix: `})): ?>`

**endrole**

- has parameter = NO
Expand All @@ -32,8 +41,8 @@ You may wish to extend PhpStorm to support Blade Directives of this package.
**hasrole**

- has parameter = YES
- Prefix: `<?php if(auth()->check() && auth()->user()->hasRole(`
- Suffix: `)); ?>`
- Prefix: `<?php if(\\Spatie\\Permission\\PermissionServiceProvider::bladeMethodWrapper('hasRole', {`
- Suffix: `})): ?>`

--

Expand All @@ -48,8 +57,8 @@ You may wish to extend PhpStorm to support Blade Directives of this package.
**hasanyrole**

- has parameter = YES
- Prefix: `<?php if(auth()->check() && auth()->user()->hasAnyRole(`
- Suffix: `)); ?>`
- Prefix: `<?php if(\\Spatie\\Permission\\PermissionServiceProvider::bladeMethodWrapper('hasAnyRole', {`
- Suffix: `})): ?>`

--

Expand All @@ -64,8 +73,8 @@ You may wish to extend PhpStorm to support Blade Directives of this package.
**hasallroles**

- has parameter = YES
- Prefix: `<?php if(auth()->check() && auth()->user()->hasAllRoles(`
- Suffix: `)); ?>`
- Prefix: `<?php if(\\Spatie\\Permission\\PermissionServiceProvider::bladeMethodWrapper('hasAllRoles', {`
- Suffix: `})): ?>`

--

Expand All @@ -80,8 +89,8 @@ You may wish to extend PhpStorm to support Blade Directives of this package.
**unlessrole**

- has parameter = YES
- Prefix: `<?php if(auth()->check() && !auth()->user()->hasRole(`
- Suffix: `)); ?>`
- Prefix: `<?php if(! \\Spatie\\Permission\\PermissionServiceProvider::bladeMethodWrapper('hasRole', {`
- Suffix: `})): ?>`

--

Expand All @@ -92,3 +101,17 @@ You may wish to extend PhpStorm to support Blade Directives of this package.
- Suffix: blank

--

**hasexactroles**

- has parameter = YES
- Prefix: `<?php if(\\Spatie\\Permission\\PermissionServiceProvider::bladeMethodWrapper('hasExactRoles', {`
- Suffix: `})): ?>`

--

**endhasexactroles**

- has parameter = NO
- Prefix: blank
- Suffix: blank
72 changes: 72 additions & 0 deletions ide.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"$schema": "https://laravel-ide.com/schema/laravel-ide-v2.json",
"blade": {
"directives": [
{
"name": "role",
"prefix": "<?php if(\\Spatie\\Permission\\PermissionServiceProvider::bladeMethodWrapper('hasRole', {",
"suffix": "})): ?>"
},
{
"name": "elserole",
"prefix": "<?php elseif(\\Spatie\\Permission\\PermissionServiceProvider::bladeMethodWrapper('hasRole', {",
"suffix": "})): ?>"
},
{
"name": "endrole",
"prefix": "",
"suffix": ""
},
{
"name": "hasrole",
"prefix": "<?php if(\\Spatie\\Permission\\PermissionServiceProvider::bladeMethodWrapper('hasRole', {",
"suffix": "})): ?>"
},
{
"name": "endhasrole",
"prefix": "",
"suffix": ""
},
{
"name": "hasanyrole",
"prefix": "<?php if(\\Spatie\\Permission\\PermissionServiceProvider::bladeMethodWrapper('hasAnyRole', {",
"suffix": "})): ?>"
},
{
"name": "endhasanyrole",
"prefix": "",
"suffix": ""
},
{
"name": "hasallroles",
"prefix": "<?php if(\\Spatie\\Permission\\PermissionServiceProvider::bladeMethodWrapper('hasAllRoles', {",
"suffix": "})): ?>"
},
{
"name": "endhasallroles",
"prefix": "",
"suffix": ""
},
{
"name": "unlessrole",
"prefix": "<?php if(! \\Spatie\\Permission\\PermissionServiceProvider::bladeMethodWrapper('hasRole', {",
"suffix": "})): ?>"
},
{
"name": "endunlessrole",
"prefix": "",
"suffix": ""
},
{
"name": "hasexactroles",
"prefix": "<?php if(\\Spatie\\Permission\\PermissionServiceProvider::bladeMethodWrapper('hasExactRoles', {",
"suffix": "})): ?>"
},
{
"name": "endhasexactroles",
"prefix": "",
"suffix": ""
}
]
}
}

0 comments on commit cdf7302

Please sign in to comment.