Completed
Push — master ( 55f4d0...97c563 )
by PROSPER
03:11
created

FacebookController::getPage()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 14
rs 9.4285
cc 2
eloc 7
nc 2
nop 0
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use Illuminate\Http\Request;
6
7
use App\Http\Requests;
8
use App\Http\Controllers\Controller;
9
use Facebook;
10
use App\User;
11
use Auth;
12
use Session;
13
use Illuminate\Support\Collection;
14
15
class FacebookController extends Controller
16
{
17
    protected $user;
18
19
    /**
20
     * Return all data to the Facebook API dashboard
21
     * @return mixed
22
     */
23
    public function getPage()
24
    {
25
        if( Session::get('provider') !== 'facebook') {
26
            Auth::logout();
27
28
            Session::flush();
29
30
            return redirect('/auth/facebook');
31
        }
32
33
        $userDetails = $this->getData();
34
35
        return view('api.facebook')->withDetails($userDetails);
36
    }
37
38
    /**
39
     * [getData description]
40
     * @return [type] [description]
0 ignored issues
show
Documentation introduced by
The doc-type [type] could not be parsed: Unknown type name "" at position 0. [(view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
41
     */
42
    private function getData()
43
    {
44
       $data = Facebook::get('/me?fields=id,name,cover,email,gender,first_name,last_name,locale,timezone,link,picture', Auth::user()->getAccessToken());
45
46
      return json_decode($data->getGraphUser(),true);
47
    }
48
}
49