Skip to content

Commit cdf7302

Browse files
committed
Autocomplete all Blade directives via Laravel Idea plugin
1 parent cbd19cf commit cdf7302

File tree

2 files changed

+105
-10
lines changed

2 files changed

+105
-10
lines changed

docs/advanced-usage/phpstorm.md

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ weight: 8
55

66
# Extending PhpStorm
77

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

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

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

2225
--
2326

27+
**elserole**
28+
29+
- has parameter = YES
30+
- Prefix: `<?php elseif(\\Spatie\\Permission\\PermissionServiceProvider::bladeMethodWrapper('hasRole', {`
31+
- Suffix: `})): ?>`
32+
2433
**endrole**
2534

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

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

3847
--
3948

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

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

5463
--
5564

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

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

7079
--
7180

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

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

8695
--
8796

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

94103
--
104+
105+
**hasexactroles**
106+
107+
- has parameter = YES
108+
- Prefix: `<?php if(\\Spatie\\Permission\\PermissionServiceProvider::bladeMethodWrapper('hasExactRoles', {`
109+
- Suffix: `})): ?>`
110+
111+
--
112+
113+
**endhasexactroles**
114+
115+
- has parameter = NO
116+
- Prefix: blank
117+
- Suffix: blank

ide.json

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"$schema": "https://laravel-ide.com/schema/laravel-ide-v2.json",
3+
"blade": {
4+
"directives": [
5+
{
6+
"name": "role",
7+
"prefix": "<?php if(\\Spatie\\Permission\\PermissionServiceProvider::bladeMethodWrapper('hasRole', {",
8+
"suffix": "})): ?>"
9+
},
10+
{
11+
"name": "elserole",
12+
"prefix": "<?php elseif(\\Spatie\\Permission\\PermissionServiceProvider::bladeMethodWrapper('hasRole', {",
13+
"suffix": "})): ?>"
14+
},
15+
{
16+
"name": "endrole",
17+
"prefix": "",
18+
"suffix": ""
19+
},
20+
{
21+
"name": "hasrole",
22+
"prefix": "<?php if(\\Spatie\\Permission\\PermissionServiceProvider::bladeMethodWrapper('hasRole', {",
23+
"suffix": "})): ?>"
24+
},
25+
{
26+
"name": "endhasrole",
27+
"prefix": "",
28+
"suffix": ""
29+
},
30+
{
31+
"name": "hasanyrole",
32+
"prefix": "<?php if(\\Spatie\\Permission\\PermissionServiceProvider::bladeMethodWrapper('hasAnyRole', {",
33+
"suffix": "})): ?>"
34+
},
35+
{
36+
"name": "endhasanyrole",
37+
"prefix": "",
38+
"suffix": ""
39+
},
40+
{
41+
"name": "hasallroles",
42+
"prefix": "<?php if(\\Spatie\\Permission\\PermissionServiceProvider::bladeMethodWrapper('hasAllRoles', {",
43+
"suffix": "})): ?>"
44+
},
45+
{
46+
"name": "endhasallroles",
47+
"prefix": "",
48+
"suffix": ""
49+
},
50+
{
51+
"name": "unlessrole",
52+
"prefix": "<?php if(! \\Spatie\\Permission\\PermissionServiceProvider::bladeMethodWrapper('hasRole', {",
53+
"suffix": "})): ?>"
54+
},
55+
{
56+
"name": "endunlessrole",
57+
"prefix": "",
58+
"suffix": ""
59+
},
60+
{
61+
"name": "hasexactroles",
62+
"prefix": "<?php if(\\Spatie\\Permission\\PermissionServiceProvider::bladeMethodWrapper('hasExactRoles', {",
63+
"suffix": "})): ?>"
64+
},
65+
{
66+
"name": "endhasexactroles",
67+
"prefix": "",
68+
"suffix": ""
69+
}
70+
]
71+
}
72+
}

0 commit comments

Comments
 (0)