app/Http/Controllers/HomeController.php
/**
     * Show the application dashboard.
     *
     * @return \Illuminate\Http\Response
     */
Show the application dashboard.
@return \Illuminate\Http\Response
Show the application dashboard . @return \ Illuminate \ Http \ Response
public function index(Request $request, ContactInvite $invite, Portfolio $portfolio, User $user, Task $task)
    {   
        $portfolios = $this->getPortfolios(16);
        $user_profile = $request->user()->profile()->first();
        $activities = fractal()->collection($portfolios)
                                ->transformWith(new PortfolioTransformer)
                                ->serializeWith(new \Spatie\Fractalistic\ArraySerializer())
                                ->toArray();
        $tasks = fractal()->collection($tasks = $task->isPublic()->isApproved()->orderDesc()->take(5)->get())
                          ->transformWith(new TaskTransformer)
                          ->serializeWith(new \Spatie\Fractalistic\ArraySerializer())
                          ->toArray();
        $people = null;
        if(!$activities){
            $defaults = [
                'location'  => '%Lagos',
            ];
            $collection = $user->where('id', '!=', $request->user()->id)->has('portfolio')->withCount(['portfolio' => function($query){
                                $query->where('is_public', true);
                            }])->orderBy('portfolio_count', 'desc')->take(10)->get();
            $people = fractal()->collection($collection)
                            ->transformWith(new UserTransformers)
                            ->serializeWith(new \Spatie\Fractalistic\ArraySerializer())
                            ->toArray();
        }
        $email = $request->user()->email;
        $inviteStatus = true;
        $gmailCheck =  preg_match('/(@gmail.com)$/', $email); 
        if($gmailCheck){
            $hasInvited = $invite->where('invitee_email', $email)->get();
            if($hasInvited->count()){
                $inviteStatus = true;
            } else {
                $inviteStatus = false;
            }
        }
        $user = fractal()->item($user_profile)
                            ->transformWith(new ProfileTransformers)
                            ->serializeWith(new \Spatie\Fractalistic\ArraySerializer())
                            ->toArray();
        return view('home')->with([
            'user'      => $user,
            'activities'=> $activities,
            'gmail'     => (bool)$gmailCheck,
            'invite_status' => $inviteStatus,
            'profiles'  => $people, 
            'tasks'     => $tasks,
        ]);
    }
public function index ( Request $ request , ContactInvite $ invite , Portfolio $ portfolio , User $ user , Task $ task ) { $ portfolios = $ this -> getPortfolios ( 16 ) ; $ user_profile = $ request -> user ( ) -> profile ( ) -> first ( ) ; $ activities = fractal ( ) -> collection ( $ portfolios ) -> transformWith ( new PortfolioTransformer ) -> serializeWith ( new \ Spatie \ Fractalistic \ ArraySerializer ( ) ) -> toArray ( ) ; $ tasks = fractal ( ) -> collection ( $ tasks = $ task -> isPublic ( ) -> isApproved ( ) -> orderDesc ( ) -> take ( 5 ) -> get ( ) ) -> transformWith ( new TaskTransformer ) -> serializeWith ( new \ Spatie \ Fractalistic \ ArraySerializer ( ) ) -> toArray ( ) ; $ people = null ; if ( ! $ activities ) { $ defaults = [ 'location' => '%Lagos' , ] ; $ collection = $ user -> where ( 'id' , '!=' , $ request -> user ( ) -> id ) -> has ( 'portfolio' ) -> withCount ( [ 'portfolio' => function ( $ query ) { $ query -> where ( 'is_public' , true ) ; } ] ) -> orderBy ( 'portfolio_count' , 'desc' ) -> take ( 10 ) -> get ( ) ; $ people = fractal ( ) -> collection ( $ collection ) -> transformWith ( new UserTransformers ) -> serializeWith ( new \ Spatie \ Fractalistic \ ArraySerializer ( ) ) -> toArray ( ) ; } $ email = $ request -> user ( ) -> email ; $ inviteStatus = true ; $ gmailCheck = preg_match ( '/(@gmail.com)$/' , $ email ) ; if ( $ gmailCheck ) { $ hasInvited = $ invite -> where ( 'invitee_email' , $ email ) -> get ( ) ; if ( $ hasInvited -> count ( ) ) { $ inviteStatus = true ; } else { $ inviteStatus = false ; } } $ user = fractal ( ) -> item ( $ user_profile ) -> transformWith ( new ProfileTransformers ) -> serializeWith ( new \ Spatie \ Fractalistic \ ArraySerializer ( ) ) -> toArray ( ) ; return view ( 'home' ) -> with ( [ 'user' => $ user , 'activities' => $ activities , 'gmail' => ( bool ) $ gmailCheck , 'invite_status' => $ inviteStatus , 'profiles' => $ people , 'tasks' => $ tasks , ] ) ; }
Show the application dashboard.
Show the application dashboard .
// dd($activities); //$request->user()->email