@
@
@atambalasi2015-11-01 19:16:21
Laravel
@atambalasi, 2015-11-01 19:16:21

Why doesn't a private method return a result?

I have a controller with two methods

class ProfileController extends Controller
{
 public function showProfile()
  {
    self::checkUserAuth();	
  }
  
  private function checkUserAuth() 
  {
    if (Auth::check()) 
    {
    		return view('profile.index');
    }
    else
    {
      
      return redirect('/');	
    }
  }
}
}
the checkUserAuth() method does not return a result or is not called.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
J
JhaoDa, 2015-11-01
@JhaoDa

I highly recommend learning the basics of PHP.

public function showProfile()
{
    return $this->checkUserAuth();	
}

S
Sergey, 2015-11-01
Protko @Fesor

an error in the showProfile method... I see no point in suggesting further.
ps I advise you to read the documentation for PHP.

A
Alexey, 2015-11-02
@AlekseyChuyan

You access static methods by "::", use "->".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question