Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

talhaatsix's avatar

Laravel Api | Social networking | Vuejs

Hi I'm new in development . i learn laravel 5.7 .

need help to complete my sample project .

A Social Networking site

Users , Friends , Posts , Chat System , likes , Share .

1 ) how can i design db .

2 ) How to create api with custom auth and token multiple devices .

3 ) How Chat system design for 1-1 chat and group

4 ) Add settings in users for posts , public , private and friends

5 ) Single Post Privacy settings public , private and friends

6 ) Share Post (i'm duplicating the post with shared user_id)

7 ) Fetch posts on user newsfeed with checks Users post his friends posts and shared posts and privacy check posts . with pagination

if a user is my friends and his post is private .
if a user is my friends and his general settings for posts is private 

8 ) user pofile info settings his email and address , public private and friends .

i need help how to create this in laravel and is it possible in laravel

0 likes
5 replies
mushood's avatar

Yes this is possible in laravel

As for the other questions, it would take quite some time to answer each and answering them for you would take away from your learning. Could you say what you would do for each of those questions and then we could point you in the correct direction.

For question 2, take a look at laravel passport: https://laravel.com/docs/5.8/passport

Happy learning

talhaatsix's avatar

@MUSHOOD - User Profile Settings .

User 1 -> Can See other User Profile . User have Settings for Profile . Email , Friends and Address . Email Can be Public Private Friends Friends Can be Public Private Friends Address Can be Public Private Friends Post Can be Public Private Friends

For Saving user settings users table -> friends_privacy , email_privacy , post_privacy Columns .

User 1 goes to User 2 Profile .

in controller im checking for $req->user_id!==$req->user()->id than i set $_REQUEST['check_privacy']

Than in User Model i created

 public function getAddressAttribute($value){
    if(!$this->checkPrivacyFor('location_privacy')){
        return "";
    }
    return $value;
}

  private function checkPrivacyFor($key){
    if(isset($_REQUEST['privacy_check']) && $_REQUEST['privacy_check']==true){
        if($this->$key=="Only Me"){
            return false;
        }elseif($this->$key=="Friends" && !$this->areFriends($_REQUEST['requested_user'])){
            return false;
        }elseif($this->$key=="Collaborators" && !$this->areATeam($_REQUEST['requested_user'])){
            if(!$this->areProjectOfficials($_REQUEST['requested_user']))
                return false;
        }
    }
    return true;
} 

this above code is in user model .

is it right approach .....

talhaatsix's avatar

@MUSHOOD - Hi ,

thanks for your help .

and for post (news feed) with user settings and also a single post (with public , private ,friends ) what i do?

public function getFeed(Request $req){

    //All Feed
   
       $friends = Friendship::where(['user_id' => $request->user()->id, 'is_confirmed' => 1])->pluck('friend_id')->toArray();
      $feeds = $feeds->where(function($feeds)use ($friends, $request, &$adminNewestFeedIds) {
                    $feeds = $feeds->where(function($feeds) use ($friends, $request) {
                        $feeds = $feeds->whereRaw("((((user_id IN ('" . implode("','", $friends) . "') ) )AND privacy <> 
                                                     'private') OR user_id = '" . $request->user()->id . "' )");
      });

the above is not a good approach

plz suggest something for fetching feed ..

Please or to participate in this conversation.