Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

cascaded isset with different if's don't work

How do you set up multiple issets in cascade in a view?

<div class="row">
    <div class="col-12 col-md-10 d-flex justify-content-center">
        @if (@isset($client_name))
        <h1>List of the overall tasks of the{{$client_name}}</h1> 
        @if (@isset($project_name_tasks))
        <h1>List of project tasks of {{$project_name_tasks}} </h1>
        @else
        <h1>List of project tasks</h1>
        @endif
        @endisset
    </div>
</div>

It does not work properly.

Can someone help me?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You should use:

@isset($client_name)
    <h1>List of the overall tasks of the{{$client_name}}</h1> 
    @isset($project_name_tasks)
        <h1>List of project tasks of {{$project_name_tasks}} </h1>
    @else
        <h1>List of project tasks</h1>
    @endisset
@endisset

because@isset is Blade directive, so no need to have extra @if.

Alternatively you can of course use isset function from PHP but then you don’t need to prefix it with @ so it should look like:

@if(isset($client_name))
    <h1>List of the overall tasks of the{{$client_name}}</h1> 
    @if(isset($project_name_tasks))
        <h1>List of project tasks of {{$project_name_tasks}} </h1>
    @else
        <h1>List of project tasks</h1>
    @endif
@endif

–EDIT–

If each isset is separate from each other you should just close condition earlier so:

@isset($client_name)
    <h1>List of the overall tasks of the{{$client_name}}</h1> 
@endisset
@isset($project_name_tasks)
   <h1>List of project tasks of {{$project_name_tasks}} </h1>
@else
  <h1>List of project tasks</h1>
@endisset

@endisset

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading