Error Call to a member function with () on string Laravel

0

At the time of executing the next destroy function, I get an error regarding the function with de laravel, they could help me.

function destroy($id,$route='none' ){
    $destroy = User::find($id);
    $destroy->delete();
    if($route == 'equal'){
        return back()->with('info','Usuario eliminado');
    }else{
        return route('home')->with('info','Usuario eliminado');
    }
}
    
asked by Camilo 05.05.2018 в 19:25
source

2 answers

1

You have to use the method redirect() before back() or route()

function destroy($id,$route='none' ){
    $destroy = User::find($id);
    $destroy->delete();
    if($route == 'equal'){
        return redirect()->back()->with('info','Usuario eliminado');
    }else{
        return redirect()->route('home')->with('info','Usuario eliminado');
    }
}
    
answered by 06.05.2018 в 15:33
0

You mark this error because you must first access the redirect method, then route and finally the with method and the same for the back

method
return redirect()->route('home')->with('info', 'Usuario eliminado');

Here you have more information about it

link

    
answered by 06.05.2018 в 16:30