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)



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire