Skip to content

Commit 65a61d0

Browse files
committed
Add mention of elsecan and elsecannot directives
This is just a draft (making a point) and should be rewritten because section below does not mention anything about these two directives. - mentioning use of @else directive in between @can and @endcan might be also useful
1 parent eb5af56 commit 65a61d0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

authorization.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,14 +292,18 @@ As previously discussed, some actions like `create` may not require a model inst
292292
<a name="via-blade-templates"></a>
293293
### Via Blade Templates
294294

295-
When writing Blade templates, you may wish to display a portion of the page only if the user is authorized to perform a given action. For example, you may wish to show an update form for a blog post only if the user can actually update the post. In this situation, you may use the `@can` and `@cannot` directives.
295+
When writing Blade templates, you may wish to display a portion of the page only if the user is authorized to perform a given action. For example, you may wish to show an update form for a blog post only if the user can actually update the post. In this situation, you may use the `@can` and `@cannot` directives as well as `@elsecan` and `@elsecannot`.
296296

297297
@can('update', $post)
298298
<!-- The Current User Can Update The Post -->
299+
@elsecan('create', $post)
300+
<!-- The Current User Can Create New Post -->
299301
@endcan
300302

301303
@cannot('update', $post)
302304
<!-- The Current User Can't Update The Post -->
305+
@elsecannot('create', $post)
306+
<!-- The Current User Can't Create New Post -->
303307
@endcannot
304308

305309
These directives are convenient shortcuts for writing `@if` and `@unless` statements. The `@can` and `@cannot` statements above respectively translate to the following statements:

0 commit comments

Comments
 (0)