I am already sending a variable using Auth::login($user) and setting it inside an array in my routes. Want to send an additional array, everything i tried failed.
Code I have
Controller
public function callback(){
if( !$this->fb->generateSessionFromRedirect() ){
return Redirect::to('/')->with('message', "Error logging into facebook");
}
$user_fb = $this->fb->getGraph();
if(empty($user_fb)) {
return Redirect::to('/')->with('message', "User Not Found");
}
$user = User::whereUidFb($user_fb->getProperty('id'))->first();
if(empty($user)){
$user = new User;
$user->name = $user_fb->getProperty('name');
$user->uid_fb = $user_fb->getProperty('id');
$user->save();
}
$user->access_token_fb = $this->fb->getToken();
$user->save();
$user_pages = $this->fb->getPages();
// var_dump($user_pages);
Auth::login($user);
return Redirect::to('/')->with(array('pages' => $user_pages));
}
ROUTE
Route::get('/', function()
{
$user = array();
if(Auth::check()) {
$user = Auth::user();
}
return View::make('hello', array('user' => $user));
});
So I want to send $user_pages, right now I have access to only $user. Tried running a foreach loop for $pages in my view, but doesnt identify the variable. So i am guessing I have to do something in routes and send it the same way I am sending $data.
Any Help?
$data? You make things more confusing for yourself and others if you come up with arbitrary variable names.callback()being called in your code. In the declared route you're only returning the data variable (which I would rename to user). I'd recommend you to watch the Laravel beginner video's on Laracast.