Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@cannot statement from Blade engine not working

I'm trying to use @cannot in my template but I have the following issue. With the code:

@section('content')
    @can('upload-images',$flyer)
        <form action="{{ URL::to('/') }}/{{ $flyer->zip }}/{{ $flyer->street }}/photos" method="POST" class="dropzone" enctype="multipart/form-data">
            {{ csrf_field() }}
        </form>
    @endcan
    @cannot
        <p>Not allowed</p>
    @endcannot
@stop

@cannot throws the following error:

Undefined class constant 'denies'

I know @cannot exists and also that uses Gate::denies, which is the error I'm taking, here is the Github commit where the magic should occur:

https://github.com/laravel/framework/commit/9c41aa0d53412e3008285e89ff9764fa51b42469

Any clues? Thanks!

like image 469
Joss Avatar asked Sep 15 '25 02:09

Joss


1 Answers

Laravel's doc has being updated. I should use @else:

@can(...)
@else
@endcan

And @cannot should be used as the opposite of @can, but never at the same time:

@cannot(...)
@else
@endcannot
like image 142
Joss Avatar answered Sep 16 '25 18:09

Joss