Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete all Blade directives via Laravel Idea plugin #2210

Merged
merged 1 commit into from
Oct 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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": ""
}
]
}
}