/**
  * Handle the command.
  *
  * @param  FollowUserCommand  $command
  * @return void
  */
 public function handle(FollowUserCommand $command)
 {
     //
     $follow = new Follow();
     $follow->user_id = Auth::id();
     $follow->followed_id = $command->userId;
     $follow->save();
 }
 /**
  * Handle the command.
  *
  * @param  UnFollowUserCommand  $command
  * @return void
  */
 public function handle(UnFollowUserCommand $command)
 {
     //
     //dd($command);
     $follow = Follow::whereRaw('user_id=? AND followed_id=?', [Auth::id(), $command->userId])->firstOrFail();
     $follow->delete();
 }
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     Like::creating(function ($attribute) {
         // -1 like_left for media
         $media = Media::findOrFail($attribute->media_id);
         $media->likes_left = $media->likes_left - 1;
         $media->save();
         // +1 credit for liker of media
         $user = User::findOrFail($attribute->user_id);
         if ($user->pro_user) {
             $user->credit = $user->credit + 3;
             //for pro user
         } else {
             $user->credit = $user->credit + 1;
         }
         $user->save();
     });
     Follow::creating(function ($attribute) {
         // -1 like_left for media
         $user = User::findOrFail($attribute->follow_id);
         $user->followers_left = $user->followers_left - 1;
         $user->save();
         // +1 credit for liker of media
         $user = User::findOrFail($attribute->user_id);
         if ($user->pro_user) {
             $user->credit = $user->credit + 3;
             //for pro user
         } else {
             $user->credit = $user->credit + 1;
         }
         $user->save();
     });
 }
Example #4
0
 public function run()
 {
     for ($x = 1; $x <= 25; $x++) {
         $user = User::find(rand(1, 5));
         $f_user = User::find(rand(6, 10));
         Follow::create(['user_id' => $user->id, 'following_user_id' => $f_user->id]);
     }
 }
 public static function unFollow($followData)
 {
     $followed = Follow::where('user_id', $followData['user_id'])->where('follow_user_id', $followData['follow_user_id']);
     if ($followed->delete()) {
         return true;
     } else {
         return false;
     }
 }
Example #6
0
 public function run()
 {
     $faker = Faker::create();
     $userIds = User::lists('id');
     $groupIds = Group::lists('id');
     foreach (range(1, 200) as $index) {
         Follow::create(['user_id' => $faker->randomElement($userIds), 'group_id' => $faker->randomElement($groupIds)]);
     }
 }
 /**
  * Follows a user.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $user = User::where('username', $request->username)->first();
     if (!$user) {
         return response()->json(['success' => false, 'message' => "No such user in our DB"]);
     }
     if (!$user->followable) {
         return response()->json(['success' => false, 'message' => "You cannot follow this user"]);
     }
     return response()->json(['success' => true, 'message' => "Successfully followed", 'like' => Follow::create(['user_id' => User::getCurrentUserId(), 'follow_id' => $user->id])]);
 }
Example #8
0
 public function index()
 {
     $tweet_all = Tweet::all();
     $follow_all = Follow::all();
     $user_follow = $follow_all->filter(function ($item) {
         return $item['user_id'] == Auth::user()->id;
     })->pluck('follow_id');
     $data['tweets'] = $tweet_all;
     $data['followed'] = $user_follow->toArray();
     return view('tweet/home', $data);
 }
Example #9
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function followIt()
 {
     // $type = $input['toType'];
     // $typeId = $input['typeId'];
     return var_dump($request->all());
     //returns the changed follow permission for requested data
     $follow = Follow::firstOrNew(['user_id' => Auth::user()->id, 'toType' => $type, 'typeId' => $typeId]);
     $follow->user_id = Auth::user()->id;
     $follow->toType = $type;
     $follow->typeId = $typeId;
     $follow->permit = !$user->permit;
     $follow->epochUpdatedAt = time();
     $follow->save();
     return $follow->permit;
 }
Example #10
0
 public function followable()
 {
     $user_id = User::getCurrentUserId();
     //Check if the user was already followed by the current user
     $follow = Follow::where('follow_id', $this->id)->where('user_id', $user_id)->first();
     //check if the user has any show_to
     if ($this->show_to == null) {
         //if show_to is null, that is can be shown to everybody.
         return !(bool) $follow;
     } else {
         if (User::find(User::getCurrentUserId())->country == $this->show_to) {
             //if user show to and current user are from same country
             return !(bool) $follow;
         } else {
             return false;
         }
     }
 }
Example #11
0
    public function searchProfile()
    {
        if (Auth::check()) {
            $title = 'Profile search';
            $city = Input::get('city');
            $name = Input::get('name');
            $role = Input::get('role');
            $working_at = Input::get('working_at');
            $mobile = Input::get('mobile');
            $type = Input::get('type');
            $firm_type = Input::get('firm_type');
            // return $firm_type;
            if ($type == 'people') {
                $users = Induser::with('user')->orderBy('id', 'desc')->where('id', '!=', Auth::user()->induser_id);
                if ($name != null) {
                    $users->whereRaw("(fname like '%" . $name . "%' or lname like '%" . $name . "%' or email = '" . $name . "')");
                }
                if ($city != null) {
                    $pattern = '/\\s*,\\s*/';
                    $replace = ',';
                    $city = preg_replace($pattern, $replace, $city);
                    $cityArray = explode(',', $city);
                    $users->whereIn('city', $cityArray);
                }
                if ($role != null) {
                    $users->where('role', 'like', '%' . $role . '%');
                }
                if ($working_at != null) {
                    $users->where('working_at', 'like', '%' . $working_at . '%');
                }
                if ($mobile != null) {
                    $users->where('mobile', 'like', '%' . $mobile . '%');
                }
                $users = $users->paginate(15);
                $links = DB::select('select id from indusers
									where indusers.id in (
											select connections.user_id as id from connections
											where connections.connection_user_id=?
											 and connections.status=1
											union 
											select connections.connection_user_id as id from connections
											where connections.user_id=?
											 and connections.status=1
								)', [Auth::user()->induser_id, Auth::user()->induser_id]);
                $links = collect($links);
                // return $users;
                return view('pages.profileSearch', compact('users', 'title', 'links', 'type', 'corpsearchprofile', 'perPeople', 'perpeopleSkill'));
            } elseif ($type == 'company') {
                $users = Corpuser::with('user')->orderBy('id', 'desc');
                if ($name != null) {
                    $users->whereRaw("(firm_name like '%" . $name . "%' or firm_email_id = '" . $name . "')");
                }
                if ($city != null) {
                    $pattern = '/\\s*,\\s*/';
                    $replace = ',';
                    $city = preg_replace($pattern, $replace, $city);
                    $cityArray = explode(',', $city);
                    $users->whereIn('city', $cityArray);
                }
                if ($role != null) {
                    $users->where('role', 'like', '%' . $role . '%');
                }
                if ($firm_type != null) {
                    $users->whereIn('firm_type', $firm_type);
                }
                $users = $users->paginate(15);
                $following = DB::select('select id from corpusers 
										 where corpusers.id in (
											select follows.corporate_id as id from follows
											where follows.individual_id=?
									)', [Auth::user()->induser_id]);
                $following = collect($following);
                $followCount = Follow::where('corporate_id', '=', Auth::user()->induser_id)->orWhere('individual_id', '=', Auth::user()->induser_id)->count('id');
                return view('pages.profileSearch', compact('users', 'title', 'following', 'type', 'followCount'));
            }
        }
    }
Example #12
0
 public function seguidor(User $user, $id)
 {
     $count = Follow::where('userfolow_id', $user->id)->where('user_id', $id)->first();
     return $count;
 }
Example #13
0
 public function followed_by()
 {
     $follows = Follow::all();
     $user_ids_array = [];
     foreach ($follows as $f) {
         if ($f->followed_user_id == $this->id) {
             $user_ids_array[] = $f->follower_id;
         }
     }
     return $user_ids_array;
 }
Example #14
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $follow = Follow::find($id);
     $user = User::find($follow->user_id);
     Follow::destroy($id);
     return redirect('users');
 }
 /**
  * Send Follow Request
  *
  * @return View
  */
 public function UnfollowArtist($id)
 {
     $user = Auth::user();
     $artist = Artist::find($id);
     if ($artist) {
         $follow = Follow::where('artist_id', $id)->where('user_id', $user->id)->first();
         $follow->delete();
         return redirect('artist/' . $artist->id)->with('success', 'You Unfollowed ' . $artist->user->firstname);
     }
     return redirect('artist/' . $artist->id);
 }
 public function linkPageUnfollow($id)
 {
     $follow = Follow::where('corporate_id', '=', $id)->where('individual_id', '=', Auth::user()->induser_id)->first();
     $follow->delete();
     return redirect('/links');
 }
Example #17
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $a = Post::all()->lists('content');
     //array de contenidos
     $b = implode(" ", $a);
     // String completo
     $c = explode(" ", $b);
     // array de palabras
     $hola = 5;
     //funcion de filter
     $e = array_filter($c, function ($var) {
         return strlen($var) >= 4;
     });
     //funcion de filter
     $d = array_count_values($e);
     // array con su contador
     arsort($d);
     $arrays = array_slice($d, 0, 5);
     $user = User::where('name', $id)->first();
     $users = User::all();
     $reposts = Repost::where('user_id', $id)->get();
     $follows = Follow::where('userfolow_id', $id)->get();
     return view('users.show', compact('user', 'follows', 'users', 'reposts', 'arrays'));
 }
Example #18
0
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     view()->composer('includes-update.header', function ($view) {
         $thanksCount = 0;
         $followCount = 0;
         if (Auth::user()->identifier == 1 || Auth::user()->identifier == 3) {
             $user = Induser::where('id', '=', Auth::user()->induser_id)->first();
             $favourites = Postactivity::with('user')->where('fav_post', '=', 1)->where('user_id', '=', Auth::user()->id)->orderBy('id', 'desc')->get(['id', 'fav_post', 'fav_post_dtTime', 'user_id', 'post_id']);
             $thanksCount = Postactivity::with('user', 'post')->join('postjobs', 'postjobs.id', '=', 'postactivities.post_id')->where('postjobs.individual_id', '=', Auth::user()->induser_id)->where('postactivities.thanks', '=', 1)->orderBy('postactivities.id', 'desc')->sum('postactivities.thanks');
             $linksCount = Connections::where('user_id', '=', Auth::user()->induser_id)->where('status', '=', 1)->orWhere('connection_user_id', '=', Auth::user()->induser_id)->where('status', '=', 1)->count('id');
             $linkrequestCount = Connections::where('connection_user_id', '=', Auth::user()->induser_id)->where('status', '=', 0)->count('id');
             $groupCount = Groups_users::where('user_id', '=', Auth::user()->induser_id)->count('id');
             $postCount = Postjob::where('individual_id', '=', Auth::user()->induser_id)->count('id');
             $profilePer = 0;
             if (Auth::user()->induser->fname != null) {
                 $profilePer = $profilePer + 1;
             }
             if (Auth::user()->induser->lname != null) {
                 $profilePer = $profilePer + 1;
             }
             if (Auth::user()->induser->email != null) {
                 $profilePer = $profilePer + 1;
             }
             if (Auth::user()->induser->mobile != null) {
                 $profilePer = $profilePer + 1;
             }
             if (Auth::user()->induser->dob != null) {
                 $profilePer = $profilePer + 1;
             }
             if (Auth::user()->induser->city != null) {
                 $profilePer = $profilePer + 1;
             }
             if (Auth::user()->induser->fb_page != null) {
                 $profilePer = $profilePer + 1;
             }
             if (Auth::user()->induser->in_page != null) {
                 $profilePer = $profilePer + 1;
             }
             if (Auth::user()->induser->gender != null) {
                 $profilePer = $profilePer + 1;
             }
             if (Auth::user()->induser->about_individual != null) {
                 $profilePer = $profilePer + 1;
             }
             if (Auth::user()->induser->education != null) {
                 $profilePer = $profilePer + 1;
             }
             if (Auth::user()->induser->experience != null) {
                 $profilePer = $profilePer + 1;
             }
             if (Auth::user()->induser->working_status != null) {
                 $profilePer = $profilePer + 1;
             }
             if (Auth::user()->induser->working_at != null) {
                 $profilePer = $profilePer + 1;
             }
             if (Auth::user()->induser->role != null) {
                 $profilePer = $profilePer + 1;
             }
             if (Auth::user()->induser->linked_skill != null) {
                 $profilePer = $profilePer + 1;
             }
             if (Auth::user()->induser->resume != null) {
                 $profilePer = $profilePer + 1;
             }
             if (Auth::user()->induser->prefered_location != null) {
                 $profilePer = $profilePer + 1;
             }
             if (Auth::user()->induser->prefered_jobtype != null) {
                 $profilePer = $profilePer + 1;
             }
             if (Auth::user()->induser->profile_pic != null) {
                 $profilePer = $profilePer + 1;
             }
             $profilePer = round($profilePer / 20 * 100);
         } else {
             if (Auth::user()->identifier == 2 || Auth::user()->identifier == 3) {
                 $user = Corpuser::where('id', '=', Auth::user()->corpuser_id)->first();
                 $followCount = Follow::where('corporate_id', '=', 1)->orWhere('individual_id', '=', 1)->count('id');
                 $linksCount = "";
                 $linkrequestCount = "";
                 $groupCount = "";
                 $postCount = Postjob::where('corporate_id', '=', Auth::user()->corpuser_id)->count('id');
                 $favourites = Postactivity::with('user')->where('fav_post', '=', 1)->where('user_id', '=', Auth::user()->id)->orderBy('id', 'desc')->get(['id', 'fav_post', 'fav_post_dtTime', 'user_id', 'post_id']);
                 $profilePer = 0;
                 if (Auth::user()->corpuser->firm_name != null) {
                     $profilePer = $profilePer + 1;
                 }
                 if (Auth::user()->corpuser->username != null) {
                     $profilePer = $profilePer + 1;
                 }
                 if (Auth::user()->corpuser->firm_type != null) {
                     $profilePer = $profilePer + 1;
                 }
                 if (Auth::user()->corpuser->emp_count != null) {
                     $profilePer = $profilePer + 1;
                 }
                 if (Auth::user()->corpuser->working_as != null) {
                     $profilePer = $profilePer + 1;
                 }
                 if (Auth::user()->corpuser->slogan != null) {
                     $profilePer = $profilePer + 1;
                 }
                 if (Auth::user()->corpuser->firm_email_id != null) {
                     $profilePer = $profilePer + 1;
                 }
                 if (Auth::user()->corpuser->logo_status != null) {
                     $profilePer = $profilePer + 1;
                 }
                 if (Auth::user()->corpuser->about_firm != null) {
                     $profilePer = $profilePer + 1;
                 }
                 if (Auth::user()->corpuser->firm_address != null) {
                     $profilePer = $profilePer + 1;
                 }
                 if (Auth::user()->corpuser->operating_since != null) {
                     $profilePer = $profilePer + 1;
                 }
                 if (Auth::user()->corpuser->linked_skill != null) {
                     $profilePer = $profilePer + 1;
                 }
                 if (Auth::user()->corpuser->website_url != null) {
                     $profilePer = $profilePer + 1;
                 }
                 if (Auth::user()->corpuser->firm_phone != null) {
                     $profilePer = $profilePer + 1;
                 }
                 if (Auth::user()->corpuser->industry != null) {
                     $profilePer = $profilePer + 1;
                 }
                 if (Auth::user()->corpuser->role != null) {
                     $profilePer = $profilePer + 1;
                 }
                 if (Auth::user()->corpuser->city != null) {
                     $profilePer = $profilePer + 1;
                 }
                 $profilePer = round($profilePer / 17 * 100);
             }
         }
         $view->with('session_user', $user)->with('favourites', $favourites)->with('thanksCount', $thanksCount)->with('followCount', $followCount)->with('profilePer', $profilePer)->with('linkrequest', $linkrequestCount)->with('linkCount', $linksCount)->with('groupCount', $groupCount)->with('postCount', $postCount);
     });
     view()->composer('includes-update.header', function ($view) {
         if (Auth::user()->identifier == 1 || Auth::user()->identifier == 2 || Auth::user()->identifier == 3) {
             $applications = Postactivity::with('user', 'post')->join('postjobs', 'postjobs.id', '=', 'postactivities.post_id')->where('postjobs.individual_id', '=', Auth::user()->induser_id)->where('postactivities.apply', '=', 1)->orderBy('postactivities.id', 'desc')->take(5)->get(['postactivities.id', 'postjobs.unique_id', 'postactivities.apply', 'postactivities.apply_dtTime', 'postactivities.user_id', 'postactivities.post_id']);
             $thanks = Postactivity::with('user', 'post')->join('postjobs', 'postjobs.id', '=', 'postactivities.post_id')->where('postjobs.individual_id', '=', Auth::user()->induser_id)->where('postactivities.thanks', '=', 1)->orderBy('postactivities.id', 'desc')->take(5)->get();
             $favourites = Postactivity::with('user')->where('fav_post', '=', 1)->where('user_id', '=', Auth::user()->id)->orderBy('id', 'desc')->get(['id', 'fav_post', 'fav_post_dtTime', 'user_id', 'post_id']);
             $thanksCount = Postactivity::with('user', 'post')->join('postjobs', 'postjobs.id', '=', 'postactivities.post_id')->where('postjobs.individual_id', '=', Auth::user()->induser_id)->where('postactivities.thanks', '=', 1)->orderBy('postactivities.id', 'desc')->sum('postactivities.thanks');
             $applicationsCount = Postactivity::with('user', 'post')->join('postjobs', 'postjobs.id', '=', 'postactivities.post_id')->where('postjobs.individual_id', '=', Auth::user()->induser_id)->where('postactivities.apply', '=', 1)->orderBy('postactivities.id', 'desc')->sum('postactivities.apply');
             $notifications = Notification::with('fromUser', 'toUser')->where('to_user', '=', Auth::user()->id)->orderBy('id', 'desc')->take(5)->get();
             $notificationsCount = Notification::where('to_user', '=', Auth::user()->id)->where('view_status', '=', 0)->count();
         }
         $view->with('applications', $applications)->with('thanks', $thanks)->with('favourites', $favourites)->with('thanksCount', $thanksCount)->with('applicationsCount', $applicationsCount)->with('notifications', $notifications)->with('notificationsCount', $notificationsCount);
     });
 }
Example #19
0
 private function _unfollow($id)
 {
     $follow = Follow::where('user_id', Auth::user()->id)->where('follow_id', (int) $id);
     $follow->delete();
 }