jeudi 1 juin 2017

Laravel 5.4 Use If/Else inside of a controller

I'm trying to use @if & @else inside a controller, eg:

public function deleteCharacter ($char_delete_id)

    {

@if (Auth::user()->id == $delCharacterUserID) 
$deleteSuccess = 1;

            return redirect('/characters')->with('deleteSuccess', $deleteSuccess); 


@else 
      $deleteSuccess = 0;

        return redirect('/characters')->with('deleteSuccess', $deleteSuccess); 

    @endif

This throws the error:

FatalErrorException in CharacterController.php line 40: syntax error, unexpected 'if' (T_IF)



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2rdUH4U
via IFTTT

Aucun commentaire:

Enregistrer un commentaire